Skip to content

Commit

Permalink
feat: 로그인 후 원래 경로로 리다이렉션 구현 (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonddori authored Jul 20, 2024
1 parent 3675419 commit 3d94375
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/app/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<ThemeProvider theme={theme}>
<CssBaseline />
Expand Down
22 changes: 22 additions & 0 deletions src/hooks/useCurrentPath.ts
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 3d94375

Please sign in to comment.