added use update account
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// imports
|
||||
|
||||
import { useMutation } from "@tanstack/vue-query";
|
||||
import { API_ENDPOINTS } from "~/constants";
|
||||
|
||||
// types
|
||||
|
||||
export type UpdateAccountRequest = {
|
||||
profile_photo?: File | null;
|
||||
first_name?: string;
|
||||
last_name?: string;
|
||||
phone?: string;
|
||||
gender?: string | undefined;
|
||||
email?: string;
|
||||
birth_date?: string;
|
||||
};
|
||||
|
||||
const useUpdateAccount = () => {
|
||||
// state
|
||||
|
||||
const { $axios: axios } = useNuxtApp();
|
||||
|
||||
// method
|
||||
|
||||
const handleUpdateAccount = async (params: UpdateAccountRequest) => {
|
||||
const { data } = await axios.patch(
|
||||
API_ENDPOINTS.account.update,
|
||||
{
|
||||
...params,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
}
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (data: UpdateAccountRequest) => handleUpdateAccount(data),
|
||||
});
|
||||
};
|
||||
|
||||
export default useUpdateAccount;
|
||||
Reference in New Issue
Block a user