From f00a411c176005b9cdcb8cb0539809dbde78ebf5 Mon Sep 17 00:00:00 2001 From: seo-wo <4nyth4me@gmail.com> Date: Wed, 20 Dec 2023 14:39:22 +0900 Subject: [PATCH 1/3] feat: the way not to use isSubmit state wip: need to discuss #139 --- src/assets/css/Rotation/New_Rotation.scss | 11 ++++++----- src/components/Rotation/Rotation.tsx | 19 ++----------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/assets/css/Rotation/New_Rotation.scss b/src/assets/css/Rotation/New_Rotation.scss index 0988118..10c95bd 100644 --- a/src/assets/css/Rotation/New_Rotation.scss +++ b/src/assets/css/Rotation/New_Rotation.scss @@ -28,7 +28,7 @@ flex-direction: column; justify-content: center; align-items: center; - margin-bottom: 20px; + // margin-bottom: 20px; } .rotation-viewSelectDates-title { @@ -56,12 +56,13 @@ color: $pinkred; font-weight: bold; cursor: pointer; - font-size: 13px; - border: none; + font-size: 20px; + border: 1px solid $pinkred; border-radius: 10px; transition: 0.5s ease; display: flex; align-items: center; + text-align: center; background: none; } button:hover { @@ -128,8 +129,8 @@ } button[disabled] { background: #f0f0f0 !important;} button:not([disabled]) { - background: none !important; - &.selected, &.attendLimited { background: #01BABC !important; } + background: rgb(53, 218, 196)!important; + &.selected, &.attendLimited { background: rgb(237, 89, 89) !important; } &:not(.selectable):hover { cursor: default !important;} } } \ No newline at end of file diff --git a/src/components/Rotation/Rotation.tsx b/src/components/Rotation/Rotation.tsx index 62423ad..5792f4e 100644 --- a/src/components/Rotation/Rotation.tsx +++ b/src/components/Rotation/Rotation.tsx @@ -301,12 +301,6 @@ const SelectDateBox = ({ >
-
{isSubmit ? '불가능하다고 제출한 날짜' : '불가능한 날짜'}
-
- {createUnavailableDates(record).map((date, i) => ( - {date} - ))} -
{!isSubmit && (
@@ -430,6 +424,7 @@ export const Rotate = () => { .then(() => { alert('성공적으로 신청 취소되었습니다'); mutate(`${getAddress()}/rotations/attendance`); + setIsSubmit(false); pageReload(); }) .catch((err) => { @@ -452,21 +447,11 @@ export const Rotate = () => { */ useEffect(() => { async function fetchAttendLimit(intraId: string, currDate: Date) { - // if (checkIsPeriod(null) && checkTokenAndRedirect(null) && intraId) { - // try { - // const attendLimitData = await getAttendLimit(intraId, currDate); - // const attendLimit = attendLimitData.attendLimit; - // setIsSumbit(true); - // setRecord(updateRecord(initialRecord, attendLimit)); - // } catch (error) { - // errorAlert(error); - // } - // } if (checkTokenAndRedirect(null) && intraId) { try { const attendLimitData = await getAttendLimit(); const attendLimit = attendLimitData.attendLimit; - setIsSubmit(true); + setIsSubmit(false); setRecord(updateRecord(initialRecord, attendLimit)); } catch (error) { setIsSubmit(false); From 3ab5351b4076a5e5e0b1ac41217b3a1e7233ae19 Mon Sep 17 00:00:00 2001 From: seo-wo <4nyth4me@gmail.com> Date: Wed, 20 Dec 2023 14:39:44 +0900 Subject: [PATCH 2/3] feat: mobile login and logout --- src/components/utils/MobileNavber.tsx | 42 +++++++++++++++------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/components/utils/MobileNavber.tsx b/src/components/utils/MobileNavber.tsx index 8f02642..e929b6a 100644 --- a/src/components/utils/MobileNavber.tsx +++ b/src/components/utils/MobileNavber.tsx @@ -5,25 +5,35 @@ import { useSetRecoilState } from 'recoil'; import GlobalLoginState from '@recoil/GlobalLoginState'; import { clearToken, getToken } from '@cert/TokenStorage'; import hambergImg from '@img/bars-solid-white.svg'; +import getAddress from '@globalObj/function/getAddress'; +import apiClient from '@service/apiClient'; function MobileNavber() { const navigate = useNavigate(); const setLoginState = useSetRecoilState(GlobalLoginState); const [modalOpen, setModalOpen] = useState(false); + const url = `${getAddress()}/auth/google`; const onClickLogOut = () => { - clearToken(); - setLoginState(() => { - return { - id: '', - isLogin: false, - isAdmin: false, - profileUrl: '', - }; - }); - setModalOpen((prev) => !prev); - alert('로그아웃 되셨습니다!'); - navigate('/'); + apiClient + .post('/auth/logout') + .then(() => { + clearToken(); + setLoginState(() => { + return { + id: '', + isLogin: false, + isAdmin: false, + profileUrl: '', + }; + }); + setModalOpen((prev) => !prev); + alert('로그아웃 되셨습니다!'); + navigate('/'); + }) + .catch((err) => { + alert('로그아웃에 실패했습니다.'); + }); }; const onClickModalShow = () => { @@ -88,13 +98,7 @@ function MobileNavber() { 사서 달력 {/* 친스타그램 */} 집현전실록 - {getToken() ? ( - 로그아웃 - ) : ( - - 로그인하기 - - )} + {getToken() ? 로그아웃 : 구글 로그인}
)}
From 8e5b33462f4bb6fc5be7dd10a3a98ff4e8e8b46a Mon Sep 17 00:00:00 2001 From: seo-wo <4nyth4me@gmail.com> Date: Wed, 20 Dec 2023 15:20:44 +0900 Subject: [PATCH 3/3] fix: change the way of getting user name --- src/components/Main/Apply.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Main/Apply.tsx b/src/components/Main/Apply.tsx index 0a8541a..6d53b4a 100644 --- a/src/components/Main/Apply.tsx +++ b/src/components/Main/Apply.tsx @@ -12,6 +12,7 @@ import CreateEventBox from './CreateEventBox'; import useSWR from 'swr'; import fetcher from '@globalObj/function/fetcher'; import Event from './Event'; +import { getDecodedToken } from '@cert/TokenStorage'; import apiClient from '@service/apiClient'; function Apply() { @@ -84,7 +85,7 @@ function Apply() { return (

- {getToken() ? `${LoginState.id}님, 신청하시죠?` : '로그인 후 신청 가능!'} + {getToken() ? `${getDecodedToken().id}님, 신청하시죠?` : '로그인 후 신청 가능!'}