From 789640bb032c910d5d86471ea23dc05a8c79aeb4 Mon Sep 17 00:00:00 2001 From: hyuna Date: Thu, 31 Oct 2024 10:57:25 +0900 Subject: [PATCH 01/29] =?UTF-8?q?chore=20::=20=EC=A3=BC=EB=A7=90=EA=B8=89?= =?UTF-8?q?=EC=8B=9D=20=EC=9C=A0=EC=A0=80=20=EC=A0=84=EC=B2=B4=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EB=B6=88=EB=9F=AC=EC=98=A4=EA=B8=B0=20api?= =?UTF-8?q?=20url=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/weekend-meals/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apis/weekend-meals/index.ts b/src/apis/weekend-meals/index.ts index ceeb50e..14accea 100644 --- a/src/apis/weekend-meals/index.ts +++ b/src/apis/weekend-meals/index.ts @@ -13,7 +13,7 @@ export const GetAllMeals = () => { return useQuery({ queryKey: [], queryFn: async () => { - const { data } = await instance.get(`${router}/hey`); + const { data } = await instance.get(`${router}/application-list`); return data; }, }); From 02a7ee6b1ac99498f43b4476636c2b542b7328ea Mon Sep 17 00:00:00 2001 From: hyuna Date: Thu, 31 Oct 2024 10:57:44 +0900 Subject: [PATCH 02/29] =?UTF-8?q?chore=20::=20=EC=A3=BC=EB=A7=90=EA=B8=89?= =?UTF-8?q?=EC=8B=9D=20=EB=AA=A8=EB=8B=AC=20=EA=B8=B0=EA=B0=84=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/modal/weekendmealModal.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/modal/weekendmealModal.tsx b/src/components/modal/weekendmealModal.tsx index 8c6fa1f..982e32c 100644 --- a/src/components/modal/weekendmealModal.tsx +++ b/src/components/modal/weekendmealModal.tsx @@ -65,6 +65,17 @@ export const WeekendMealModal = ({ setMonth(data); }; + useEffect(() => { + if (!weekendMealInfo?.[0]?.data || !weekendMealInfo?.[1]?.data) return; + const { start, end } = weekendMealInfo[0].data; + const { month } = weekendMealInfo[1].data; + if (start && end) { + setEndData(end); + setStartData(start); + setMonth(month); + } + }, [weekendMealInfo?.[0]?.data, weekendMealInfo?.[1]?.data]); + const handleDateChange = (date: any) => { selectedDate.selectDate(date); if (isStartOpen) { From c002923cfe9d0ae73b203a1a9fc31dc5e6063225 Mon Sep 17 00:00:00 2001 From: hyuna Date: Thu, 31 Oct 2024 10:58:07 +0900 Subject: [PATCH 03/29] =?UTF-8?q?chore=20::=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/modal/weekendmealModal.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/components/modal/weekendmealModal.tsx b/src/components/modal/weekendmealModal.tsx index 982e32c..61c590a 100644 --- a/src/components/modal/weekendmealModal.tsx +++ b/src/components/modal/weekendmealModal.tsx @@ -103,12 +103,6 @@ export const WeekendMealModal = ({ }; }, []); - // useEffect(() => { - // setEndData(weekendMealInfo[0].data?.end!); - // setStartData(weekendMealInfo[0].data?.start!); - // setMonth(weekendMealInfo[1].data?.month!); - // }, [weekendMealInfo]); - return ( From e48300d25e95395f657d2e0aa34eef4e6f2028cc Mon Sep 17 00:00:00 2001 From: hyuna Date: Thu, 31 Oct 2024 15:03:34 +0900 Subject: [PATCH 04/29] =?UTF-8?q?feat=20::=20=EC=B6=9C=EC=84=9D=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20api=20=EC=97=B0=EB=8F=99=20=EB=B0=8F=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 3 ++- src/apis/index.ts | 2 +- src/components/helpmenu/index.tsx | 2 +- src/components/mainRouterButton/index.tsx | 8 ++++---- src/pages/notice/detail/index.tsx | 1 + src/router/router.tsx | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 11dec4c..88e1b66 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import { RouterProvider } from 'react-router-dom'; +import { RouterProvider, useNavigate } from 'react-router-dom'; import { Router } from './router/router'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { GlobalStyle, theme } from './styles/theme'; @@ -7,6 +7,7 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import 'react-toastify/dist/ReactToastify.css'; import Toast from './components/toast'; import * as ChannelService from '@channel.io/channel-web-sdk-loader'; +import { useEffect } from 'react'; const queryClient = new QueryClient({ defaultOptions: { diff --git a/src/apis/index.ts b/src/apis/index.ts index 6802f59..ccabf9e 100644 --- a/src/apis/index.ts +++ b/src/apis/index.ts @@ -55,7 +55,7 @@ instance.interceptors.response.use( cookie.set('refresh_token', data.refresh_token); }) .catch(() => { - window.location.href = 'login'; + window.location.href = '/'; }); } catch (refreshError) { return Promise.reject(refreshError); diff --git a/src/components/helpmenu/index.tsx b/src/components/helpmenu/index.tsx index f6f14d6..b28d8fb 100644 --- a/src/components/helpmenu/index.tsx +++ b/src/components/helpmenu/index.tsx @@ -17,7 +17,7 @@ const HelfMenu = () => { cookie.remove('access_token'); cookie.remove('refresh_token'); localStorage.clear(); - navigate('/login'); + navigate('/'); }; return ( diff --git a/src/components/mainRouterButton/index.tsx b/src/components/mainRouterButton/index.tsx index 7271e55..d643d31 100644 --- a/src/components/mainRouterButton/index.tsx +++ b/src/components/mainRouterButton/index.tsx @@ -52,7 +52,7 @@ const MainRouterButton = () => { }, { img: classAttendance, - text: '학급 출석', + text: '학급 관리', router: '/classManage', }, // { @@ -62,17 +62,17 @@ const MainRouterButton = () => { // }, { img: changeTeacher, - text: '자습감독 변경', + text: '자습감독', router: '/self-study', }, { img: academicCalendar, - text: '학사 일정 변경', + text: '학사일정 관리', router: '/schedule', }, { img: timetableChange, - text: '시간표 변경', + text: '시간표 관리', router: '/timetable', }, { diff --git a/src/pages/notice/detail/index.tsx b/src/pages/notice/detail/index.tsx index 3f8b982..c40382b 100644 --- a/src/pages/notice/detail/index.tsx +++ b/src/pages/notice/detail/index.tsx @@ -73,6 +73,7 @@ const NoticeDetail = () => { { id: noticeId }, { onSuccess: () => { + router('/notice'); showToast({ type: 'success', message: '공지가 삭제되었습니다.', diff --git a/src/router/router.tsx b/src/router/router.tsx index d42f4fd..ece8671 100644 --- a/src/router/router.tsx +++ b/src/router/router.tsx @@ -33,7 +33,7 @@ export const Router = createBrowserRouter([ element: , }, { - path: 'login', + path: '', element: , }, { From 9e68c4d928eb93c383444f122fbf3fadd54ca242 Mon Sep 17 00:00:00 2001 From: hyuna Date: Thu, 31 Oct 2024 15:55:10 +0900 Subject: [PATCH 05/29] =?UTF-8?q?feat=20::=20=EA=B3=B5=EC=A7=80=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/notice/index.ts | 9 ++++ src/apis/type.ts | 6 +++ src/pages/notice/detail/index.tsx | 75 ++++++++++++++++++++++++++++--- 3 files changed, 83 insertions(+), 7 deletions(-) diff --git a/src/apis/notice/index.ts b/src/apis/notice/index.ts index 8c19bd2..eaacace 100644 --- a/src/apis/notice/index.ts +++ b/src/apis/notice/index.ts @@ -1,6 +1,7 @@ import { useQuery } from '@tanstack/react-query'; import { instance } from '@/apis'; import { + EditNotice, NoticeDetailType, SimpleNoticeType, UploadNoticeType, @@ -46,3 +47,11 @@ export const useDeleteNotice = () => { }, }); }; + +export const useEditNotice = () => { + return useMutation({ + mutationFn: async (param) => { + await instance.patch(`${router}/modify`, param); + }, + }); +}; diff --git a/src/apis/type.ts b/src/apis/type.ts index 0c82ec8..712cd22 100644 --- a/src/apis/type.ts +++ b/src/apis/type.ts @@ -15,6 +15,12 @@ export interface SelectedDaySelfStudTeacher { teacher: string; } +export interface EditNotice { + id: string; + title: string; + content: string; +} + export interface TodayMealsType { date: string; meal_list: { diff --git a/src/pages/notice/detail/index.tsx b/src/pages/notice/detail/index.tsx index 3f8b982..40a2a7b 100644 --- a/src/pages/notice/detail/index.tsx +++ b/src/pages/notice/detail/index.tsx @@ -1,28 +1,67 @@ import React, { useEffect, useState } from 'react'; import { Layout } from '@/components/layout'; import nextSvg from '@/assets/svg/next.svg'; -import { useNavigate, useParams } from 'react-router-dom'; -import { DetailNotice, useDeleteNotice } from '@/apis/notice'; +import { useNavigate, useNavigation, useParams } from 'react-router-dom'; +import { DetailNotice, useDeleteNotice, useEditNotice } from '@/apis/notice'; import * as S from '../style'; import BottomButtonWrap from '@/components/Button/bottom'; import Modal from '@/components/modal'; import { showToast } from '@/components/toast'; +import Input from '@/components/input'; +import { Textarea } from '@/components/input/textarea'; const NoticeDetail = () => { const params = useParams(); + const router = useNavigate(); const noticeId = params.detail || ''; const { data: GetDetailNotice } = DetailNotice(noticeId); const { mutate: DeleteNotice } = useDeleteNotice(); const [deleteNotice, setDeleteNotice] = useState(false); const [name, setName] = useState(''); + const [edit, setEdit] = useState(false); + const { mutate: ModifyNotice } = useEditNotice(); useEffect(() => { const storedName = localStorage.getItem('name'); if (storedName) { setName(storedName); } }, []); + const [data, setData] = useState({ + id: noticeId, + title: GetDetailNotice?.title, + content: GetDetailNotice?.content, + }); - const router = useNavigate(); + useEffect(() => { + setData({ + id: noticeId, + title: GetDetailNotice?.title, + content: GetDetailNotice?.content, + }); + }, [GetDetailNotice]); + + const handleChange = (e: React.ChangeEvent) => { + const { name, value } = e.target; + setData((prevData) => ({ + ...prevData, + [name]: value, + })); + }; + + const Modify = () => { + ModifyNotice(data, { + onSuccess: () => { + window.location.reload(); + }, + onError: () => { + setEdit(false); + showToast({ + type: 'error', + message: '공지 수정에 실패하였습니다', + }); + }, + }); + }; return ( { {GetDetailNotice?.title} } - title={GetDetailNotice?.title} + title={ + edit ? ( + + ) : ( + GetDetailNotice?.title + ) + } right={ @@ -49,12 +99,23 @@ const NoticeDetail = () => { } > - {GetDetailNotice?.content} + + {edit ? ( +