Skip to content

Commit 7eb4032

Browse files
committed
✨ feat:접근 권한 toast 추가
Issue Resolved: #
1 parent 1325f9d commit 7eb4032

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

front/src/components/Navbar/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export default function Navbar() {
3838
toast.warning('예매내역이 삭제되었습니다.');
3939
return queryClient.refetchQueries({ queryKey: ['reservation'] });
4040
},
41+
onError: () => {
42+
toast.error('예매내역 삭제에 실패했습니다.\n 잠시 후 다시 시도해주세요');
43+
},
4144
});
4245

4346
const deletingReservationIdList = useMutationState({
@@ -47,9 +50,9 @@ export default function Navbar() {
4750

4851
const { mutate: requestLogout } = useMutation({
4952
mutationFn: postLogout,
50-
onError: () => {},
5153
onSuccess: () => {
5254
if (logout) logout();
55+
toast.warning('로그아웃 되었습니다');
5356
},
5457
});
5558

front/src/components/loaders/WithLogin.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ import { Navigate } from 'react-router-dom';
33

44
import { useAuthContext } from '@/hooks/useAuthContext.tsx';
55

6+
import { toast } from '@/components/Toast/index.ts';
7+
68
import { ROUTE_URL } from '@/constants/index.ts';
79

810
//TODO toast 알림 추가 필ㄹ요
911
export default function WithLogin({ children }: PropsWithChildren) {
1012
const { isLogin } = useAuthContext();
11-
if (!isLogin) return <Navigate to={ROUTE_URL.USER.LOGIN} />;
13+
if (!isLogin) {
14+
toast.warning('로그인이 필요한 서비스입니다.\n로그인 후 이용해주세요.');
15+
return <Navigate to={ROUTE_URL.USER.LOGIN} />;
16+
}
1217
return <>{children}</>;
1318
}

front/src/components/loaders/WithoutLogin.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ import { Navigate } from 'react-router-dom';
33

44
import { useAuthContext } from '@/hooks/useAuthContext.tsx';
55

6+
import { toast } from '@/components/Toast/index.ts';
7+
68
import { ROUTE_URL } from '@/constants/index.ts';
79

810
export default function WithoutLogin({ children }: PropsWithChildren) {
911
const { isLogin } = useAuthContext();
10-
if (isLogin) return <Navigate to={ROUTE_URL.PROGRAM.DEFAULT} />;
12+
if (isLogin) {
13+
toast.warning('로그인 후 접근할 수 없습니다.\n로그 아웃 후 이용해주세요.');
14+
return <Navigate to={ROUTE_URL.PROGRAM.DEFAULT} />;
15+
}
1116
return <>{children}</>;
1217
}

0 commit comments

Comments
 (0)