| 2 | import type { PreferencesAdapter, Preferences, UiConfig } from './types' |
| 3 | |
| 4 | export class FetchPreferencesAdapter implements PreferencesAdapter { |
| 5 | getPreferences(): Promise<Preferences> { |
| 6 | return get<Preferences>('/preferences') |
| 7 | } |
| 8 | |
| 9 | savePreferences(partial: Partial<Preferences>): Promise<{ success: boolean; error?: string }> { |
| 10 | return patch<{ success: boolean; error?: string }>('/preferences', partial) |
| 11 | } |
| 12 | |
| 13 | getUiConfig(): Promise<UiConfig> { |
| 14 | return get<UiConfig>('/preferences/ui-config') |
| 15 | } |
| 16 | |
| 17 | saveUiConfig(partial: Partial<UiConfig>): Promise<{ success: boolean; error?: string }> { |
| 18 | return patch<{ success: boolean; error?: string }>('/preferences/ui-config', partial) |
| 19 | } |
| 20 | |
| 21 | async getLocale(): Promise<string> { |
| 22 | const result = await get<{ lang: string }>('/preferences/locale') |
| 23 | return result.lang |
| 24 | } |
| 25 | |
| 26 | saveLocale(lang: string): Promise<{ success: boolean; error?: string }> { |
| 27 | return patch<{ success: boolean; error?: string }>('/preferences/locale', { lang }) |
| 28 | } |
| 29 | } |
nothing calls this directly
no outgoing calls
no test coverage detected