Skip to content

Commit

Permalink
develop -> main
Browse files Browse the repository at this point in the history
  • Loading branch information
phyuna0525 committed Nov 12, 2024
2 parents 19af3e9 + a2966cf commit 8b60dea
Show file tree
Hide file tree
Showing 20 changed files with 108 additions and 61 deletions.
17 changes: 9 additions & 8 deletions src/apis/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -57,16 +58,16 @@ export const MyName = () => {
});
};

export const GetAllTeacher = () => {
return useQuery<string[]>({
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,
});
};
6 changes: 4 additions & 2 deletions src/apis/story/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<DetailApplication>(`${router}/query/${student_id}`);
const { data } = await instance.get<DetailApplication>(
`${router}/query/${student_id}`,
);
return data;
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/StudentsState/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<S.StudentsStateContainer>
<S.StudentsStateFlexbox>
Expand Down
2 changes: 1 addition & 1 deletion src/components/calendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const Calendar = ({ type }: CalendarProp) => {
</Width>
{modal && selectedDate && (
<Modal
refetchStatus={ReSelfStudyData}
refetchStatus={type === 'schedule' ? ReScheduleData : ReSelfStudyData}
type={type}
title={`${selectedMonth}${selectedDay}${selectedWeekday}`}
subTitle="오늘의 자습감독 선생님"
Expand Down
2 changes: 1 addition & 1 deletion src/components/calendar/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '@/styles/theme';
import { theme } from '@/styles/theme';

export const Container = styled.section`
width: 100%;
min-width: 1000px;
display: flex;
flex-direction: column;
align-items: center;
Expand Down
18 changes: 11 additions & 7 deletions src/components/input/search.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as S from './style';
import React, { useEffect, useRef, useState } from 'react';
import search from '@/assets/svg/search.svg';
import { GetAllTeacher } from '@/apis/admin';
import useTeacherListInformation from '@/stores/teacherlist';

interface ChangeProps {
text: string;
Expand All @@ -26,8 +26,8 @@ const SearchInput = ({
value,
type,
}: InputProp) => {
const { data: teacherData } = GetAllTeacher();
const [filteredTeachers, setFilteredTeachers] = useState<string[]>([]);
const { teacher } = useTeacherListInformation();
const [filteredTeachers, setFilteredTeachers] = useState<string[]>(teacher);
const [list, setList] = useState<boolean>(false);
const dropdownRef = useRef<HTMLDivElement>(null);

Expand All @@ -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 || []);
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/input/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 14 additions & 2 deletions src/components/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,29 @@ 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<boolean>(false);

const handleClick = () => {
setIsActive(!isActive);
onClick();
};
return (
<S.OutAcceptWrap draggable isActive={isActive} onClick={handleClick}>
<S.OutAcceptWrap
type={type}
draggable
isActive={isActive}
onClick={handleClick}
>
<S.OutAcceptTitle>{name}</S.OutAcceptTitle>
<div>외출</div>
<S.OutAcceptDate>{date}</S.OutAcceptDate>
Expand Down
11 changes: 8 additions & 3 deletions src/components/list/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { theme } from '@/styles/theme';

interface AcceptListProp {
isActive: boolean;
type: 'application' | 'early-return';
}
export const OutAcceptWrap = styled.div<AcceptListProp>`
display: flex;
Expand All @@ -13,10 +14,14 @@ export const OutAcceptWrap = styled.div<AcceptListProp>`
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`
Expand Down
2 changes: 1 addition & 1 deletion src/components/mainRouterButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const MainRouterButton = () => {
},
{
img: clubManagement,
text: '전공동아리 관리',
text: '전공동아리 출결',
router: '/club',
},
{
Expand Down
4 changes: 3 additions & 1 deletion src/components/modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -86,6 +86,7 @@ export const Modal = ({
type: 'success',
message: '삭제되었습니다',
});
reSchedule();
refetchStatus();
},
},
Expand Down Expand Up @@ -128,6 +129,7 @@ export const Modal = ({
type: 'success',
message: '학사일정이 추가되었습니다',
});
setState(false);
refetchStatus();
},
onError: (error) => {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<Header />
Expand Down
3 changes: 2 additions & 1 deletion src/pages/RequestClass.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const RequestClass = () => {
<>
<Button
onClick={() => {
nav('accpet');
nav('/classMoveList');
}}
size="small"
type="main"
Expand Down Expand Up @@ -123,6 +123,7 @@ const RequestClass = () => {
/>
{modal && (
<Modal
refetchStatus={() => {}}
type="check"
onCancel={() => {
setModal(false);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/club/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const ClubPage = () => {

return (
<Layout
now="전공동아리 관리"
title="전공동아리 관리"
now="전공동아리 출결"
title="전공동아리 출결"
right={
<>
<Dropdown
Expand Down
7 changes: 3 additions & 4 deletions src/pages/notice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ const NoticePage = () => {

const notices: SimpleNoticeType[] = Array.isArray(data) ? data : [];

const filteredNotices = notices.filter(
(notice: SimpleNoticeType) =>
notice.title.includes(searchTerm) || notice.id.includes(searchTerm),
const filteredNotices = notices.filter((notice: SimpleNoticeType) =>
notice.title.includes(searchTerm),
);

return (
Expand All @@ -43,7 +42,7 @@ const NoticePage = () => {
<SearchInput
type="Search"
value={searchTerm}
placeholder="입력하세요"
placeholder="검색할 공지의 제목을 입력해주세요"
onChange={handleSearchChange}
/>
</>
Expand Down
11 changes: 9 additions & 2 deletions src/pages/outAccept/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { showToast } from '@/components/toast';
import { Toggle } from '@/components/toggle';
import Modal from '@/components/modal';
import { useAcceptModal } from '@/hook/useModal';
import { getStudentString } from '@/utils/utils';

const OutAccept = () => {
const [selectedGrade, setSelectedGrade] = useState<number>(5);
Expand Down Expand Up @@ -102,10 +103,15 @@ const OutAccept = () => {
{GetOutRequest?.length ? (
GetOutRequest.map((item, index) => (
<OutAcceptList
type={currentMenu}
key={index}
name={item.user_name}
name={getStudentString(item)}
content={item.reason}
date={item.end ? `${item.start}~${item.end}` : `${item.start}`}
date={
item.end
? `${item.start.slice(0, 5)} ~ ${item.end.slice(0, 5)}`
: `${item.start.slice(0, 5)}`
}
onClick={() => handleAcceptListClick(item.id, item.user_name)}
/>
))
Expand Down Expand Up @@ -137,6 +143,7 @@ const OutAccept = () => {
/>
{modal && (
<Modal
refetchStatus={() => {}}
type="check"
title={useAcceptModal({
students: selectedStudentName,
Expand Down
25 changes: 15 additions & 10 deletions src/pages/outList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { useState, useEffect } from 'react';
import Modal from '@/components/modal';
import Dropdown from '@/components/dropdown';
import { FloorOption } from '@/utils/dropdown';
import { toast } from 'react-toastify';
import useSelectionStore from '@/stores/useSelect';
import { showToast } from '@/components/toast';
import { Toggle } from '@/components/toggle';
import { useGetEarlyReturnList } from '@/apis/early-return';
import { getStudentString } from '@/utils/utils';

const OutList = () => {
const {
Expand Down Expand Up @@ -69,11 +69,13 @@ const OutList = () => {
right={
<>
<Toggle onChange={setCurrentMenu} />
<Dropdown
options={FloorOption}
value={selectedFloor}
changeHandler={handleFloorChange}
/>
{currentMenu === 'application' && (
<Dropdown
options={FloorOption}
value={selectedFloor}
changeHandler={handleFloorChange}
/>
)}
</>
}
>
Expand All @@ -85,10 +87,11 @@ const OutList = () => {
OutListFloorData?.length ? (
OutListFloorData?.map((item, index) => (
<OutAcceptList
type={currentMenu}
key={index}
name={item.user_name}
name={getStudentString(item)}
content={item.reason}
date={`${item.start} ~ ${item.end}`}
date={`${item.start.slice(0, 5)} ~ ${item.end.slice(0, 5)}`}
onClick={() => handleAcceptListClick(item.id, item.user_name)}
/>
))
Expand All @@ -98,10 +101,11 @@ const OutList = () => {
) : earlyreturnListData?.length ? (
earlyreturnListData?.map((item) => (
<OutAcceptList
type={currentMenu}
key={item.class_num}
name={item.user_name}
name={getStudentString(item)}
content={item.reason}
date={item.start}
date={item.start.slice(0, 5)}
onClick={() => {}}
/>
))
Expand All @@ -121,6 +125,7 @@ const OutList = () => {
)}
{modal && (
<Modal
refetchStatus={() => {}}
type="red"
title={`${
selectedStudentName.length > 1
Expand Down
2 changes: 1 addition & 1 deletion src/pages/previousList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const PreviousList = () => {
}
>
<ContentWrap>
{Loading && <p>로딩중~</p>}
{Loading && <p>로딩중...</p>}
{filteredStudents?.map((item) => (
<StoryList
id={item.id}
Expand Down
Loading

0 comments on commit 8b60dea

Please sign in to comment.