mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-13 08:13:49 +10:00
[Feature] Implement Self-Serve Account Deletion
This commit is contained in:
@ -2,7 +2,7 @@ import { User } from '@reactive-resume/schema';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import toast from 'react-hot-toast';
|
||||
|
||||
import { setAccessToken, setUser } from '@/store/auth/authSlice';
|
||||
import { logout, setAccessToken, setUser } from '@/store/auth/authSlice';
|
||||
|
||||
import store from '../store';
|
||||
import axios from './axios';
|
||||
@ -37,6 +37,10 @@ export type ResetPasswordParams = {
|
||||
password: string;
|
||||
};
|
||||
|
||||
export type UpdateProfileParams = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
export const login = async (loginParams: LoginParams) => {
|
||||
const {
|
||||
data: { user, accessToken },
|
||||
@ -75,3 +79,23 @@ export const resetPassword = async (resetPasswordParams: ResetPasswordParams) =>
|
||||
|
||||
toast.success('Your password has been changed successfully, please login again.');
|
||||
};
|
||||
|
||||
export const updateProfile = async (updateProfileParams: UpdateProfileParams) => {
|
||||
const { data: user } = await axios.patch<User, AxiosResponse<User>, UpdateProfileParams>(
|
||||
'/auth/update-profile',
|
||||
updateProfileParams
|
||||
);
|
||||
|
||||
store.dispatch(setUser(user));
|
||||
|
||||
toast.success('Your profile has been successfully updated.');
|
||||
};
|
||||
|
||||
export const deleteAccount = async () => {
|
||||
await axios.delete('/resume/all');
|
||||
await axios.delete('/auth');
|
||||
|
||||
store.dispatch(logout());
|
||||
|
||||
toast.success('Your account has been deleted, hope to see you again soon.');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user