diff --git a/src/app/afterManage/page.tsx b/src/app/afterManage/page.tsx index 35d6c3f..068bb10 100644 --- a/src/app/afterManage/page.tsx +++ b/src/app/afterManage/page.tsx @@ -24,13 +24,13 @@ const AfterManage = () => { const [modal, setModal] = useState(false); const [change, setChange] = useState(false); const [clubList, setClubList] = useState([]); - const [dataList, setDataList] = useState(); const [saveModal, setSaveModal] = useState(false); + const [dataList, setDataList] = useState(); const [selectClub, setSelectClub] = useState("대동여지도"); const { selectedStudents, selectedStudentName, handleAcceptListClick } = useAcceptListSelection(); - const { data: getAfter } = GetAfterStudent(); - const { data: getClub } = GetClubList(selectClub); + const { data: getAfter, refetch: ReGetAfter } = GetAfterStudent(); + const { data: getClub, refetch: ReGetClub } = GetClubList(selectClub); const { mutate: Post } = PostStudent(); const { mutate: CheckClub } = CheckStatus(); @@ -148,11 +148,11 @@ const AfterManage = () => { }; updatedData.push(studentData); } - FixStatusMutate(updatedData, { - onSuccess: () => { - location.reload(); - }, - }); + }); + FixStatusMutate(updatedData, { + onSuccess: () => { + ReGetAfter(); + }, }); setSaveModal(false); }; diff --git a/src/app/components/common/list/after/check/page.tsx b/src/app/components/common/list/after/check/page.tsx index 9facdc4..d40676c 100644 --- a/src/app/components/common/list/after/check/page.tsx +++ b/src/app/components/common/list/after/check/page.tsx @@ -1,6 +1,7 @@ "use client"; import React, { useEffect, useState } from "react"; import AfterCheck from "../page"; +import useAttendanceStore from "@/stores/useChangeStatus"; interface State { state1: string; @@ -41,6 +42,8 @@ const CheckList: React.FC = ({ return "현체"; case "EMPLOYMENT": return "취업"; + case "GO_HOME": + return "귀가"; default: return ""; } @@ -55,7 +58,6 @@ const CheckList: React.FC = ({ useEffect(() => { localStorage.setItem(id, JSON.stringify(statusList)); }, [id, statusList]); - const handleChange = (index: number, newState: string) => { const newStatusList = [...statusList]; for (let i = index; i < newStatusList.length; i++) { diff --git a/src/app/components/common/list/after/page.tsx b/src/app/components/common/list/after/page.tsx index 946e610..e6642a7 100644 --- a/src/app/components/common/list/after/page.tsx +++ b/src/app/components/common/list/after/page.tsx @@ -65,6 +65,8 @@ const AfterCheck: React.FC = ({ state, onChange, type }) => { return "#414BA2"; case "출석": return "#475467"; + case "귀가": + "#475467"; default: return undefined; } @@ -80,6 +82,8 @@ const AfterCheck: React.FC = ({ state, onChange, type }) => { return "MOVEMENT"; case "출석": return "ATTENDANCE"; + case "귀가": + return "GO_HOME"; default: return ""; } @@ -131,6 +135,12 @@ const AfterCheck: React.FC = ({ state, onChange, type }) => { > 외출 +
handleOptionClick("귀가")} + > + 귀가 +
handleOptionClick("무단")} diff --git a/src/app/selfStudyCheck/page.tsx b/src/app/selfStudyCheck/page.tsx index 4b2cf8a..81d85fd 100644 --- a/src/app/selfStudyCheck/page.tsx +++ b/src/app/selfStudyCheck/page.tsx @@ -34,7 +34,10 @@ const SelfStudyCheck = () => { const [edit, setEdit] = useState(false); const [saveModal, setSaveModal] = useState(false); const { mutate: ChangeMutate } = CheckStatus(); - const { data: CheckMutate } = ClassStudentCheck(selectedGrade, selectedClass); + const { data: CheckMutate, refetch: ReCheckData } = ClassStudentCheck( + selectedGrade, + selectedClass + ); const { selectedStudentName, handleAcceptListClick } = useAcceptListSelection(); const { addStudent, updateStatus, getStatus, students } = @@ -63,7 +66,7 @@ const SelfStudyCheck = () => { try { await ChangeMutate(updatedData, { onSuccess: () => { - location.reload(); + ReCheckData(); }, onError: (error) => { alert(error.name); diff --git a/src/stores/useChangeStatus.ts b/src/stores/useChangeStatus.ts index 84df46b..8ebc5dc 100644 --- a/src/stores/useChangeStatus.ts +++ b/src/stores/useChangeStatus.ts @@ -2,36 +2,36 @@ import create from "zustand"; interface Student { user_id: string; - status: string; + status_list: string[]; } interface AttendanceStore { students: Student[]; - addStudent: (user_id: string, status?: string) => void; - updateStatus: (user_id: string, status: string) => void; - getStatus: (user_id: string) => string | undefined; + addStudent: (user_id: string, status_list?: string[]) => void; + updateStatus: (user_id: string, status_list: string[]) => void; + getStatus: (user_id: string) => string[] | undefined; } const useAttendanceStore = create((set, get) => ({ students: [], - addStudent: (user_id, status = "ATTENDANCE") => { + addStudent: (user_id, status_list = ["ATTENDANCE"]) => { set((state) => ({ - students: [...state.students, { user_id, status }], + students: [...state.students, { user_id, status_list }], })); }, - updateStatus: (user_id, status) => { + updateStatus: (user_id, status_list) => { set((state) => ({ students: state.students.map((student) => - student.user_id === user_id ? { ...student, status } : student + student.user_id === user_id ? { ...student, status_list } : student ), })); }, getStatus: (user_id) => { return get().students.find((student) => student.user_id === user_id) - ?.status; + ?.status_list; }, }));