55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import axiosClient from "./axiosClient";
|
|
import { User, AiSettings } from "../types/user";
|
|
|
|
export const userApi = {
|
|
getProfile: async (): Promise<User> => {
|
|
const { data } = await axiosClient.get<User>("/user");
|
|
return data;
|
|
},
|
|
|
|
updateProfile: async (
|
|
profile: Partial<User> & {
|
|
currentPassword?: string;
|
|
newPassword?: string;
|
|
accent_color?: string;
|
|
show_edit_date?: boolean;
|
|
colored_icons?: boolean;
|
|
floating_toolbar_enabled?: boolean;
|
|
}
|
|
) => {
|
|
const { data } = await axiosClient.put("/user/profile", profile);
|
|
return data;
|
|
},
|
|
|
|
uploadAvatar: async (file: File) => {
|
|
const formData = new FormData();
|
|
formData.append("avatar", file);
|
|
|
|
const { data } = await axiosClient.post("/user/avatar", formData, {
|
|
headers: { "Content-Type": "multipart/form-data" },
|
|
});
|
|
return data;
|
|
},
|
|
|
|
deleteAvatar: async () => {
|
|
await axiosClient.delete("/user/avatar");
|
|
},
|
|
|
|
deleteAccount: async (password: string) => {
|
|
const { data } = await axiosClient.delete("/user/delete-account", {
|
|
data: { password },
|
|
});
|
|
return data;
|
|
},
|
|
|
|
getAiSettings: async (): Promise<AiSettings> => {
|
|
const { data } = await axiosClient.get<AiSettings>("/user/ai-settings");
|
|
return data;
|
|
},
|
|
|
|
updateAiSettings: async (settings: Partial<AiSettings>) => {
|
|
const { data } = await axiosClient.put("/user/ai-settings", settings);
|
|
return data;
|
|
},
|
|
};
|