mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:09:51 +08:00
15 lines
666 B
TypeScript
15 lines
666 B
TypeScript
import { apiFetch, apiUrl } from '@/lib/api'
|
|
|
|
export interface LearningOrigin {
|
|
content_workspace_id?: string
|
|
content_workspace_name?: string
|
|
}
|
|
export const libraryItemKey = (row: LearningOrigin, id: string | number) =>
|
|
JSON.stringify([row.content_workspace_id ?? '', id])
|
|
|
|
export async function learningLibrary<T extends LearningOrigin>(kind: string) {
|
|
const response = await apiFetch(apiUrl(`/api/dashboard/learning-library/${kind}`), { cache: 'no-store' })
|
|
if (!response.ok) throw new Error(`Could not load learning library (${response.status})`)
|
|
return await response.json() as { items: T[]; unavailable_workspaces: string[]; can_create: boolean }
|
|
}
|