34 lines
811 B
TypeScript
34 lines
811 B
TypeScript
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),
|
|
});
|
|
}
|