diff --git a/src/components/_main/profile/edit/accountGeneral.jsx b/src/components/_main/profile/edit/accountGeneral.jsx index 052ccaa..4652541 100644 --- a/src/components/_main/profile/edit/accountGeneral.jsx +++ b/src/components/_main/profile/edit/accountGeneral.jsx @@ -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 (
@@ -409,6 +443,9 @@ export default function AccountGeneral() {
+ + +
); } diff --git a/src/services/index.js b/src/services/index.js index 0b4716c..6a4e81f 100644 --- a/src/services/index.js +++ b/src/services/index.js @@ -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;