From 40236990aad99d6b1f8d3cb48cea6c5078d76b0f Mon Sep 17 00:00:00 2001 From: sumi-0011 Date: Mon, 29 Jan 2024 17:31:02 +0900 Subject: [PATCH 01/14] =?UTF-8?q?feat:=20motion=20div=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/level/guide/page.tsx | 7 ++--- src/components/Motion/MotionDiv.tsx | 40 +++++++++++++++++++++++++++++ src/constants/style/animation.ts | 33 ------------------------ 3 files changed, 42 insertions(+), 38 deletions(-) create mode 100644 src/components/Motion/MotionDiv.tsx delete mode 100644 src/constants/style/animation.ts diff --git a/src/app/level/guide/page.tsx b/src/app/level/guide/page.tsx index 44e12dfa..a8b77ba1 100644 --- a/src/app/level/guide/page.tsx +++ b/src/app/level/guide/page.tsx @@ -7,11 +7,10 @@ import GrowthLevel from '@/app/level/guide/GrowthLevel'; import LockedCharacter from '@/components/Level/LockedCharacter'; import LevelStatus from '@/components/LevelStatus/LevelStatus'; import LoadingSpinner from '@/components/Loading/LoadingSpinner'; +import MotionDiv from '@/components/Motion/MotionDiv'; import { LEVEL_SYSTEM } from '@/constants/level'; -import { defaultFadeInMotion } from '@/constants/style/animation'; import { css, cx } from '@/styled-system/css'; import { getLevel } from '@/utils/result'; -import { motion } from 'framer-motion'; function LevelGuidePage() { const { data, isLoading } = useGetMissionSummary(); @@ -39,9 +38,7 @@ function LevelGuidePage() {

현재 레벨

- - {selectLevelInfo.label} - + {selectLevelInfo.label}
diff --git a/src/components/Motion/MotionDiv.tsx b/src/components/Motion/MotionDiv.tsx new file mode 100644 index 00000000..145732a6 --- /dev/null +++ b/src/components/Motion/MotionDiv.tsx @@ -0,0 +1,40 @@ +'use client'; + +import { type ComponentProps } from 'react'; +import { motion, type Variants } from 'framer-motion'; + +interface Props extends ComponentProps {} + +function MotionDiv(props: Props) { + return ( + + ); +} + +export default MotionDiv; + +const defaultEasing = [0.6, -0.05, 0.01, 0.99]; + +const defaultFadeInVariants: Variants = { + initial: { + opacity: 0, + transition: { duration: 0.3, ease: defaultEasing }, + willChange: 'opacity', + }, + animate: { + opacity: 1, + transition: { duration: 0.3, ease: defaultEasing }, + willChange: 'opacity', + }, + exit: { + opacity: 0, + transition: { duration: 0.3, ease: defaultEasing }, + willChange: 'opacity', + }, +}; diff --git a/src/constants/style/animation.ts b/src/constants/style/animation.ts deleted file mode 100644 index daa25d02..00000000 --- a/src/constants/style/animation.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { css } from '@/styled-system/css'; -import { type Variants } from 'framer-motion'; - -export const fadeInAnimationCss = css({ - animation: `fadeIn .7s ease-in`, -}); - -export const defaultEasing = [0.6, -0.05, 0.01, 0.99]; - -export const defaultFadeInVariants: Variants = { - initial: { - opacity: 0, - transition: { duration: 0.3, ease: defaultEasing }, - willChange: 'opacity', - }, - animate: { - opacity: 1, - transition: { duration: 0.3, ease: defaultEasing }, - willChange: 'opacity', - }, - exit: { - opacity: 0, - transition: { duration: 0.3, ease: defaultEasing }, - willChange: 'opacity', - }, -}; - -export const defaultFadeInMotion = { - initial: 'initial', - animate: 'animate', - exit: 'exit', - variants: defaultFadeInVariants, -}; From b5209fe04ac9e8a45e680f19dde3ff1ff33c1a18 Mon Sep 17 00:00:00 2001 From: sumi-0011 Date: Mon, 29 Jan 2024 17:40:38 +0900 Subject: [PATCH 02/14] =?UTF-8?q?refactor:=20motion=20div=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EB=B0=8F=20fade=20up=20=EB=AA=A8=EC=85=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/level/guide/Character.tsx | 6 ++--- src/components/Motion/MotionDiv.tsx | 42 ++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/app/level/guide/Character.tsx b/src/app/level/guide/Character.tsx index d312fda0..aea3e7e4 100644 --- a/src/app/level/guide/Character.tsx +++ b/src/app/level/guide/Character.tsx @@ -1,4 +1,5 @@ import Image from 'next/image'; +import MotionDiv from '@/components/Motion/MotionDiv'; import { css, cx } from '@/styled-system/css'; interface Props { @@ -11,7 +12,7 @@ interface Props { function Character(props: Props) { return ( -
)} -
+ ); } @@ -67,7 +68,6 @@ export default Character; const imageWrapperCss = css({ position: 'relative', margin: '0 auto', - animation: 'fadeIn .7s', height: '100%', width: '100%', }); diff --git a/src/components/Motion/MotionDiv.tsx b/src/components/Motion/MotionDiv.tsx index 145732a6..166be474 100644 --- a/src/components/Motion/MotionDiv.tsx +++ b/src/components/Motion/MotionDiv.tsx @@ -1,15 +1,28 @@ 'use client'; -import { type ComponentProps } from 'react'; +import { type ComponentProps, useMemo } from 'react'; import { motion, type Variants } from 'framer-motion'; -interface Props extends ComponentProps {} +interface Props extends Omit, 'variants'> { + variants?: Variants | 'fadeIn' | 'fadeInUp'; +} + +function MotionDiv({ variants = 'fadeIn', ...props }: Props) { + const _variants: Variants = useMemo(() => { + switch (variants) { + case 'fadeIn': + return defaultFadeInVariants; + case 'fadeInUp': + return defaultFadeInUpVariants; + default: + return variants; + } + }, [variants]); -function MotionDiv(props: Props) { return ( Date: Mon, 29 Jan 2024 17:51:33 +0900 Subject: [PATCH 03/14] =?UTF-8?q?feat:=20result=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EB=AA=A8=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/result/page.tsx | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/app/result/page.tsx b/src/app/result/page.tsx index 779e73fb..29c35e85 100644 --- a/src/app/result/page.tsx +++ b/src/app/result/page.tsx @@ -5,6 +5,7 @@ import Character from '@/app/level/guide/Character'; import AppBarBottom from '@/components/AppBarBottom/AppBarBottom'; import Banner from '@/components/Banner/Banner'; import LinkButton from '@/components/Button/LinkButton'; +import MotionDiv from '@/components/Motion/MotionDiv'; import Tab from '@/components/Tab/Tab'; import { ROUTER } from '@/constants/router'; import { css } from '@/styled-system/css'; @@ -21,7 +22,7 @@ const TAB = [ ]; function ResultPage() { - const { data } = useGetMissionSummary(); + const { data, isLoading } = useGetMissionSummary(); const symbolStack = data?.symbolStack ?? 0; const currentLevel = getLevel(symbolStack); @@ -36,19 +37,30 @@ function ResultPage() { 레벨 안내
-
- -
- -
- - -
+ {isLoading ? ( +
+ ) : ( + <> + + + + + + + + + + )} ); From 0773e9607eb75e0eb38f797c7ec4291f498b50b4 Mon Sep 17 00:00:00 2001 From: sumi-0011 Date: Mon, 29 Jan 2024 23:47:58 +0900 Subject: [PATCH 04/14] =?UTF-8?q?refactor:=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EC=8A=A4=EC=BC=88=EB=A0=88=ED=86=A4=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/search/page.tsx | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/app/search/page.tsx b/src/app/search/page.tsx index e3bf3203..59d259c3 100644 --- a/src/app/search/page.tsx +++ b/src/app/search/page.tsx @@ -5,7 +5,6 @@ import Link from 'next/link'; import { useSuspenseGetSearchNickname } from '@/apis/member'; import FollowerItem from '@/components/ListItem/Follow/FollowerItem'; import FollowingItem from '@/components/ListItem/Follow/FollowingItem'; -import { ProfileItemSkeleton } from '@/components/ListItem/ProfileListItem'; import SearchBar from '@/components/SearchBar/SearchBar'; import { ROUTER } from '@/constants/router'; import { css } from '@/styled-system/css'; @@ -15,16 +14,7 @@ function SearchPage() { return ( <> - - - - - - - } - > + }> From 4e5e5190e20bebfc5ed1fefcbd85245af0e39283 Mon Sep 17 00:00:00 2001 From: wooBottle Date: Thu, 1 Feb 2024 02:37:16 +0900 Subject: [PATCH 05/14] =?UTF-8?q?=EB=94=94=EB=B0=94=EC=9D=B4=EC=8A=A4=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EA=B0=80=EC=A0=B8=EC=99=80=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=ED=95=B4=EC=A3=BC=EB=8A=94=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/auth.ts | 18 ++++++++++++++++++ src/app/auth/login/page.tsx | 38 +++++++++++++++++++++++++------------ 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/apis/auth.ts b/src/apis/auth.ts index 20857908..0da3f567 100644 --- a/src/apis/auth.ts +++ b/src/apis/auth.ts @@ -23,6 +23,10 @@ interface RegisterRequest { nickname: string; } +interface FcmTokenRequest { + fcmToken: string; +} + export const AUTH_APIS = { login: async (request: LoginRequest): Promise => { const { data } = await apiInstance.post(ROUTER.AUTH.LOGIN, { @@ -54,6 +58,13 @@ export const AUTH_APIS = { }); return data; }, + + fcmUpdate: async (request: FcmTokenRequest) => { + const { data } = await apiInstance.patch('/members/fcm-token', { + fcmToken: request.fcmToken, + }); + return data; + }, }; export const useTempRegister = (option?: UseMutationOptions) => { @@ -97,3 +108,10 @@ export const useNicknameRegister = (option?: UseMutationOptions) => { + return useMutation({ + mutationFn: AUTH_APIS.fcmUpdate, + ...option, + }); +}; diff --git a/src/app/auth/login/page.tsx b/src/app/auth/login/page.tsx index 89b9207a..87cfd00c 100644 --- a/src/app/auth/login/page.tsx +++ b/src/app/auth/login/page.tsx @@ -3,7 +3,7 @@ import { useEffect } from 'react'; import { useRouter } from 'next/navigation'; import Script from 'next/script'; -import { useSocialLogin } from '@/apis/auth'; +import { useSocialLogin, useUpdateMemberFcmToken } from '@/apis/auth'; import Button from '@/components/Button/Button'; import ButtonSocialLogin from '@/components/ButtonSocialLogin/ButtonSocialLogin'; import { AUTH_PROVIDER, WINDOW_CUSTOM_EVENT } from '@/constants/common'; @@ -30,7 +30,8 @@ const initAppleLogin = () => { export default function LoginPage() { const router = useRouter(); - const { mutateAsync } = useSocialLogin(); + const { mutateAsync: socialLoginAsyncMutate } = useSocialLogin(); + const { mutate: updateMemberFcmTokenMutate } = useUpdateMemberFcmToken(); const onClickGuest = () => { router.push(ROUTER.GUEST.MISSION.NEW); @@ -65,8 +66,8 @@ export default function LoginPage() { }; useEffect(() => { - const appleIdSignInOnSuccessHandler = (event: CustomEvent) => { - mutateAsync( + const webAppleIdSignInOnSuccessEventListener = (event: CustomEvent) => { + socialLoginAsyncMutate( { provider: AUTH_PROVIDER.APPLE, idToken: event.detail.authorization.id_token, @@ -79,8 +80,9 @@ export default function LoginPage() { ); }; - const handleEvent = (event: CustomEvent) => { - mutateAsync( + const nativeLoginCallbackEventListener = (event: CustomEvent) => { + updateMemberFcmTokenMutate({ fcmToken: event.detail.data.deviceToken }); + socialLoginAsyncMutate( { provider: event.detail.data.provider, idToken: event.detail.data.data, @@ -95,18 +97,30 @@ export default function LoginPage() { document.addEventListener( WINDOW_CUSTOM_EVENT.APPLE_ID_SIGN_IN_ON_SUCCESS, - appleIdSignInOnSuccessHandler as EventListener, + webAppleIdSignInOnSuccessEventListener as EventListener, + ); + document.addEventListener( + NATIVE_CUSTOM_EVENTS.APPLE_LOGIN_CALLBACK, + nativeLoginCallbackEventListener as EventListener, + ); + document.addEventListener( + NATIVE_CUSTOM_EVENTS.KAKAO_LOGIN_CALLBACK, + nativeLoginCallbackEventListener as EventListener, ); - document.addEventListener(NATIVE_CUSTOM_EVENTS.APPLE_LOGIN_CALLBACK, handleEvent as EventListener); - document.addEventListener(NATIVE_CUSTOM_EVENTS.KAKAO_LOGIN_CALLBACK, handleEvent as EventListener); return () => { document.removeEventListener( WINDOW_CUSTOM_EVENT.APPLE_ID_SIGN_IN_ON_SUCCESS, - appleIdSignInOnSuccessHandler as EventListener, + webAppleIdSignInOnSuccessEventListener as EventListener, + ); + document.removeEventListener( + NATIVE_CUSTOM_EVENTS.APPLE_LOGIN_CALLBACK, + nativeLoginCallbackEventListener as EventListener, + ); + document.removeEventListener( + NATIVE_CUSTOM_EVENTS.KAKAO_LOGIN_CALLBACK, + nativeLoginCallbackEventListener as EventListener, ); - document.removeEventListener(NATIVE_CUSTOM_EVENTS.APPLE_LOGIN_CALLBACK, handleEvent as EventListener); - document.removeEventListener(NATIVE_CUSTOM_EVENTS.KAKAO_LOGIN_CALLBACK, handleEvent as EventListener); }; }, []); From eff83b786b06f7605741aca8cdc1897163ba1221 Mon Sep 17 00:00:00 2001 From: wooBottle Date: Sun, 4 Feb 2024 17:18:41 +0900 Subject: [PATCH 06/14] =?UTF-8?q?:art:=20FcmToken=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/auth/login/page.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/auth/login/page.tsx b/src/app/auth/login/page.tsx index 87cfd00c..146c021b 100644 --- a/src/app/auth/login/page.tsx +++ b/src/app/auth/login/page.tsx @@ -81,7 +81,6 @@ export default function LoginPage() { }; const nativeLoginCallbackEventListener = (event: CustomEvent) => { - updateMemberFcmTokenMutate({ fcmToken: event.detail.data.deviceToken }); socialLoginAsyncMutate( { provider: event.detail.data.provider, @@ -89,6 +88,9 @@ export default function LoginPage() { }, { onSuccess: () => { + if (!!event.detail?.data?.deviceToken) { + updateMemberFcmTokenMutate({ fcmToken: event.detail.data.deviceToken }); + } router.push(ROUTER.HOME); }, }, From 83580c763a51bb59e329b29b7829e806a365f7f4 Mon Sep 17 00:00:00 2001 From: sumi-0011 Date: Sun, 4 Feb 2024 23:22:03 +0900 Subject: [PATCH 07/14] =?UTF-8?q?feat:=20=ED=99=94=EB=A9=B4=20=EB=B3=B4?= =?UTF-8?q?=EC=9D=B4=EA=B8=B0=20=EC=83=81=ED=83=9C=EA=B0=80=20=EB=B0=94?= =?UTF-8?q?=EB=80=94=EB=96=84=EB=8F=84=20=EA=B0=90=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mission/[id]/stopwatch/index.hooks.ts | 22 ++++++++++++-- src/hooks/mission/stopwatch/useStopwatch.ts | 29 +++++++++++++++---- src/utils/storage/progressMission.ts | 5 +++- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/app/mission/[id]/stopwatch/index.hooks.ts b/src/app/mission/[id]/stopwatch/index.hooks.ts index ad434eb6..f651e664 100644 --- a/src/app/mission/[id]/stopwatch/index.hooks.ts +++ b/src/app/mission/[id]/stopwatch/index.hooks.ts @@ -10,10 +10,10 @@ export function useUnloadAction(time: number, missionId: string) { setProgressMissionTime(missionId, time); }, [time]); - useVisibilityState(onSaveTime); + useVisibilityStateHidden(onSaveTime); } -function useVisibilityState(onAction: VoidFunction) { +function useVisibilityStateHidden(onAction: VoidFunction) { const onVisibilityChange = useCallback(() => { if (document.visibilityState === 'hidden') { onAction(); @@ -30,6 +30,24 @@ function useVisibilityState(onAction: VoidFunction) { }, [onVisibilityChange]); // 빈 의존성 배열을 전달하여 이 훅이 컴포넌트가 마운트되거나 언마운트될 때만 실행되도록 합니다. } +// visible 상태로 바뀔 때 실행되는 훅 +export function useVisibilityStateVisible(onAction: VoidFunction) { + const onVisibilityChange = useCallback(() => { + if (document.visibilityState === 'visible') { + onAction(); + } + }, [onAction]); + + useEffect(() => { + document.addEventListener('visibilitychange', onVisibilityChange); + + // 컴포넌트가 언마운트될 때 이벤트 리스너를 제거합니다. + return () => { + document.removeEventListener('visibilitychange', onVisibilityChange); + }; + }, [onVisibilityChange]); // 빈 의존성 배열을 전달하여 이 훅이 컴포넌트가 마운트되거나 언마운트될 때만 실행되도록 합니다. +} + export function useRecordMidTime(time: number, missionId: string) { const onSaveTime = () => { eventLogger.logEvent(EVENT_LOG_NAME.STOPWATCH.MID_SAVE_2, EVENT_LOG_CATEGORY.STOPWATCH, { time }); diff --git a/src/hooks/mission/stopwatch/useStopwatch.ts b/src/hooks/mission/stopwatch/useStopwatch.ts index 96705f62..7a1fe4c6 100644 --- a/src/hooks/mission/stopwatch/useStopwatch.ts +++ b/src/hooks/mission/stopwatch/useStopwatch.ts @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react'; +import { useVisibilityStateVisible } from '@/app/mission/[id]/stopwatch/index.hooks'; import { getProgressMissionTime } from '@/utils/storage/progressMission'; import { formatMMSS } from '@/utils/time'; @@ -36,14 +37,32 @@ export default function useStopwatch(status: StepType, missionId: string, onNext return () => clearInterval(timer); }, [second, status]); - useEffect(() => { - // 해당 미션을 이어 가는 경우. init time setting + const settingInitTime = () => { const initSeconds = getProgressMissionTime(missionId); - if (initSeconds && initSeconds < MAX_SECONDS) { + console.log('initSeconds: ', initSeconds); + + if (!initSeconds) return; + if (initSeconds >= MAX_SECONDS) { + setSecond(MAX_SECONDS); + // setIsFinished(true); + // return; + } else { setSecond(initSeconds); - // TODO : 구조 변경 필요 - onNextStep?.('progress'); // 바로 재시작 } + + onNextStep?.('progress'); // 바로 재시작 + }; + + // 화면 visible 상태로 변경 시, 시간을 다시 세팅 + useVisibilityStateVisible(() => { + setIsPending(true); + settingInitTime(); + setIsPending(false); + }); + + useEffect(() => { + // 해당 미션을 이어 가는 경우. init time setting + settingInitTime(); setIsPending(false); }, []); diff --git a/src/utils/storage/progressMission.ts b/src/utils/storage/progressMission.ts index 5cd4d0d5..d8e337c7 100644 --- a/src/utils/storage/progressMission.ts +++ b/src/utils/storage/progressMission.ts @@ -71,6 +71,9 @@ const getProgressMissionTimeToStack = (missionId: string) => { return progressTime; }; +const DEFAULT_MS = 1000; +const timerMs: number = Number(process.env.NEXT_PUBLIC_TIMER_MS ?? DEFAULT_MS); + export const getProgressMissionTime = (missionId: string): number => { if (!checkIsProgressMission(missionId)) return 0; // const progressTimeString = localStorage.getItem(STORAGE_KEY.PROGRESS_MISSION.TIME(missionId)); @@ -78,7 +81,7 @@ export const getProgressMissionTime = (missionId: string): number => { // TODO : 오늘 날짜에 진행되고 있던 미션인지 확인 const progressTimeMs = getProgressMissionTimeToStack(missionId); - const progressTime = Math.floor(progressTimeMs / 1000); + const progressTime = Math.floor(progressTimeMs / timerMs); if (!progressTime) return 0; From 15db94029d472ae91d7b3d3d5cd0e196c0ab38a9 Mon Sep 17 00:00:00 2001 From: sumi-0011 Date: Sun, 4 Feb 2024 23:46:24 +0900 Subject: [PATCH 08/14] =?UTF-8?q?feat:=20=EC=8A=A4=ED=86=B1=EC=9B=8C?= =?UTF-8?q?=EC=B9=98=20=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EB=B0=9C=EC=83=9D=20=EC=8B=9C=20=EC=8A=A4?= =?UTF-8?q?=EB=82=B5=EB=B0=94=20=EB=9D=84=EC=9A=B0=EA=B8=B0=20-=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=ED=95=84=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/mission/[id]/stopwatch/page.tsx | 10 +++++++- .../SnackBar/useServerErrorSnackBar.ts | 23 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/components/SnackBar/useServerErrorSnackBar.ts diff --git a/src/app/mission/[id]/stopwatch/page.tsx b/src/app/mission/[id]/stopwatch/page.tsx index fd423f3b..aa24d1bd 100644 --- a/src/app/mission/[id]/stopwatch/page.tsx +++ b/src/app/mission/[id]/stopwatch/page.tsx @@ -9,6 +9,7 @@ import { BackDialog, FinalDialog, MidOutDialog } from '@/app/mission/[id]/stopwa import Button from '@/components/Button/Button'; import Header from '@/components/Header/Header'; import Loading from '@/components/Loading'; +import useServerErrorSnackBar from '@/components/SnackBar/useServerErrorSnackBar'; import Stopwatch from '@/components/Stopwatch/Stopwatch'; import { EVENT_LOG_CATEGORY, EVENT_LOG_NAME } from '@/constants/eventLog'; import { MISSION_CATEGORY_LABEL } from '@/constants/mission'; @@ -69,6 +70,7 @@ export default function StopwatchPage() { useRecordMidTime(time, missionId); useUnloadAction(time, missionId); + const triggerServerErrorSnackBar = useServerErrorSnackBar(); // isError 처리 어떻게 할것인지? const { mutate, isPending: isSubmitLoading } = useRecordTime({ @@ -80,8 +82,14 @@ export default function StopwatchPage() { setIsMoveLoading(true); removeProgressMissionData(); }, - onError: () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + onError: (error: any) => { + triggerServerErrorSnackBar(error); setIsMoveLoading(() => false); // 없어도 되는지 확인 필요 + + if (error.response.data.data.errorClassName === 'MISSION_RECORD_ALREADY_EXISTS_TODAY') { + router.replace(ROUTER.HOME); + } }, }); diff --git a/src/components/SnackBar/useServerErrorSnackBar.ts b/src/components/SnackBar/useServerErrorSnackBar.ts new file mode 100644 index 00000000..23cdb486 --- /dev/null +++ b/src/components/SnackBar/useServerErrorSnackBar.ts @@ -0,0 +1,23 @@ +import { isSeverError } from '@/apis/instance.api'; +import { useSnackBar } from '@/components/SnackBar/SnackBarProvider'; + +// mutation을 통해 서버에 요청을 보낼 때 발생하는 에러를 처리하는 hook +// mutation을 래핑하기로 결정 +// option에 추가할지 useMutationWithSanckBar 등 새로운 hook을 만들지 고민 +function useServerErrorSnackBar() { + const { triggerSnackBar } = useSnackBar(); + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const triggerServerErrorSnackBar = (error: any) => { + if (isSeverError(error)) { + triggerSnackBar({ + message: error.response.data.data.message, + }); + return; + } + }; + + return triggerServerErrorSnackBar; +} + +export default useServerErrorSnackBar; From 159314696ebccf3260d96147291ee2e5411b328c Mon Sep 17 00:00:00 2001 From: sumi-0011 Date: Mon, 5 Feb 2024 15:49:11 +0900 Subject: [PATCH 09/14] =?UTF-8?q?feat:=20=EC=98=A4=EB=8A=98=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=EC=B2=B4=ED=81=AC=20=EB=B0=8F=20=EC=9D=B4=EC=A0=84?= =?UTF-8?q?=20=EB=AF=B8=EC=85=98=20=EC=83=81=ED=83=9C=EB=A1=9C=20=EC=84=B8?= =?UTF-8?q?=ED=8C=85=ED=95=98=EA=B8=B0,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/mission/stopwatch/useStopwatch.ts | 19 +++++++------ src/utils/storage/progressMission.ts | 31 +++++++++++++++++++-- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/hooks/mission/stopwatch/useStopwatch.ts b/src/hooks/mission/stopwatch/useStopwatch.ts index 7a1fe4c6..e4c14b0b 100644 --- a/src/hooks/mission/stopwatch/useStopwatch.ts +++ b/src/hooks/mission/stopwatch/useStopwatch.ts @@ -1,12 +1,12 @@ import { useEffect, useState } from 'react'; import { useVisibilityStateVisible } from '@/app/mission/[id]/stopwatch/index.hooks'; -import { getProgressMissionTime } from '@/utils/storage/progressMission'; +import { getPrevProgressMissionStatus, getProgressMissionTime } from '@/utils/storage/progressMission'; import { formatMMSS } from '@/utils/time'; import { type StepType } from './useStopwatchStatus'; const INIT_SECONDS = 0; -const MAX_SECONDS = 60 * 60; // max 1 hour +const MAX_SECONDS = 3600; // max 1 hour const DEFAULT_MS = 1000; const timerMs: number = Number(process.env.NEXT_PUBLIC_TIMER_MS ?? DEFAULT_MS); @@ -37,20 +37,17 @@ export default function useStopwatch(status: StepType, missionId: string, onNext return () => clearInterval(timer); }, [second, status]); + // init time setting 분리 const settingInitTime = () => { const initSeconds = getProgressMissionTime(missionId); - console.log('initSeconds: ', initSeconds); - if (!initSeconds) return; + if (!initSeconds) return false; if (initSeconds >= MAX_SECONDS) { setSecond(MAX_SECONDS); - // setIsFinished(true); - // return; } else { setSecond(initSeconds); } - - onNextStep?.('progress'); // 바로 재시작 + return true; }; // 화면 visible 상태로 변경 시, 시간을 다시 세팅 @@ -62,8 +59,12 @@ export default function useStopwatch(status: StepType, missionId: string, onNext useEffect(() => { // 해당 미션을 이어 가는 경우. init time setting - settingInitTime(); + const flag = settingInitTime(); setIsPending(false); + if (!flag) return; + + const prevStatus = getPrevProgressMissionStatus(missionId); + prevStatus && onNextStep?.(prevStatus); // 바로 재시작 }, []); return { minutes: formattedMinutes, seconds: formattedSeconds, stepper, isFinished, isPending }; diff --git a/src/utils/storage/progressMission.ts b/src/utils/storage/progressMission.ts index d8e337c7..7d82f8d9 100644 --- a/src/utils/storage/progressMission.ts +++ b/src/utils/storage/progressMission.ts @@ -75,10 +75,11 @@ const DEFAULT_MS = 1000; const timerMs: number = Number(process.env.NEXT_PUBLIC_TIMER_MS ?? DEFAULT_MS); export const getProgressMissionTime = (missionId: string): number => { + // 진행중인 미션이 없다면 if (!checkIsProgressMission(missionId)) return 0; - // const progressTimeString = localStorage.getItem(STORAGE_KEY.PROGRESS_MISSION.TIME(missionId)); - // TODO : 오늘 날짜에 진행되고 있던 미션인지 확인 + // 진행중인 미션이 있는 경우 + if (!checkTodayMission(missionId)) return 0; const progressTimeMs = getProgressMissionTimeToStack(missionId); const progressTime = Math.floor(progressTimeMs / timerMs); @@ -88,6 +89,17 @@ export const getProgressMissionTime = (missionId: string): number => { return progressTime; }; +export const getPrevProgressMissionStatus = (missionId: string): 'ready' | 'progress' | 'stop' | undefined => { + const timeStack = localStorage.getItem(STORAGE_KEY.PROGRESS_MISSION.TIME_STACK(missionId)) || '[]'; + const timeStackData = JSON.parse(timeStack); + + if (!timeStackData || timeStackData.length === 0) return 'ready'; + const status = timeStackData[timeStackData.length - 1].status; + + if (status === 'restart') return 'progress'; + if (status === 'stop') return 'stop'; +}; + export const checkIsExistProgressMission = (missionId: string) => { const progressMissionId = getProgressMissionIdToStorage(); if (!progressMissionId) return false; @@ -108,6 +120,21 @@ const checkIsProgressMission = (missionId: string) => { return true; }; +// 오늘 날짜에 진행되고 있던 미션인지 확인 +// return : true - 오늘 날짜에 진행되고 있던 미션 데이터, false - 오늘 날짜에 진행되고 있던 미션 데이터가 아니거나 없음 +const checkTodayMission = (missionId: string) => { + const mission = getProgressMissionStartTimeToStorage(missionId); + if (!mission) return false; + const missionDate = new Date(mission).getDate(); + const currentDate = new Date().getDate(); + + if (missionDate === currentDate) return true; + + // 오늘 날짜에 진행되고 있던 미션 데이터가 아님 -> 삭제 + removeProgressMissionData(); + return false; +}; + const getProgressMissionToStorage = (): MissionData | false => { const progressMissionData = localStorage.getItem(STORAGE_KEY.PROGRESS_MISSION.MISSION); if (!progressMissionData) return false; From 8ea4ee795ac6a97c27e6a30518717c75e2c92371 Mon Sep 17 00:00:00 2001 From: sumi-0011 Date: Mon, 5 Feb 2024 15:59:19 +0900 Subject: [PATCH 10/14] =?UTF-8?q?feat:=20useMutationHandleError=20?= =?UTF-8?q?=ED=9B=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/record.ts | 3 ++- src/app/mission/[id]/stopwatch/page.tsx | 6 +----- .../query/useMutationHandleError.ts} | 17 +++++++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) rename src/{components/SnackBar/useServerErrorSnackBar.ts => hooks/query/useMutationHandleError.ts} (50%) diff --git a/src/apis/record.ts b/src/apis/record.ts index aee641b1..5700a74b 100644 --- a/src/apis/record.ts +++ b/src/apis/record.ts @@ -1,6 +1,7 @@ import getQueryKey from '@/apis/getQueryKey'; import { type RecordType } from '@/apis/schema/record'; import { type UploadBaseRequest } from '@/apis/schema/upload'; +import useMutationHandleError from '@/hooks/query/useMutationHandleError'; import { useMutation, type UseMutationOptions, @@ -109,7 +110,7 @@ export const useGetRecordDetail = (recordId: string, option?: UseQueryOptions) => - useMutation({ mutationFn: RECORD_API.recordTime, ...options }); + useMutationHandleError({ mutationFn: RECORD_API.recordTime, ...options }); export const useUpdateRemarkMutation = ( recordId: string, diff --git a/src/app/mission/[id]/stopwatch/page.tsx b/src/app/mission/[id]/stopwatch/page.tsx index aa24d1bd..74bab220 100644 --- a/src/app/mission/[id]/stopwatch/page.tsx +++ b/src/app/mission/[id]/stopwatch/page.tsx @@ -9,7 +9,6 @@ import { BackDialog, FinalDialog, MidOutDialog } from '@/app/mission/[id]/stopwa import Button from '@/components/Button/Button'; import Header from '@/components/Header/Header'; import Loading from '@/components/Loading'; -import useServerErrorSnackBar from '@/components/SnackBar/useServerErrorSnackBar'; import Stopwatch from '@/components/Stopwatch/Stopwatch'; import { EVENT_LOG_CATEGORY, EVENT_LOG_NAME } from '@/constants/eventLog'; import { MISSION_CATEGORY_LABEL } from '@/constants/mission'; @@ -70,7 +69,6 @@ export default function StopwatchPage() { useRecordMidTime(time, missionId); useUnloadAction(time, missionId); - const triggerServerErrorSnackBar = useServerErrorSnackBar(); // isError 처리 어떻게 할것인지? const { mutate, isPending: isSubmitLoading } = useRecordTime({ @@ -84,10 +82,8 @@ export default function StopwatchPage() { }, // eslint-disable-next-line @typescript-eslint/no-explicit-any onError: (error: any) => { - triggerServerErrorSnackBar(error); - setIsMoveLoading(() => false); // 없어도 되는지 확인 필요 - if (error.response.data.data.errorClassName === 'MISSION_RECORD_ALREADY_EXISTS_TODAY') { + removeProgressMissionData(); router.replace(ROUTER.HOME); } }, diff --git a/src/components/SnackBar/useServerErrorSnackBar.ts b/src/hooks/query/useMutationHandleError.ts similarity index 50% rename from src/components/SnackBar/useServerErrorSnackBar.ts rename to src/hooks/query/useMutationHandleError.ts index 23cdb486..135c54af 100644 --- a/src/components/SnackBar/useServerErrorSnackBar.ts +++ b/src/hooks/query/useMutationHandleError.ts @@ -1,10 +1,8 @@ import { isSeverError } from '@/apis/instance.api'; import { useSnackBar } from '@/components/SnackBar/SnackBarProvider'; +import { useMutation, type UseMutationOptions } from '@tanstack/react-query'; -// mutation을 통해 서버에 요청을 보낼 때 발생하는 에러를 처리하는 hook -// mutation을 래핑하기로 결정 -// option에 추가할지 useMutationWithSanckBar 등 새로운 hook을 만들지 고민 -function useServerErrorSnackBar() { +function useMutationHandleError(options?: UseMutationOptions) { const { triggerSnackBar } = useSnackBar(); // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -12,12 +10,19 @@ function useServerErrorSnackBar() { if (isSeverError(error)) { triggerSnackBar({ message: error.response.data.data.message, + offset: 'cta', }); return; } }; - return triggerServerErrorSnackBar; + return useMutation({ + ...options, + onError: (error, variables, context) => { + triggerServerErrorSnackBar(error); + options?.onError?.(error, variables, context); + }, + }); } -export default useServerErrorSnackBar; +export default useMutationHandleError; From 071152642d0e53481b1bd277a3b77b616279cf9b Mon Sep 17 00:00:00 2001 From: sumi-0011 Date: Mon, 5 Feb 2024 16:02:10 +0900 Subject: [PATCH 11/14] =?UTF-8?q?feat:=20snack=20bar=20=EC=9C=84=EC=B9=98?= =?UTF-8?q?=20=EC=A1=B0=EC=A0=95=20=EA=B0=80=EB=8A=A5=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/record.ts | 7 ++++++- src/hooks/query/useMutationHandleError.ts | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/apis/record.ts b/src/apis/record.ts index 5700a74b..339eef3b 100644 --- a/src/apis/record.ts +++ b/src/apis/record.ts @@ -110,7 +110,12 @@ export const useGetRecordDetail = (recordId: string, option?: UseQueryOptions) => - useMutationHandleError({ mutationFn: RECORD_API.recordTime, ...options }); + useMutationHandleError( + { mutationFn: RECORD_API.recordTime, ...options }, + { + offset: 'appBar', + }, + ); export const useUpdateRemarkMutation = ( recordId: string, diff --git a/src/hooks/query/useMutationHandleError.ts b/src/hooks/query/useMutationHandleError.ts index 135c54af..adf90504 100644 --- a/src/hooks/query/useMutationHandleError.ts +++ b/src/hooks/query/useMutationHandleError.ts @@ -2,7 +2,14 @@ import { isSeverError } from '@/apis/instance.api'; import { useSnackBar } from '@/components/SnackBar/SnackBarProvider'; import { useMutation, type UseMutationOptions } from '@tanstack/react-query'; -function useMutationHandleError(options?: UseMutationOptions) { +interface SnackBarOptions { + offset?: 'appBar' | 'default' | 'cta'; +} + +function useMutationHandleError( + options?: UseMutationOptions, + snackBarOptions?: SnackBarOptions, +) { const { triggerSnackBar } = useSnackBar(); // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -11,6 +18,7 @@ function useMutationHandleError(options?: UseMutationOptions Date: Tue, 6 Feb 2024 00:14:16 +0900 Subject: [PATCH 12/14] =?UTF-8?q?review:=20=EB=8F=99=EB=AF=BC=EC=98=A4?= =?UTF-8?q?=EB=B9=A0=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/record.ts | 2 +- src/app/mission/[id]/stopwatch/page.tsx | 11 +++++++---- src/components/SnackBar/SnackBar.types.ts | 5 ++++- src/hooks/query/useMutationHandleError.ts | 8 +++----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/apis/record.ts b/src/apis/record.ts index 4e55cc4f..a39cacc5 100644 --- a/src/apis/record.ts +++ b/src/apis/record.ts @@ -1,6 +1,6 @@ import getQueryKey from '@/apis/getQueryKey'; import { type RecordType } from '@/apis/schema/record'; -import { type UploadBaseRequest } from '@/apis/schema/upload'; +import { type ImageFileExtensionType, type UploadBaseRequest } from '@/apis/schema/upload'; import useMutationHandleError from '@/hooks/query/useMutationHandleError'; import { useMutation, diff --git a/src/app/mission/[id]/stopwatch/page.tsx b/src/app/mission/[id]/stopwatch/page.tsx index 74bab220..30054bb2 100644 --- a/src/app/mission/[id]/stopwatch/page.tsx +++ b/src/app/mission/[id]/stopwatch/page.tsx @@ -2,6 +2,7 @@ import { Fragment, useEffect, useState } from 'react'; import { useParams, useRouter } from 'next/navigation'; +import { isSeverError } from '@/apis/instance.api'; import { useGetMissionDetailNoSuspense } from '@/apis/mission'; import { useRecordTime } from '@/apis/record'; import { useCustomBack, useRecordMidTime, useUnloadAction } from '@/app/mission/[id]/stopwatch/index.hooks'; @@ -81,10 +82,12 @@ export default function StopwatchPage() { removeProgressMissionData(); }, // eslint-disable-next-line @typescript-eslint/no-explicit-any - onError: (error: any) => { - if (error.response.data.data.errorClassName === 'MISSION_RECORD_ALREADY_EXISTS_TODAY') { - removeProgressMissionData(); - router.replace(ROUTER.HOME); + onError: (error) => { + if (isSeverError(error)) { + if (error.response.data.data.errorClassName === 'MISSION_RECORD_ALREADY_EXISTS_TODAY') { + removeProgressMissionData(); + router.replace(ROUTER.HOME); + } } }, }); diff --git a/src/components/SnackBar/SnackBar.types.ts b/src/components/SnackBar/SnackBar.types.ts index b36be535..2987e101 100644 --- a/src/components/SnackBar/SnackBar.types.ts +++ b/src/components/SnackBar/SnackBar.types.ts @@ -1,14 +1,17 @@ import { type IconComponentMap } from '@/components/Icon'; +export type SnackBarOffset = 'appBar' | 'default' | 'cta'; + export interface SnackBarBaseType { message: string; - offset?: 'appBar' | 'default' | 'cta'; + offset?: SnackBarOffset; id: string; } export interface SnackBarNoneType extends SnackBarBaseType { variant?: 'none'; } + export interface SnackBarIconType extends SnackBarBaseType { variant: 'icon'; iconName: keyof typeof IconComponentMap; diff --git a/src/hooks/query/useMutationHandleError.ts b/src/hooks/query/useMutationHandleError.ts index adf90504..6b338b5d 100644 --- a/src/hooks/query/useMutationHandleError.ts +++ b/src/hooks/query/useMutationHandleError.ts @@ -1,10 +1,9 @@ import { isSeverError } from '@/apis/instance.api'; +import { type SnackBarBaseType } from '@/components/SnackBar/SnackBar.types'; import { useSnackBar } from '@/components/SnackBar/SnackBarProvider'; import { useMutation, type UseMutationOptions } from '@tanstack/react-query'; -interface SnackBarOptions { - offset?: 'appBar' | 'default' | 'cta'; -} +type SnackBarOptions = Pick; function useMutationHandleError( options?: UseMutationOptions, @@ -12,8 +11,7 @@ function useMutationHandleError( ) { const { triggerSnackBar } = useSnackBar(); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const triggerServerErrorSnackBar = (error: any) => { + const triggerServerErrorSnackBar = (error: unknown) => { if (isSeverError(error)) { triggerSnackBar({ message: error.response.data.data.message, From e5b442b99e705e63b618337c83784f820ece0dc6 Mon Sep 17 00:00:00 2001 From: sumi-0011 Date: Tue, 6 Feb 2024 00:37:09 +0900 Subject: [PATCH 13/14] refactor: build error fix --- src/app/search/page.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/search/page.tsx b/src/app/search/page.tsx index f249d9f3..01b44bff 100644 --- a/src/app/search/page.tsx +++ b/src/app/search/page.tsx @@ -11,7 +11,6 @@ import { css } from '@/styled-system/css'; function SearchPage() { const [input, setInput] = useState(''); - const filteredInput = input.trim(); return ( <> From 5192dfc4d77571d024abedad20b59e29871b1164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=EC=9A=B0=EB=B3=91?= Date: Tue, 6 Feb 2024 02:00:50 +0900 Subject: [PATCH 14/14] =?UTF-8?q?Revert=20"[Hofix]=20=EC=84=9C=EB=B2=84?= =?UTF-8?q?=EC=97=90=EC=84=9C=20401=20error=EA=B0=80=20=EB=9C=A8=EB=A9=B4?= =?UTF-8?q?=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EB=A1=9C=20=EB=9D=BC=EC=9A=B0=ED=8C=85=ED=95=A9=EB=8B=88?= =?UTF-8?q?=EB=8B=A4."?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/instance.api.ts | 8 ++------ src/app/error.tsx | 12 +++--------- src/app/template.tsx | 1 - src/hooks/useAuth.ts | 5 ----- src/utils/appEnv.ts | 2 -- 5 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/apis/instance.api.ts b/src/apis/instance.api.ts index 16efbf3e..200a3003 100644 --- a/src/apis/instance.api.ts +++ b/src/apis/instance.api.ts @@ -1,6 +1,4 @@ -import { ROUTER } from '@/constants/router'; import { getTokens } from '@/services/auth/actions'; -import { isLocal } from '@/utils/appEnv'; import axios, { type AxiosError, type AxiosInstance, type AxiosResponse } from 'axios'; export const BASE_URL = process.env.NEXT_PUBLIC_SEVER_API; @@ -9,9 +7,6 @@ const BASE_TIMEOUT = 10000; const setInterceptors = (instance: AxiosInstance) => { instance.interceptors.request.use( async (config) => { - if (!isLocal()) { - return config; - } const { accessToken, refreshToken } = await getTokens(); if (accessToken) { config.headers.Authorization = `Bearer ${accessToken}`; @@ -33,7 +28,8 @@ const setInterceptors = (instance: AxiosInstance) => { (error) => { if (axios.isAxiosError(error)) { if (error.response?.status === 401) { - window.location.href = ROUTER.AUTH.LOGIN; + //TODO : refresh token + console.log('refresh token'); } } return Promise.reject(error); diff --git a/src/app/error.tsx b/src/app/error.tsx index a4527b04..ff4d3331 100644 --- a/src/app/error.tsx +++ b/src/app/error.tsx @@ -2,22 +2,16 @@ import { useEffect } from 'react'; import Image from 'next/image'; -import { useRouter } from 'next/navigation'; -import { isSeverError } from '@/apis/instance.api'; -import { ROUTER } from '@/constants/router'; import { css } from '@/styled-system/css'; export default function Error({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) { const onClickResetButton = () => reset(); - const router = useRouter(); + useEffect(() => { - if (isSeverError(error)) { - if (error.response.status === 401) { - router.push(ROUTER.AUTH.LOGIN); - } - } + // TODO: ga로 쏘거나 하는 등의 플로우는 필요없을지 하는 생각 console.error(error); }, [error]); + return (
diff --git a/src/app/template.tsx b/src/app/template.tsx index 940fc10f..333c9b9f 100644 --- a/src/app/template.tsx +++ b/src/app/template.tsx @@ -11,7 +11,6 @@ import { useAuth } from '@/hooks/useAuth'; export default function Template({ children }: { children: React.ReactNode }) { useAuth(); - // const [customMotion, setCustomMotion] = useState(true); // useEffect(() => { diff --git a/src/hooks/useAuth.ts b/src/hooks/useAuth.ts index 4a9a6672..1c60c1dc 100644 --- a/src/hooks/useAuth.ts +++ b/src/hooks/useAuth.ts @@ -1,7 +1,6 @@ import { useEffect } from 'react'; import { usePathname, useRouter } from 'next/navigation'; import { ROUTER } from '@/constants/router'; -import { isLocal } from '@/utils/appEnv'; const ALLOW_PATH_LIST = [ ROUTER.AUTH.LOGIN, @@ -23,10 +22,6 @@ export function useAuth() { const pathname = usePathname(); useEffect(() => { - if (!isLocal()) { - return; - } - const token = localStorage.getItem('accessToken') ?? process.env.NEXT_PUBLIC_ACCESS_TOKEN; if (!token && !ALLOW_PATH_LIST.includes(pathname)) { diff --git a/src/utils/appEnv.ts b/src/utils/appEnv.ts index af2b4c94..85cb1c0c 100644 --- a/src/utils/appEnv.ts +++ b/src/utils/appEnv.ts @@ -11,5 +11,3 @@ const getUserAgent = () => { export const isWebView = () => RegExp(APP_USER_AGENT).test(getUserAgent()); export const isAndroid = () => RegExp(ANDROID).test(getUserAgent()); export const isIOS = () => RegExp(IOS).test(getUserAgent()); - -export const isLocal = () => process.env.NODE_ENV === 'development';