Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 로그아웃 기능 추가 #298

Merged
merged 2 commits into from
Dec 2, 2023
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
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