업데이트

This commit is contained in:
익희 김 2025-01-02 15:14:58 +09:00
parent faf98ce6a5
commit 0b0a60940f
2 changed files with 45 additions and 1 deletions

View File

@ -9,7 +9,7 @@ import { useRouter } from 'next-nprogress-bar';
// icons
import { MdVerified } from 'react-icons/md';
// mui
import { Box, Grid, Card, Stack, TextField, Typography, FormHelperText, Skeleton } from '@mui/material';
import { Box, Grid, Card, Stack, TextField, Typography, FormHelperText, Skeleton, Button } from '@mui/material';
import { LoadingButton } from '@mui/lab';
// component
import UploadAvatar from 'src/components/upload/UploadAvatar';
@ -26,6 +26,23 @@ import axios from 'axios';
import { useDispatch } from 'react-redux';
import { setLogin } from 'src/redux/slices/user';
import { useSelector } from 'react-redux';
import { deleteCookies } from 'src/hooks/cookies';
import { setLogout } from 'src/redux/slices/user';
import { resetWishlist } from 'src/redux/slices/wishlist';
const updateIsVerified = async (isVerified) => {
try {
const response = await api.updateProfile({ isVerified:false });
if (response.success) {
console.log('User isVerified updated successfully:', response.data);
} else {
console.error('Failed to update isVerified:', response.message);
}
} catch (error) {
console.error('Error while updating isVerified:', error.message);
}
};
export default function AccountGeneral() {
const { user: adminUser } = useSelector(({ user }) => user);
@ -174,6 +191,23 @@ export default function AccountGeneral() {
ResendOTPMutate({ email: user.email });
};
const signOut = async () => {
const signOutConfirm = confirm('UIE 서비스를 탈퇴하시겠습니까?');
console.log(signOutConfirm)
if (signOutConfirm === true) {
updateIsVerified(true)
.then(() => {
alert('탈퇴 되었습니다.')
deleteCookies('token');
dispatch(setLogout());
dispatch(resetWishlist());
router.push('/');
})
.catch((err) => console.error('Update failed', err));
}
};
return (
<FormikProvider value={formik}>
<Form autoComplete="off" noValidate onSubmit={handleSubmit}>
@ -409,6 +443,9 @@ export default function AccountGeneral() {
</Grid>
</Grid>
</Form>
<Stack sx={{display:'flex', justifyContent:'center'}}>
<Button onClick={signOut}>탈퇴하기</Button>
</Stack>
</FormikProvider>
);
}

View File

@ -411,6 +411,13 @@ export const updateProfile = async ({ ...payload }) => {
const { data } = await http.put(`/users/profile`, payload);
return data;
};
export const verifiedFalse = async ({ ...payload }) => {
const { data } = await http.put(`/users/verifiedFalse`, payload);
return data;
};
export const changePassword = async ({ ...payload }) => {
const { data } = await http.put(`/users/change-password`, payload);
return data;