You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
961 B
37 lines
961 B
import { ofetch } from "ofetch"; |
|
|
|
import { getAuthHeaders } from "@/backend/accounts/auth"; |
|
import { AccountWithToken } from "@/stores/auth"; |
|
|
|
export interface SettingsInput { |
|
applicationLanguage?: string; |
|
applicationTheme?: string | null; |
|
defaultSubtitleLanguage?: string; |
|
} |
|
|
|
export interface SettingsResponse { |
|
applicationTheme?: string | null; |
|
applicationLanguage?: string | null; |
|
defaultSubtitleLanguage?: string | null; |
|
} |
|
|
|
export function updateSettings( |
|
url: string, |
|
account: AccountWithToken, |
|
settings: SettingsInput |
|
) { |
|
return ofetch<SettingsResponse>(`/users/${account.userId}/settings`, { |
|
method: "PUT", |
|
body: settings, |
|
baseURL: url, |
|
headers: getAuthHeaders(account.token), |
|
}); |
|
} |
|
|
|
export function getSettings(url: string, account: AccountWithToken) { |
|
return ofetch<SettingsResponse>(`/users/${account.userId}/settings`, { |
|
method: "GET", |
|
baseURL: url, |
|
headers: getAuthHeaders(account.token), |
|
}); |
|
}
|
|
|