From 3d9437591064cb167343963e7b7c7a00d6b66b16 Mon Sep 17 00:00:00 2001 From: yeonddori <126975394+yeonddori@users.noreply.github.com> Date: Sun, 21 Jul 2024 06:21:57 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=9B=84?= =?UTF-8?q?=20=EC=9B=90=EB=9E=98=20=EA=B2=BD=EB=A1=9C=EB=A1=9C=20=EB=A6=AC?= =?UTF-8?q?=EB=8B=A4=EC=9D=B4=EB=A0=89=EC=85=98=20=EA=B5=AC=ED=98=84=20(#1?= =?UTF-8?q?05)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #103 --- src/app/Providers.tsx | 3 +++ src/hooks/useCurrentPath.ts | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/hooks/useCurrentPath.ts diff --git a/src/app/Providers.tsx b/src/app/Providers.tsx index 8fff1eb..dc46845 100644 --- a/src/app/Providers.tsx +++ b/src/app/Providers.tsx @@ -4,10 +4,13 @@ import { CssBaseline, ThemeProvider } from '@mui/material'; import { createStore, Provider } from 'jotai'; import theme from '@/constants/theme'; +import useCurrentPath from '@/hooks/useCurrentPath'; const store = createStore(); const Providers = ({ children }: { children: React.ReactNode }) => { + useCurrentPath(); + return ( diff --git a/src/hooks/useCurrentPath.ts b/src/hooks/useCurrentPath.ts new file mode 100644 index 0000000..15b20df --- /dev/null +++ b/src/hooks/useCurrentPath.ts @@ -0,0 +1,22 @@ +'use client'; + +import { useEffect } from 'react'; + +import { useSetAtom } from 'jotai'; + +import { loginBackPathAtom } from '@/state/atom'; + +const useCurrentPath = () => { + const setCurrentPath = useSetAtom(loginBackPathAtom); + + useEffect(() => { + const excludedPaths = ['/login/oauth2/code/kakao']; + if (excludedPaths.includes(window.location.pathname)) { + return; + } + + setCurrentPath(window.location.pathname); + }, [setCurrentPath]); +}; + +export default useCurrentPath;