stratoflights-web/src/lib/api/profile.ts
2026-08-14 00:01:49 +09:00

20 lines
734 B
TypeScript

import { api } from './client';
export interface UserProfile {
username: string;
email: string;
first_name: string;
last_name: string;
}
export type ProfilePatch = Partial<Pick<UserProfile, 'email' | 'first_name' | 'last_name'>>;
export const profileApi = {
get: () => api.get<UserProfile>('/profile/'),
update: (patch: ProfilePatch) => api.patch<UserProfile>('/profile/', patch),
changePassword: (old_password: string, new_password: string) =>
api.post<{ detail: string }>('/profile/change-password/', { old_password, new_password }),
deleteData: () => api.del<{ detail: string }>('/profile/delete-data/'),
deleteAccount: (password: string) =>
api.del<{ detail: string }>('/profile/delete-account/', { password })
};