diff --git a/src/api/main/index.ts b/src/api/main/index.ts index efcd884..a60e26a 100644 --- a/src/api/main/index.ts +++ b/src/api/main/index.ts @@ -8,6 +8,8 @@ export const GetName = () => { queryFn: async () => { const result = await instance.get("/admin/my-name"); localStorage.setItem("name", result.data.name); + localStorage.setItem("grade", JSON.stringify(result.data.grade)); + localStorage.setItem("class_num", JSON.stringify(result.data.class_num)); return result.data.name; }, }); diff --git a/src/app/afterManage/page.tsx b/src/app/afterManage/page.tsx index fd41805..f3cf8ac 100644 --- a/src/app/afterManage/page.tsx +++ b/src/app/afterManage/page.tsx @@ -272,10 +272,14 @@ const AfterManage = () => { 출결 저장하기 ) - ) : ( + ) : selectedTab ? ( + ) : ( + )} diff --git a/src/app/classChange/page.tsx b/src/app/classChange/page.tsx index 5076323..d93d374 100644 --- a/src/app/classChange/page.tsx +++ b/src/app/classChange/page.tsx @@ -25,11 +25,19 @@ const ClassChange = () => { const router = useRouter(); const Accept = async () => { - setAccept(true); + if (selectedStudents.length === 0) { + alert("교실 이동 수락 할 학생을 선택해 주세요"); + } else { + setAccept(true); + } }; const Refuse = () => { - setRefuse(true); + if (selectedStudents.length === 0) { + alert("교실 이동 거절 할 학생을 선택해 주세요"); + } else { + setRefuse(true); + } }; useEffect(() => { @@ -107,6 +115,20 @@ const ClassChange = () => { } }; + const acceptColor = () => { + if (selectedStudents.length === 0) { + return "solidDisabled"; + } + return "primary"; + }; + + const refuseColor = () => { + if (selectedStudents.length === 0) { + return "ghostDisabled"; + } + return "red"; + }; + return ( {}} @@ -119,11 +141,15 @@ const ClassChange = () => {
-
} > - {data?.map((item, index) => ( - handleAcceptListClick(item.id, item.username)} - prevClass={`${item.grade}-${item.class_num}`} - nextClass={`${item.classroom_name}`} - student={getStudentString(item)} - /> - ))} +
+ {data?.map((item, index) => ( + handleAcceptListClick(item.id, item.username)} + prevClass={`${item.grade}-${item.class_num}`} + nextClass={`${item.classroom_name}`} + student={getStudentString(item)} + /> + ))} +
{refuse && ( {metadata.title} - + {children} diff --git a/src/app/main/page.tsx b/src/app/main/page.tsx index 93040fb..6621ae0 100644 --- a/src/app/main/page.tsx +++ b/src/app/main/page.tsx @@ -1,8 +1,8 @@ "use client"; import Header from "@/components/header"; -import Button from "./button"; +import Button from "../../components/main/button"; import { useEffect, useState } from "react"; -import CheckPage from "./checkPage"; +import CheckPage from "../../components/main/checkPage"; import { GetName, GetTodaydirector } from "@/api/main"; import { getToday, getWeekDay } from "@/util/date"; import AfterManageImg from "@/assets/svg/aferManege.svg"; @@ -25,7 +25,7 @@ const Main = () => {
diff --git a/src/app/outAccept/page.tsx b/src/app/outAccept/page.tsx index 3f43b5c..386b779 100644 --- a/src/app/outAccept/page.tsx +++ b/src/app/outAccept/page.tsx @@ -30,6 +30,15 @@ const OutAccept = () => { AcceptDataList(); }, [selectGrade, selectClass]); + useEffect(() => { + const grade = parseInt(localStorage.getItem("grade") || "1", 10); + const class_num = parseInt(localStorage.getItem("class_num") || "1", 10); + const setgrade = grade === 0 ? 1 : grade; + const setclass_num = class_num === 0 ? 1 : class_num; + setSelectGrade(setgrade); + setSelectClass(setclass_num); + }, []); + const handleGradeChange = (selectedOption: number) => { if (selectedOption === 5) { setSelectGrade(5); @@ -39,6 +48,20 @@ const OutAccept = () => { } }; + const acceptColor = () => { + if (selectedStudents.length === 0) { + return "solidDisabled"; + } + return "primary"; + }; + + const refuseColor = () => { + if (selectedStudents.length === 0) { + return "ghostDisabled"; + } + return "red"; + }; + const handleClassChange = (selectedOption: number) => { if (selectGrade === 5) { alert("학년을 선택해주세요"); @@ -97,7 +120,9 @@ const OutAccept = () => { }; const Accept = () => { - setAcModal(true); + if (selectedStudents.length === 0) { + alert("외출 수락 할 학생을 선택해주세요"); + } else setAcModal(true); }; const onCancel = () => { @@ -106,7 +131,9 @@ const OutAccept = () => { }; const No = () => { - setNomodal(true); + if (selectedStudents.length === 0) { + alert("외출 거절 할 학생을 선택해주세요"); + } else setNomodal(true); }; const onClickTab = (tab: boolean) => { @@ -125,6 +152,7 @@ const OutAccept = () => { }, { onSuccess: () => { + location.reload(); setNomodal(false); }, onError: (error) => { @@ -152,8 +180,8 @@ const OutAccept = () => { }, { onSuccess: () => { + location.reload(); setAcModal(false); - // location.reload(); }, onError: (error) => { console.error("Out accept error", error); @@ -183,11 +211,15 @@ const OutAccept = () => {
-