import type { SessionInfo, Theme, Language } from "../types/index.js"; import { BASE, del, get, patch, post, putBinary } from "./apiClient.js"; export const accountService = { forgotPassword: (email: string) => post<{ ok: boolean }>("/account/forgot-password", { email }), resetPassword: (token: string, password: string) => post<{ ok: boolean }>("/account/reset-password", { token, password }), requestEmailChange: (password: string, new_email: string) => post<{ ok: boolean }>("/account/email-change", { password, new_email }), confirmEmailChange: (token: string) => post<{ ok: boolean; email: string }>("/account/email-change/confirm", { token }), updateProfile: (first_name: string, last_name: string) => patch<{ ok: boolean }>("/account/profile", { first_name, last_name }), preferences: () => get<{ theme: Theme; language: Language }>("/account/preferences"), updatePreferences: (theme: Theme, language: Language) => patch<{ theme: Theme; language: Language }>("/account/preferences", { theme, language }), sessions: () => get<{ sessions: SessionInfo[] }>("/account/sessions"), revokeSession: (id: string) => del<{ ok: boolean }>(`/account/sessions/${encodeURIComponent(id)}`), revokeOtherSessions: () => del<{ ok: boolean }>("/account/sessions"), avatarUrl: (userId: string) => `${BASE}/account/avatar/${encodeURIComponent(userId)}`, uploadAvatar: (file: File) => putBinary<{ ok: boolean }>("/account/avatar", file, file.type), deleteAvatar: () => del<{ ok: boolean }>("/account/avatar"), };