diff --git a/src/apis/admin/index.ts b/src/apis/admin/index.ts index 16ea904..dcce86e 100644 --- a/src/apis/admin/index.ts +++ b/src/apis/admin/index.ts @@ -5,6 +5,7 @@ import { cookie } from '@/utils/auth'; import { Login } from './request'; import { instance } from '@/apis'; import { MynameType } from '@/apis/type'; +import useTeacherListInformation from '@/stores/teacherlist'; const router = 'admin'; @@ -57,16 +58,16 @@ export const MyName = () => { }); }; -export const GetAllTeacher = () => { - return useQuery({ +export const useGetAllTeacher = () => { + const { teacher, setTeacher } = useTeacherListInformation(); + + return useQuery({ queryKey: ['GetAllTeacher'], queryFn: async () => { - try { - const { data } = await instance.get(`${router}/all`); - return data; - } catch (error) { - console.log(''); - } + const { data } = await instance.get(`${router}/all`); + setTeacher(data); + return data; }, + enabled: teacher.length === 0, }); }; diff --git a/src/apis/story/index.ts b/src/apis/story/index.ts index 006342c..31e4827 100644 --- a/src/apis/story/index.ts +++ b/src/apis/story/index.ts @@ -16,9 +16,11 @@ export const AllList = () => { export const DetailList = (student_id: string) => { return useQuery({ - queryKey: ["DetailList", student_id], + queryKey: ['DetailList', student_id], queryFn: async () => { - const { data } = await instance.get(`${router}/query/${student_id}`); + const { data } = await instance.get( + `${router}/query/${student_id}`, + ); return data; }, }); diff --git a/src/components/StudentsState/index.tsx b/src/components/StudentsState/index.tsx index 800e30c..07b3015 100644 --- a/src/components/StudentsState/index.tsx +++ b/src/components/StudentsState/index.tsx @@ -13,7 +13,7 @@ const StudentsState = ({ type, person }: StudentsStateType) => { const buttonText = type === 'outing' ? '외출자 목록 보기' : '교실 이동 학생 보기'; const img = type === 'outing' ? outingImg : classroomMovementImg; - const rout = type === 'outing' ? 'outList' : 'classMove'; + const rout = type === 'outing' ? 'outList' : '/classMoveList'; return ( diff --git a/src/components/calendar/index.tsx b/src/components/calendar/index.tsx index 906fd5f..b500a3e 100644 --- a/src/components/calendar/index.tsx +++ b/src/components/calendar/index.tsx @@ -199,7 +199,7 @@ const Calendar = ({ type }: CalendarProp) => { {modal && selectedDate && ( { - const { data: teacherData } = GetAllTeacher(); - const [filteredTeachers, setFilteredTeachers] = useState([]); + const { teacher } = useTeacherListInformation(); + const [filteredTeachers, setFilteredTeachers] = useState(teacher); const [list, setList] = useState(false); const dropdownRef = useRef(null); @@ -37,10 +37,14 @@ const SearchInput = ({ if (type === 'self') { setList(true); - const filteredList = teacherData?.filter((teacher: string) => - teacher.toLowerCase().includes(inputValue.toLowerCase()), - ); - setFilteredTeachers(filteredList || ['']); + + const filteredList = inputValue + ? teacher?.filter((teacher: string) => + teacher.toLowerCase().includes(inputValue.toLowerCase()), + ) + : teacher; + + setFilteredTeachers(filteredList || []); } }; diff --git a/src/components/input/style.ts b/src/components/input/style.ts index d6823a4..8f98c4c 100644 --- a/src/components/input/style.ts +++ b/src/components/input/style.ts @@ -98,9 +98,9 @@ export const TeacherList = styled.div` background-color: ${theme.color.normal.white}; width: 100%; top: 110%; + height: 200px; + overflow: auto; z-index: 1; - max-height: 256px; - min-height: fit-content; overflow-y: scroll; border: 1px solid ${theme.color.gray[100]}; border-radius: 12px; diff --git a/src/components/list/index.tsx b/src/components/list/index.tsx index f0775d2..ff94c67 100644 --- a/src/components/list/index.tsx +++ b/src/components/list/index.tsx @@ -6,9 +6,16 @@ interface OutAcceptProp { date: string; content: string; onClick: () => void; + type: 'application' | 'early-return'; } -const OutAcceptList = ({ name, date, content, onClick }: OutAcceptProp) => { +const OutAcceptList = ({ + name, + date, + content, + onClick, + type, +}: OutAcceptProp) => { const [isActive, setIsActive] = useState(false); const handleClick = () => { @@ -16,7 +23,12 @@ const OutAcceptList = ({ name, date, content, onClick }: OutAcceptProp) => { onClick(); }; return ( - + {name}
외출
{date} diff --git a/src/components/list/style.ts b/src/components/list/style.ts index 8b612d2..4c43948 100644 --- a/src/components/list/style.ts +++ b/src/components/list/style.ts @@ -3,6 +3,7 @@ import { theme } from '@/styles/theme'; interface AcceptListProp { isActive: boolean; + type: 'application' | 'early-return'; } export const OutAcceptWrap = styled.div` display: flex; @@ -13,10 +14,14 @@ export const OutAcceptWrap = styled.div` min-width: min-content; background-color: ${theme.color.main[50]}; border: 2px solid - ${({ isActive }) => - isActive ? theme.color.main[500] : theme.color.main[50]}; + ${({ isActive, type }) => + isActive && type === 'application' + ? theme.color.main[500] + : theme.color.main[50]}; &:hover { - border: 2px solid ${theme.color.main[500]}; + border: 2px solid + ${({ type }) => + type === 'application' ? theme.color.main[500] : 'transparent'}; } `; export const OutAcceptTitle = styled.p` diff --git a/src/components/mainRouterButton/index.tsx b/src/components/mainRouterButton/index.tsx index 1ea319d..6604830 100644 --- a/src/components/mainRouterButton/index.tsx +++ b/src/components/mainRouterButton/index.tsx @@ -57,7 +57,7 @@ const MainRouterButton = () => { }, { img: clubManagement, - text: '전공동아리 관리', + text: '전공동아리 출결', router: '/club', }, { diff --git a/src/components/modal/index.tsx b/src/components/modal/index.tsx index bb9a683..cb9958a 100644 --- a/src/components/modal/index.tsx +++ b/src/components/modal/index.tsx @@ -58,7 +58,7 @@ export const Modal = ({ const { mutate: postTeacherMutate } = PostTeacher(); const { mutate: addScheduleMutate } = AddSchedule(); const { mutate: Delete } = DeleteSchedule(); - const { data: Schedule } = DaySchedule(date); + const { data: Schedule, refetch: reSchedule } = DaySchedule(date); useEffect(() => { if (!SelectSelfList?.length) return; @@ -86,6 +86,7 @@ export const Modal = ({ type: 'success', message: '삭제되었습니다', }); + reSchedule(); refetchStatus(); }, }, @@ -128,6 +129,7 @@ export const Modal = ({ type: 'success', message: '학사일정이 추가되었습니다', }); + setState(false); refetchStatus(); }, onError: (error) => { diff --git a/src/pages/Main/index.tsx b/src/pages/Main/index.tsx index 48f0b68..6874214 100644 --- a/src/pages/Main/index.tsx +++ b/src/pages/Main/index.tsx @@ -2,10 +2,10 @@ import Header from '@/components/header'; import * as S from './style'; import mainLogo from '@/assets/svg/mainLogo.svg'; import MainRouterButton from '@/components/mainRouterButton'; -import { showToast } from '@/components/toast'; -import { useEffect } from 'react'; +import { useGetAllTeacher } from '@/apis/admin'; const Main = () => { + useGetAllTeacher(); return ( <>
diff --git a/src/pages/RequestClass.tsx b/src/pages/RequestClass.tsx index 3bcff90..13f36c8 100644 --- a/src/pages/RequestClass.tsx +++ b/src/pages/RequestClass.tsx @@ -69,7 +69,7 @@ const RequestClass = () => { <>