Skip to content

Commit

Permalink
feat: 로그아웃 기능 추가 (#298)
Browse files Browse the repository at this point in the history
* feat(volunteer): 로그아웃 기능 추가

* feat(shelter): 로그아웃 추가
  • Loading branch information
DongjaJ authored Dec 2, 2023
1 parent 1f23d62 commit 0b1f9d5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
17 changes: 15 additions & 2 deletions apps/shelter/src/pages/my/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { Box, Divider, Switch, VStack } from '@chakra-ui/react';
import { Box, Divider, Switch, useToast, VStack } from '@chakra-ui/react';
import { useNavigate } from 'react-router-dom';
import InfoItem from 'shared/components/InfoItem';
import InfoList from 'shared/components/InfoList';
import InfoTextItem from 'shared/components/InfoTextItem';
import ProfileInfo from 'shared/components/ProfileInfo';
import SettingGroup from 'shared/components/SettingGroup';
import APP_TYPE from 'shared/constants/appType';
import useAuthStore from 'shared/store/authStore';
import { removeItemFromStorage } from 'shared/utils/localStorage';

import { useMyPage } from '@/pages/my/_hooks/useMyPage';

export default function MyPage() {
const navigate = useNavigate();
const { setUser } = useAuthStore();
const { shelterProfile, isAddressPublic, updateAddressStatus } = useMyPage();
const toast = useToast();

if (!shelterProfile) {
return null;
Expand All @@ -23,7 +28,15 @@ export default function MyPage() {
const goSettingsAccount = () => navigate('/settings/account');
const goSettingsPassword = () => navigate('/settings/password');
const logout = () => {
// TODO: 로그아웃
setUser(null);
removeItemFromStorage(APP_TYPE.SHELTER_APP);
navigate('/signin');
toast({
position: 'top',
description: '로그아웃 되었습니다.',
status: 'success',
duration: 1500,
});
};

return (
Expand Down
17 changes: 15 additions & 2 deletions apps/volunteer/src/pages/settings/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import { Box, VStack } from '@chakra-ui/react';
import { Box, useToast, VStack } from '@chakra-ui/react';
import { useNavigate } from 'react-router-dom';
import SettingGroup from 'shared/components/SettingGroup';
import APP_TYPE from 'shared/constants/appType';
import useAuthStore from 'shared/store/authStore';
import { removeItemFromStorage } from 'shared/utils/localStorage';

export default function SettingsPage() {
const navigate = useNavigate();
const goSettingsAccount = () => navigate('/settings/account');
const goSettingsPassword = () => navigate('/settings/password');
const { setUser } = useAuthStore();
const toast = useToast();
const logout = () => {
// TODO: 로그아웃
setUser(null);
removeItemFromStorage(APP_TYPE.VOLUNTEER_APP);
navigate('/volunteers');
toast({
position: 'top',
description: '로그아웃 되었습니다.',
status: 'success',
duration: 1500,
});
};

return (
Expand Down

0 comments on commit 0b1f9d5

Please sign in to comment.