업데이트
This commit is contained in:
parent
faf98ce6a5
commit
0b0a60940f
@ -9,7 +9,7 @@ import { useRouter } from 'next-nprogress-bar';
|
|||||||
// icons
|
// icons
|
||||||
import { MdVerified } from 'react-icons/md';
|
import { MdVerified } from 'react-icons/md';
|
||||||
// mui
|
// 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';
|
import { LoadingButton } from '@mui/lab';
|
||||||
// component
|
// component
|
||||||
import UploadAvatar from 'src/components/upload/UploadAvatar';
|
import UploadAvatar from 'src/components/upload/UploadAvatar';
|
||||||
@ -26,6 +26,23 @@ import axios from 'axios';
|
|||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { setLogin } from 'src/redux/slices/user';
|
import { setLogin } from 'src/redux/slices/user';
|
||||||
import { useSelector } from 'react-redux';
|
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() {
|
export default function AccountGeneral() {
|
||||||
const { user: adminUser } = useSelector(({ user }) => user);
|
const { user: adminUser } = useSelector(({ user }) => user);
|
||||||
@ -174,6 +191,23 @@ export default function AccountGeneral() {
|
|||||||
ResendOTPMutate({ email: user.email });
|
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 (
|
return (
|
||||||
<FormikProvider value={formik}>
|
<FormikProvider value={formik}>
|
||||||
<Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
<Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
||||||
@ -409,6 +443,9 @@ export default function AccountGeneral() {
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Form>
|
</Form>
|
||||||
|
<Stack sx={{display:'flex', justifyContent:'center'}}>
|
||||||
|
<Button onClick={signOut}>탈퇴하기</Button>
|
||||||
|
</Stack>
|
||||||
</FormikProvider>
|
</FormikProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -411,6 +411,13 @@ export const updateProfile = async ({ ...payload }) => {
|
|||||||
const { data } = await http.put(`/users/profile`, payload);
|
const { data } = await http.put(`/users/profile`, payload);
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const verifiedFalse = async ({ ...payload }) => {
|
||||||
|
const { data } = await http.put(`/users/verifiedFalse`, payload);
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
export const changePassword = async ({ ...payload }) => {
|
export const changePassword = async ({ ...payload }) => {
|
||||||
const { data } = await http.put(`/users/change-password`, payload);
|
const { data } = await http.put(`/users/change-password`, payload);
|
||||||
return data;
|
return data;
|
||||||
|
Loading…
Reference in New Issue
Block a user