import { client } from '../client' import { API } from '../endpoints' import type { User } from '@/scripts/types/domain/user' import type { ApiResponse } from '@/scripts/types/api' export interface UpdateProfilePayload { name: string email: string password?: string | null confirm_password?: string | null } export interface UserSettingsPayload { settings: Record } export interface UserSettingsResponse { [key: string]: string | null } export const userService = { async getProfile(): Promise> { const { data } = await client.get(API.ME) return data }, async updateProfile(payload: UpdateProfilePayload): Promise> { const { data } = await client.put(API.ME, payload) return data }, async getSettings(settings?: string[]): Promise { const { data } = await client.get(API.ME_SETTINGS, { params: { settings }, }) return data }, async updateSettings(payload: UserSettingsPayload): Promise<{ success: boolean }> { const { data } = await client.put(API.ME_SETTINGS, payload) return data }, async uploadAvatar(payload: FormData): Promise> { const { data } = await client.post(API.ME_UPLOAD_AVATAR, payload) return data }, }