10 changed files with 239 additions and 41 deletions
@ -0,0 +1,33 @@ |
|||||||
|
import { ofetch } from "ofetch"; |
||||||
|
|
||||||
|
import { getAuthHeaders } from "@/backend/accounts/auth"; |
||||||
|
import { AccountWithToken } from "@/stores/auth"; |
||||||
|
|
||||||
|
import { BookmarkInput } from "./bookmarks"; |
||||||
|
import { ProgressInput } from "./progress"; |
||||||
|
|
||||||
|
export function importProgress( |
||||||
|
url: string, |
||||||
|
account: AccountWithToken, |
||||||
|
progressItems: ProgressInput[] |
||||||
|
) { |
||||||
|
return ofetch<void>(`/users/${account.userId}/progress/import`, { |
||||||
|
method: "PUT", |
||||||
|
body: progressItems, |
||||||
|
baseURL: url, |
||||||
|
headers: getAuthHeaders(account.token), |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
export function importBookmarks( |
||||||
|
url: string, |
||||||
|
account: AccountWithToken, |
||||||
|
bookmarks: BookmarkInput[] |
||||||
|
) { |
||||||
|
return ofetch<void>(`/users/${account.userId}/bookmarks`, { |
||||||
|
method: "PUT", |
||||||
|
body: bookmarks, |
||||||
|
baseURL: url, |
||||||
|
headers: getAuthHeaders(account.token), |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
import { ofetch } from "ofetch"; |
||||||
|
|
||||||
|
import { getAuthHeaders } from "@/backend/accounts/auth"; |
||||||
|
import { AccountWithToken } from "@/stores/auth"; |
||||||
|
|
||||||
|
export interface SettingsInput { |
||||||
|
applicationLanguage?: string; |
||||||
|
applicationTheme?: string; |
||||||
|
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), |
||||||
|
}); |
||||||
|
} |
Loading…
Reference in new issue