Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'use client';

import { RouterProvider } from 'react-router-dom';

import { router } from '@/routes/router';
import { refreshAuthAtom } from '@/store/auth';
import { useSetAtom } from 'jotai';
import { useEffect } from 'react';
import { RouterProvider } from 'react-router-dom';

export const App = () => {
const refreshAuth = useSetAtom(refreshAuthAtom);
Expand All @@ -13,4 +15,4 @@ export const App = () => {
}, []);

return <RouterProvider router={router} />;
};
};
3 changes: 1 addition & 2 deletions src/api/apiInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ apiInstance.interceptors.response.use(
})
.catch((reissueError: AxiosError) => {
processQueue(reissueError);
navigate(PATH.LOGIN);
// navigate(PATH.LOGIN);

console.error('reissue error', reissueError);
return Promise.reject(reissueError);
Expand All @@ -128,7 +128,6 @@ apiInstance.interceptors.response.use(

// 리프레시 토큰이 만료됨
// sessionStorage.removeItem('Authorization');
navigate(PATH.LOGIN);
return Promise.reject(error);
}
}
Expand Down
16 changes: 4 additions & 12 deletions src/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,10 @@ export const createProfile = async ({
memberExplain,
image,
}: ProfileMutationArgs) => {
const formData = new FormData();

formData.append('memberName', memberName);
formData.append('memberExplain', memberExplain);
if (image) {
formData.append('image', image);
}

const res = await apiInstance.post('v1/members', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
const res = await apiInstance.post('v1/members', {
memberName,
memberExplain,
image,
});

return res.data;
Expand Down
10 changes: 4 additions & 6 deletions src/routes/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@

const useAuth = () => {
const [isLoggedIn] = useAtom(isLoggedInAtom);
console.log('useAuth isLoggedIn', isLoggedIn);
// if (isDevMode()) {
// return {
// isAuthenticated: true,
// };
// }
console.log('isLoggedIn', isLoggedIn);
return {
isAuthenticated: isLoggedIn,
};
};

const PrivateRoute = ({ children }: { children: React.ReactNode }) => {

Check warning on line 44 in src/routes/router.tsx

View workflow job for this annotation

GitHub Actions / ci

Fast refresh only works when a file only exports components. Move your component(s) to a separate file

Check warning on line 44 in src/routes/router.tsx

View workflow job for this annotation

GitHub Actions / deploy

Fast refresh only works when a file only exports components. Move your component(s) to a separate file
const { isAuthenticated } = useAuth();
const location = useLocation();

Expand Down Expand Up @@ -113,11 +113,9 @@
{
path: PATH.ENROLL,
element: (
<PrivateRoute>
<Suspense fallback={<LazySkeleton />}>
<LazyEnrollTemplate />
</Suspense>
</PrivateRoute>
<Suspense fallback={<LazySkeleton />}>
<LazyEnrollTemplate />
</Suspense>
),
},
{
Expand Down
7 changes: 5 additions & 2 deletions src/templates/User/EnrollSubmitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { useLocation, useNavigate } from 'react-router-dom';

import { createProfile } from '@/api/user';
import { PATH } from '@/routes/path';
import { isSubmittedAtom } from '@/store/form';
import { refreshAuthAtom } from '@/store/auth';
import {
formTextInputAtom,
formTextareaAtom,
imageAtom,
isEnrollSatisfiedAtom,
isSubmittedAtom,
} from '@/store/form';
import { alertAtom } from '@/store/modal';
import { useAtomValue, useSetAtom } from 'jotai';
Expand All @@ -23,16 +24,18 @@ export const EnrollSubmitButton = () => {
const location = useLocation();
const setAlert = useSetAtom(alertAtom);
const setIsSubmitted = useSetAtom(isSubmittedAtom);
const refreshAuth = useSetAtom(refreshAuthAtom);

const onClick = () => {
createProfile({
memberName: memberName,
memberExplain: memberExplain,
image: image,
})
.then(() => {
.then(async () => {
// const previousPath = location.state?.redirect ?? PATH.TEAMS;
// navigate(previousPath);
await refreshAuth();
setIsSubmitted(true);

const navigatePath = location.state?.redirect
Expand Down