added use update account

This commit is contained in:
Mamalizz
2025-02-11 23:25:25 +03:30
parent ce9de71f42
commit 8f88995ef7
@@ -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;