📓 course notes with file attachments under each course
Browse files at this commit49f3d3c8288e7e2a393ad0d8d5182ab2a49f6625Parent: 23ef9a8- feat
- 📓 course notes with file attachments under each course
23 changed files +522 -60
- src/api/__tests__/course-notes/course-notes.test.ts +144 -0
- src/api/client/types.ts +8 -0
- src/api/course-notes/deleteCourseNoteById.ts +5 -0
- src/api/course-notes/deleteCourseNoteFileById.ts +5 -0
- src/api/course-notes/getCourseNoteById.ts +6 -0
- src/api/course-notes/getCourseNoteFileBlob.ts +5 -0
- src/api/course-notes/getCourseNoteFileUrl.ts +3 -0
- src/api/course-notes/getCourseNoteFiles.ts +8 -0
- src/api/course-notes/getCourseNotes.ts +10 -0
- src/api/course-notes/index.ts +10 -0
- src/api/course-notes/patchCourseNoteById.ts +12 -0
- src/api/course-notes/postCourseNote.ts +12 -0
- src/api/course-notes/postCourseNoteFile.ts +8 -0
- src/components/courses/course-notes-panel.tsx +130 -0
- src/components/notes/note-card.tsx +23 -18
- src/components/notes/note-file-preview.tsx +4 -5
- src/components/notes/note-files-panel.tsx +45 -34
- src/components/notes/note-list.tsx +8 -0
- src/components/notes/note-reader-panel.tsx +5 -1
- src/i18n/messages.ts +18 -0
- src/lib/note-source.ts +37 -0
- src/pages/course-detail-page.tsx +14 -2
- src/pages/notes-page.tsx +2 -0
src/api/__tests__/course-notes/course-notes.test.tsadded+144 -0
| @@ -0,0 +1,144 @@ | |||
| 1 | +import { afterEach, describe, expect, it, vi } from "vitest"; | ||
| 2 | +import { getCourseNotes } from "../../course-notes"; | ||
| 3 | +import { getCourseNoteById } from "../../course-notes"; | ||
| 4 | +import { postCourseNote } from "../../course-notes"; | ||
| 5 | +import { patchCourseNoteById } from "../../course-notes"; | ||
| 6 | +import { deleteCourseNoteById } from "../../course-notes"; | ||
| 7 | +import { getCourseNoteFiles } from "../../course-notes"; | ||
| 8 | +import { postCourseNoteFile } from "../../course-notes"; | ||
| 9 | +import { deleteCourseNoteFileById } from "../../course-notes"; | ||
| 10 | +import { getCourseNoteFileUrl } from "../../course-notes"; | ||
| 11 | +import { getCourseNoteFileBlob } from "../../course-notes"; | ||
| 12 | +import { lastFetchCall, mockFetch204, mockFetchBlob, mockFetchSuccess } from "../helpers/mock-fetch"; | ||
| 13 | + | ||
| 14 | +describe("course notes API", () => { | ||
| 15 | + afterEach(() => { | ||
| 16 | + vi.restoreAllMocks(); | ||
| 17 | + }); | ||
| 18 | + | ||
| 19 | + it("getCourseNotes calls /course-notes with the required course filter", async () => { | ||
| 20 | + const mockPage = { items: [{ id: "cn1", course: "c1", title: "Note" }], total: 1 }; | ||
| 21 | + mockFetchSuccess(mockPage); | ||
| 22 | + | ||
| 23 | + const result = await getCourseNotes("c1"); | ||
| 24 | + expect(result).toEqual({ ...mockPage, limit: null, offset: 0 }); | ||
| 25 | + | ||
| 26 | + const [url, init] = lastFetchCall(); | ||
| 27 | + expect(url).toBe("/api/course-notes?course=c1"); | ||
| 28 | + expect(init?.method).toBe("GET"); | ||
| 29 | + }); | ||
| 30 | + | ||
| 31 | + it("getCourseNotes keeps the course filter alongside pagination", async () => { | ||
| 32 | + mockFetchSuccess({ items: [], total: 0 }); | ||
| 33 | + | ||
| 34 | + await getCourseNotes("c1", { limit: 10, offset: 20 }); | ||
| 35 | + | ||
| 36 | + const [url] = lastFetchCall(); | ||
| 37 | + expect(url).toBe("/api/course-notes?course=c1&limit=10&offset=20"); | ||
| 38 | + }); | ||
| 39 | + | ||
| 40 | + it("postCourseNote calls /course-notes with the course in the body", async () => { | ||
| 41 | + const mockNote = { id: "cn1", course: "c1", title: "Note", content: "Content" }; | ||
| 42 | + mockFetchSuccess(mockNote); | ||
| 43 | + | ||
| 44 | + const data = { course: "c1", title: "Note", content: "Content" }; | ||
| 45 | + const result = await postCourseNote(data); | ||
| 46 | + expect(result).toEqual(mockNote); | ||
| 47 | + | ||
| 48 | + const [url, init] = lastFetchCall(); | ||
| 49 | + expect(url).toBe("/api/course-notes"); | ||
| 50 | + expect(init?.method).toBe("POST"); | ||
| 51 | + expect(init?.body).toBe(JSON.stringify(data)); | ||
| 52 | + }); | ||
| 53 | + | ||
| 54 | + it("getCourseNoteById calls /course-notes/:id", async () => { | ||
| 55 | + const mockNote = { id: "cn1", course: "c1", title: "Note", content: "Content" }; | ||
| 56 | + mockFetchSuccess(mockNote); | ||
| 57 | + | ||
| 58 | + const result = await getCourseNoteById("cn1"); | ||
| 59 | + expect(result).toEqual(mockNote); | ||
| 60 | + | ||
| 61 | + const [url, init] = lastFetchCall(); | ||
| 62 | + expect(url).toBe("/api/course-notes/cn1"); | ||
| 63 | + expect(init?.method).toBe("GET"); | ||
| 64 | + }); | ||
| 65 | + | ||
| 66 | + it("patchCourseNoteById calls /course-notes/:id with updates", async () => { | ||
| 67 | + const mockNote = { id: "cn1", course: "c1", title: "Updated", content: "Content" }; | ||
| 68 | + mockFetchSuccess(mockNote); | ||
| 69 | + | ||
| 70 | + const updates = { title: "Updated" }; | ||
| 71 | + const result = await patchCourseNoteById("cn1", updates); | ||
| 72 | + expect(result).toEqual(mockNote); | ||
| 73 | + | ||
| 74 | + const [url, init] = lastFetchCall(); | ||
| 75 | + expect(url).toBe("/api/course-notes/cn1"); | ||
| 76 | + expect(init?.method).toBe("PATCH"); | ||
| 77 | + expect(init?.body).toBe(JSON.stringify(updates)); | ||
| 78 | + }); | ||
| 79 | + | ||
| 80 | + it("deleteCourseNoteById calls /course-notes/:id", async () => { | ||
| 81 | + mockFetch204(); | ||
| 82 | + | ||
| 83 | + await deleteCourseNoteById("cn1"); | ||
| 84 | + | ||
| 85 | + const [url, init] = lastFetchCall(); | ||
| 86 | + expect(url).toBe("/api/course-notes/cn1"); | ||
| 87 | + expect(init?.method).toBe("DELETE"); | ||
| 88 | + }); | ||
| 89 | + | ||
| 90 | + it("getCourseNoteFiles calls /course-notes/:id/files with pagination", async () => { | ||
| 91 | + const mockPage = { items: [{ id: "f1", name: "test.pdf" }], total: 1 }; | ||
| 92 | + mockFetchSuccess(mockPage); | ||
| 93 | + | ||
| 94 | + const result = await getCourseNoteFiles("cn1", { limit: 10 }); | ||
| 95 | + expect(result).toEqual({ ...mockPage, limit: null, offset: 0 }); | ||
| 96 | + | ||
| 97 | + const [url, init] = lastFetchCall(); | ||
| 98 | + expect(url).toBe("/api/course-notes/cn1/files?limit=10"); | ||
| 99 | + expect(init?.method).toBe("GET"); | ||
| 100 | + }); | ||
| 101 | + | ||
| 102 | + it("postCourseNoteFile calls /course-notes/:id/files with FormData", async () => { | ||
| 103 | + const mockFile = { id: "f1", name: "test.pdf", content_type: "application/pdf", size: 100 }; | ||
| 104 | + mockFetchSuccess(mockFile); | ||
| 105 | + | ||
| 106 | + const file = new File(["test"], "test.pdf", { type: "application/pdf" }); | ||
| 107 | + const result = await postCourseNoteFile("cn1", file); | ||
| 108 | + expect(result).toEqual(mockFile); | ||
| 109 | + | ||
| 110 | + const [url, init] = lastFetchCall(); | ||
| 111 | + expect(url).toBe("/api/course-notes/cn1/files"); | ||
| 112 | + expect(init?.method).toBe("POST"); | ||
| 113 | + expect(init?.body).toBeInstanceOf(FormData); | ||
| 114 | + expect((init?.body as FormData).get("file")).toBe(file); | ||
| 115 | + }); | ||
| 116 | + | ||
| 117 | + it("deleteCourseNoteFileById calls /course-notes/:id/files/:fileId", async () => { | ||
| 118 | + mockFetch204(); | ||
| 119 | + | ||
| 120 | + await deleteCourseNoteFileById("cn1", "f1"); | ||
| 121 | + | ||
| 122 | + const [url, init] = lastFetchCall(); | ||
| 123 | + expect(url).toBe("/api/course-notes/cn1/files/f1"); | ||
| 124 | + expect(init?.method).toBe("DELETE"); | ||
| 125 | + }); | ||
| 126 | + | ||
| 127 | + it("getCourseNoteFileUrl returns correct URL path", () => { | ||
| 128 | + const url = getCourseNoteFileUrl("cn1", "f1"); | ||
| 129 | + expect(url).toBe("/api/course-notes/cn1/files/f1"); | ||
| 130 | + }); | ||
| 131 | + | ||
| 132 | + it("getCourseNoteFileBlob fetches file blob", async () => { | ||
| 133 | + const blob = new Blob(["test"], { type: "application/pdf" }); | ||
| 134 | + mockFetchBlob(blob); | ||
| 135 | + | ||
| 136 | + const result = await getCourseNoteFileBlob("cn1", "f1"); | ||
| 137 | + expect(result).toBeInstanceOf(Blob); | ||
| 138 | + expect(result.type).toBe("application/pdf"); | ||
| 139 | + | ||
| 140 | + const [url, init] = lastFetchCall(); | ||
| 141 | + expect(url).toBe("/api/course-notes/cn1/files/f1"); | ||
| 142 | + expect(init?.credentials).toBe("same-origin"); | ||
| 143 | + }); | ||
| 144 | +}); | ||
src/api/client/types.tsmodified+8 -0
| @@ -105,6 +105,14 @@ export type Note = { | |||
| 105 | content: string; | 105 | content: string; |
| 106 | }; | 106 | }; |
| 107 | 107 | ||
| 108 | +/** A note attached to a course; files reuse the personal note's `NoteFile` shape. */ | ||
| 109 | +export type CourseNote = { | ||
| 110 | + id: string; | ||
| 111 | + course: string; | ||
| 112 | + title: string; | ||
| 113 | + content: string; | ||
| 114 | +}; | ||
| 115 | + | ||
| 108 | export type NoteFile = { | 116 | export type NoteFile = { |
| 109 | id: string; | 117 | id: string; |
| 110 | name: string; | 118 | name: string; |
src/api/course-notes/deleteCourseNoteById.tsadded+5 -0
| @@ -0,0 +1,5 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | + | ||
| 3 | +export function deleteCourseNoteById(id: string): Promise<void> { | ||
| 4 | + return client<void>(`/course-notes/${id}`, { method: "DELETE" }); | ||
| 5 | +} | ||
src/api/course-notes/deleteCourseNoteFileById.tsadded+5 -0
| @@ -0,0 +1,5 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | + | ||
| 3 | +export function deleteCourseNoteFileById(noteId: string, fileId: string): Promise<void> { | ||
| 4 | + return client<void>(`/course-notes/${noteId}/files/${fileId}`, { method: "DELETE" }); | ||
| 5 | +} | ||
src/api/course-notes/getCourseNoteById.tsadded+6 -0
| @@ -0,0 +1,6 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import type { CourseNote } from "../client"; | ||
| 3 | + | ||
| 4 | +export function getCourseNoteById(id: string, signal?: AbortSignal): Promise<CourseNote> { | ||
| 5 | + return client<CourseNote>(`/course-notes/${id}`, { signal }); | ||
| 6 | +} | ||
src/api/course-notes/getCourseNoteFileBlob.tsadded+5 -0
| @@ -0,0 +1,5 @@ | |||
| 1 | +import { blobClient } from "../client"; | ||
| 2 | + | ||
| 3 | +export async function getCourseNoteFileBlob(noteId: string, fileId: string, signal?: AbortSignal): Promise<Blob> { | ||
| 4 | + return blobClient(`/course-notes/${noteId}/files/${fileId}`, signal); | ||
| 5 | +} | ||
src/api/course-notes/getCourseNoteFileUrl.tsadded+3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | +export function getCourseNoteFileUrl(noteId: string, fileId: string): string { | ||
| 2 | + return `/api/course-notes/${encodeURIComponent(noteId)}/files/${encodeURIComponent(fileId)}`; | ||
| 3 | +} | ||
src/api/course-notes/getCourseNoteFiles.tsadded+8 -0
| @@ -0,0 +1,8 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import { normalizePage, pageQuery, type Page, type PageParams } from "../client"; | ||
| 3 | +import type { NoteFile } from "../client"; | ||
| 4 | + | ||
| 5 | +export async function getCourseNoteFiles(noteId: string, params?: PageParams, signal?: AbortSignal): Promise<Page<NoteFile>> { | ||
| 6 | + const data = await client<unknown>(`/course-notes/${noteId}/files${pageQuery(params)}`, { signal }); | ||
| 7 | + return normalizePage<NoteFile>(data); | ||
| 8 | +} | ||
src/api/course-notes/getCourseNotes.tsadded+10 -0
| @@ -0,0 +1,10 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import { appendPageParams, normalizePage, type Page, type PageParams } from "../client"; | ||
| 3 | +import type { CourseNote } from "../client"; | ||
| 4 | + | ||
| 5 | +export async function getCourseNotes(courseId: string, params?: PageParams, signal?: AbortSignal): Promise<Page<CourseNote>> { | ||
| 6 | + const query = new URLSearchParams({ course: courseId }); | ||
| 7 | + appendPageParams(query, params); | ||
| 8 | + const data = await client<unknown>(`/course-notes?${query.toString()}`, { signal }); | ||
| 9 | + return normalizePage<CourseNote>(data); | ||
| 10 | +} | ||
src/api/course-notes/index.tsadded+10 -0
| @@ -0,0 +1,10 @@ | |||
| 1 | +export * from "./getCourseNotes"; | ||
| 2 | +export * from "./getCourseNoteById"; | ||
| 3 | +export * from "./postCourseNote"; | ||
| 4 | +export * from "./patchCourseNoteById"; | ||
| 5 | +export * from "./deleteCourseNoteById"; | ||
| 6 | +export * from "./getCourseNoteFiles"; | ||
| 7 | +export * from "./postCourseNoteFile"; | ||
| 8 | +export * from "./deleteCourseNoteFileById"; | ||
| 9 | +export * from "./getCourseNoteFileUrl"; | ||
| 10 | +export * from "./getCourseNoteFileBlob"; | ||
src/api/course-notes/patchCourseNoteById.tsadded+12 -0
| @@ -0,0 +1,12 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import type { CourseNote } from "../client"; | ||
| 3 | + | ||
| 4 | +/** Omitted fields keep their value; null never clears here. */ | ||
| 5 | +export type PatchCourseNoteBody = { | ||
| 6 | + title?: string; | ||
| 7 | + content?: string; | ||
| 8 | +}; | ||
| 9 | + | ||
| 10 | +export function patchCourseNoteById(id: string, body: PatchCourseNoteBody): Promise<CourseNote> { | ||
| 11 | + return client<CourseNote>(`/course-notes/${id}`, { method: "PATCH", body }); | ||
| 12 | +} | ||
src/api/course-notes/postCourseNote.tsadded+12 -0
| @@ -0,0 +1,12 @@ | |||
| 1 | +import { client } from "../client"; | ||
| 2 | +import type { CourseNote } from "../client"; | ||
| 3 | + | ||
| 4 | +export type PostCourseNoteBody = { | ||
| 5 | + course: string; | ||
| 6 | + title: string; | ||
| 7 | + content?: string | null; | ||
| 8 | +}; | ||
| 9 | + | ||
| 10 | +export function postCourseNote(body: PostCourseNoteBody): Promise<CourseNote> { | ||
| 11 | + return client<CourseNote>("/course-notes", { method: "POST", body }); | ||
| 12 | +} | ||
src/api/course-notes/postCourseNoteFile.tsadded+8 -0
| @@ -0,0 +1,8 @@ | |||
| 1 | +import { formClient } from "../client"; | ||
| 2 | +import type { NoteFile } from "../client"; | ||
| 3 | + | ||
| 4 | +export function postCourseNoteFile(noteId: string, file: File, signal?: AbortSignal): Promise<NoteFile> { | ||
| 5 | + const body = new FormData(); | ||
| 6 | + body.append("file", file); | ||
| 7 | + return formClient<NoteFile>(`/course-notes/${noteId}/files`, body, signal); | ||
| 8 | +} | ||
src/components/courses/course-notes-panel.tsxadded+130 -0
| @@ -0,0 +1,130 @@ | |||
| 1 | +import { Show, Suspense, createEffect, createMemo, createResource, createSignal } from "solid-js"; | ||
| 2 | +import { deleteCourseNoteById, getCourseNotes, patchCourseNoteById, postCourseNote, postCourseNoteFile } from "@/api/course-notes"; | ||
| 3 | +import { formatApiError } from "@/api/client"; | ||
| 4 | +import { NoteForm } from "@/components/notes/note-form"; | ||
| 5 | +import { NoteList } from "@/components/notes/note-list"; | ||
| 6 | +import { Alert } from "@/components/ui/alert"; | ||
| 7 | +import { PageSpinner } from "@/components/ui/page-spinner"; | ||
| 8 | +import { PaginationControls } from "@/components/ui/pagination-controls"; | ||
| 9 | +import { SidePanel } from "@/components/ui/side-panel"; | ||
| 10 | +import { createFlash } from "@/lib/flash"; | ||
| 11 | +import { loadListPage, totalPages as pagesOf } from "@/lib/list-page"; | ||
| 12 | +import { courseNoteFiles } from "@/lib/note-source"; | ||
| 13 | +import { useT } from "@/stores/preferences-context"; | ||
| 14 | + | ||
| 15 | +const NOTE_PAGE_SIZE = 6; | ||
| 16 | + | ||
| 17 | +export function CourseNotesPanel(props: { | ||
| 18 | + courseId: string; | ||
| 19 | + canManage: boolean; | ||
| 20 | + active: boolean; | ||
| 21 | + createOpen: boolean; | ||
| 22 | + onCreateOpenChange: (open: boolean) => void; | ||
| 23 | + onCountChange: (count: number) => void; | ||
| 24 | +}) { | ||
| 25 | + const t = useT(); | ||
| 26 | + const [error, setError] = createSignal(""); | ||
| 27 | + const [flash, setFlash] = createFlash(); | ||
| 28 | + const [page, setPage] = createSignal(0); | ||
| 29 | + | ||
| 30 | + const [list, { refetch }] = createResource( | ||
| 31 | + () => (props.active ? ({ courseId: props.courseId, page: page() }) : null), | ||
| 32 | + async (key) => | ||
| 33 | + loadListPage({ | ||
| 34 | + page: key.page, | ||
| 35 | + pageSize: NOTE_PAGE_SIZE, | ||
| 36 | + clientMode: false, | ||
| 37 | + fetch: (params) => getCourseNotes(key.courseId, params), | ||
| 38 | + }), | ||
| 39 | + ); | ||
| 40 | + | ||
| 41 | + const total = () => list()?.total ?? 0; | ||
| 42 | + const pageItems = () => list()?.items ?? []; | ||
| 43 | + const totalPages = createMemo(() => pagesOf(total(), NOTE_PAGE_SIZE)); | ||
| 44 | + const safePage = createMemo(() => Math.min(page(), totalPages() - 1)); | ||
| 45 | + | ||
| 46 | + createEffect(() => props.onCountChange(total())); | ||
| 47 | + | ||
| 48 | + const wrap = async (fn: () => Promise<void>, okMessage: string) => { | ||
| 49 | + setError(""); | ||
| 50 | + try { | ||
| 51 | + await fn(); | ||
| 52 | + await refetch(); | ||
| 53 | + setFlash(okMessage); | ||
| 54 | + } catch (err) { | ||
| 55 | + setError(formatApiError(err)); | ||
| 56 | + } | ||
| 57 | + }; | ||
| 58 | + | ||
| 59 | + return ( | ||
| 60 | + <section class="min-w-0 space-y-4 rounded-lg border border-border/60 bg-card/60 p-3 shadow-xs sm:p-4 dark:border-white/8 dark:bg-card/40"> | ||
| 61 | + <Show when={flash()}> | ||
| 62 | + <Alert variant="success">{flash()}</Alert> | ||
| 63 | + </Show> | ||
| 64 | + <Show when={error() && !props.createOpen}> | ||
| 65 | + <Alert variant="destructive">{error()}</Alert> | ||
| 66 | + </Show> | ||
| 67 | + | ||
| 68 | + <Show when={props.canManage}> | ||
| 69 | + <SidePanel open={props.createOpen} onOpenChange={props.onCreateOpenChange} title={t("courseNotes.new")}> | ||
| 70 | + <NoteForm | ||
| 71 | + enableFiles | ||
| 72 | + submitLabel={t("common.create")} | ||
| 73 | + onCancel={() => props.onCreateOpenChange(false)} | ||
| 74 | + onSubmit={async (values) => { | ||
| 75 | + setError(""); | ||
| 76 | + const note = await postCourseNote({ | ||
| 77 | + course: props.courseId, | ||
| 78 | + title: values.title, | ||
| 79 | + content: values.content || undefined, | ||
| 80 | + }); | ||
| 81 | + let failedUploads = 0; | ||
| 82 | + for (const file of values.files) { | ||
| 83 | + try { | ||
| 84 | + await postCourseNoteFile(note.id, file); | ||
| 85 | + } catch { | ||
| 86 | + failedUploads += 1; | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + await refetch(); | ||
| 90 | + props.onCreateOpenChange(false); | ||
| 91 | + if (failedUploads > 0) { | ||
| 92 | + setError(t("notes.fileUploadPartial", { count: failedUploads })); | ||
| 93 | + return; | ||
| 94 | + } | ||
| 95 | + setFlash(t("common.created")); | ||
| 96 | + }} | ||
| 97 | + /> | ||
| 98 | + </SidePanel> | ||
| 99 | + </Show> | ||
| 100 | + | ||
| 101 | + <Suspense fallback={<PageSpinner />}> | ||
| 102 | + <Show when={list.error}> | ||
| 103 | + <Alert variant="destructive">{formatApiError(list.error)}</Alert> | ||
| 104 | + </Show> | ||
| 105 | + <Show when={list()}> | ||
| 106 | + <NoteList | ||
| 107 | + notes={pageItems()} | ||
| 108 | + source={courseNoteFiles} | ||
| 109 | + canManage={props.canManage} | ||
| 110 | + emptyTitle={t("courseNotes.empty")} | ||
| 111 | + emptyDescription={props.canManage ? t("courseNotes.emptyManageHint") : undefined} | ||
| 112 | + onUpdate={(id, values) => | ||
| 113 | + wrap(async () => { | ||
| 114 | + await patchCourseNoteById(id, values); | ||
| 115 | + }, t("common.saved")) | ||
| 116 | + } | ||
| 117 | + onDelete={(id) => | ||
| 118 | + wrap(async () => { | ||
| 119 | + await deleteCourseNoteById(id); | ||
| 120 | + }, t("common.deleted")) | ||
| 121 | + } | ||
| 122 | + /> | ||
| 123 | + <Show when={total() > NOTE_PAGE_SIZE}> | ||
| 124 | + <PaginationControls page={safePage()} totalPages={totalPages()} onPageChange={setPage} /> | ||
| 125 | + </Show> | ||
| 126 | + </Show> | ||
| 127 | + </Suspense> | ||
| 128 | + </section> | ||
| 129 | + ); | ||
| 130 | +} | ||
src/components/notes/note-card.tsxmodified+23 -18
| @@ -10,6 +10,8 @@ import { useT } from "@/stores/preferences-context"; | |||
| 10 | 10 | ||
| 11 | export function NoteCard(props: { | 11 | export function NoteCard(props: { |
| 12 | note: Note; | 12 | note: Note; |
| 13 | + /** Hides the edit/delete menu when false. Defaults to true. */ | ||
| 14 | + canManage?: boolean; | ||
| 13 | onOpen: (note: Note) => void; | 15 | onOpen: (note: Note) => void; |
| 14 | onUpdate: (id: string, values: { title: string; content: string }) => Promise<void>; | 16 | onUpdate: (id: string, values: { title: string; content: string }) => Promise<void>; |
| 15 | onDelete: (id: string) => Promise<void>; | 17 | onDelete: (id: string) => Promise<void>; |
| @@ -18,6 +20,7 @@ export function NoteCard(props: { | |||
| 18 | const [editing, setEditing] = createSignal(false); | 20 | const [editing, setEditing] = createSignal(false); |
| 19 | const [error, setError] = createSignal(""); | 21 | const [error, setError] = createSignal(""); |
| 20 | const [deleteOpen, setDeleteOpen] = createSignal(false); | 22 | const [deleteOpen, setDeleteOpen] = createSignal(false); |
| 23 | + const canManage = () => props.canManage !== false; | ||
| 21 | 24 | ||
| 22 | return ( | 25 | return ( |
| 23 | <> | 26 | <> |
| @@ -35,24 +38,26 @@ export function NoteCard(props: { | |||
| 35 | > | 38 | > |
| 36 | <div class="flex items-start justify-between gap-3 border-b border-amber-500/30 bg-muted/40 px-4 py-3 dark:border-amber-500/30 dark:bg-muted/30"> | 39 | <div class="flex items-start justify-between gap-3 border-b border-amber-500/30 bg-muted/40 px-4 py-3 dark:border-amber-500/30 dark:bg-muted/30"> |
| 37 | <h3 class="line-clamp-2 min-w-0 text-base font-semibold leading-snug">{props.note.title}</h3> | 40 | <h3 class="line-clamp-2 min-w-0 text-base font-semibold leading-snug">{props.note.title}</h3> |
| 38 | - <div class="shrink-0" onClick={(event) => event.stopPropagation()}> | 41 | + <Show when={canManage()}> |
| 39 | - <TableRowActions | 42 | + <div class="shrink-0" onClick={(event) => event.stopPropagation()}> |
| 40 | - label={t("common.actions")} | 43 | + <TableRowActions |
| 41 | - actions={[ | 44 | + label={t("common.actions")} |
| 42 | - { | 45 | + actions={[ |
| 43 | - label: t("common.edit"), | 46 | + { |
| 44 | - icon: <IconEdit class="h-4 w-4" />, | 47 | + label: t("common.edit"), |
| 45 | - onSelect: () => setEditing(true), | 48 | + icon: <IconEdit class="h-4 w-4" />, |
| 46 | - }, | 49 | + onSelect: () => setEditing(true), |
| 47 | - { | 50 | + }, |
| 48 | - label: t("common.delete"), | 51 | + { |
| 49 | - icon: <IconTrash class="h-4 w-4" />, | 52 | + label: t("common.delete"), |
| 50 | - destructive: true, | 53 | + icon: <IconTrash class="h-4 w-4" />, |
| 51 | - onSelect: () => setDeleteOpen(true), | 54 | + destructive: true, |
| 52 | - }, | 55 | + onSelect: () => setDeleteOpen(true), |
| 53 | - ]} | 56 | + }, |
| 54 | - /> | 57 | + ]} |
| 55 | - </div> | 58 | + /> |
| 59 | + </div> | ||
| 60 | + </Show> | ||
| 56 | </div> | 61 | </div> |
| 57 | <div class="flex flex-1 flex-col gap-4 bg-[linear-gradient(90deg,rgba(245,158,11,0.12)_0,rgba(245,158,11,0.12)_2.25rem,transparent_2.25rem),repeating-linear-gradient(0deg,transparent_0,transparent_2.05rem,rgba(120,113,108,0.14)_2.1rem)] px-4 py-4 pl-12 dark:bg-[linear-gradient(90deg,rgba(245,158,11,0.1)_0,rgba(245,158,11,0.1)_2.25rem,transparent_2.25rem),repeating-linear-gradient(0deg,transparent_0,transparent_2.05rem,rgba(214,211,209,0.1)_2.1rem)]"> | 62 | <div class="flex flex-1 flex-col gap-4 bg-[linear-gradient(90deg,rgba(245,158,11,0.12)_0,rgba(245,158,11,0.12)_2.25rem,transparent_2.25rem),repeating-linear-gradient(0deg,transparent_0,transparent_2.05rem,rgba(120,113,108,0.14)_2.1rem)] px-4 py-4 pl-12 dark:bg-[linear-gradient(90deg,rgba(245,158,11,0.1)_0,rgba(245,158,11,0.1)_2.25rem,transparent_2.25rem),repeating-linear-gradient(0deg,transparent_0,transparent_2.05rem,rgba(214,211,209,0.1)_2.1rem)]"> |
| 58 | <Show | 63 | <Show |
src/components/notes/note-file-preview.tsxmodified+4 -5
| @@ -1,8 +1,7 @@ | |||
| 1 | import { Match, Show, Switch, createEffect, createSignal, onCleanup } from "solid-js"; | 1 | import { Match, Show, Switch, createEffect, createSignal, onCleanup } from "solid-js"; |
| 2 | import { formatApiError } from "@/api/client"; | 2 | import { formatApiError } from "@/api/client"; |
| 3 | -import { getNoteFileBlob } from "@/api/notes"; | ||
| 4 | import type { NoteFile } from "@/api/client"; | 3 | import type { NoteFile } from "@/api/client"; |
| 5 | -import { getNoteFileUrl } from "@/api/notes"; | 4 | +import type { NoteFileSource } from "@/lib/note-source"; |
| 6 | import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"; | 5 | import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"; |
| 7 | import { useT } from "@/stores/preferences-context"; | 6 | import { useT } from "@/stores/preferences-context"; |
| 8 | 7 | ||
| @@ -15,12 +14,12 @@ function canPreview(file: NoteFile): boolean { | |||
| 15 | return type.startsWith("image/") || type.startsWith("video/") || type.startsWith("audio/") || canFrame(type); | 14 | return type.startsWith("image/") || type.startsWith("video/") || type.startsWith("audio/") || canFrame(type); |
| 16 | } | 15 | } |
| 17 | 16 | ||
| 18 | -export function NoteFilePreview(props: { noteId: string; file: NoteFile | null; onClose: () => void }) { | 17 | +export function NoteFilePreview(props: { noteId: string; source: NoteFileSource; file: NoteFile | null; onClose: () => void }) { |
| 19 | const t = useT(); | 18 | const t = useT(); |
| 20 | let currentUrl = ""; | 19 | let currentUrl = ""; |
| 21 | const [previewUrl, setPreviewUrl] = createSignal(""); | 20 | const [previewUrl, setPreviewUrl] = createSignal(""); |
| 22 | const [previewError, setPreviewError] = createSignal(""); | 21 | const [previewError, setPreviewError] = createSignal(""); |
| 23 | - const downloadUrl = () => (props.file ? getNoteFileUrl(props.noteId, props.file.id) : ""); | 22 | + const downloadUrl = () => (props.file ? props.source.fileUrl(props.noteId, props.file.id) : ""); |
| 24 | const type = () => props.file?.content_type ?? ""; | 23 | const type = () => props.file?.content_type ?? ""; |
| 25 | 24 | ||
| 26 | createEffect(() => { | 25 | createEffect(() => { |
| @@ -33,7 +32,7 @@ export function NoteFilePreview(props: { noteId: string; file: NoteFile | null; | |||
| 33 | if (!file || !canPreview(file)) return; | 32 | if (!file || !canPreview(file)) return; |
| 34 | 33 | ||
| 35 | const controller = new AbortController(); | 34 | const controller = new AbortController(); |
| 36 | - void getNoteFileBlob(props.noteId, file.id, controller.signal) | 35 | + void props.source.fileBlob(props.noteId, file.id, controller.signal) |
| 37 | .then((blob) => { | 36 | .then((blob) => { |
| 38 | if (controller.signal.aborted) return; | 37 | if (controller.signal.aborted) return; |
| 39 | currentUrl = URL.createObjectURL(blob); | 38 | currentUrl = URL.createObjectURL(blob); |
src/components/notes/note-files-panel.tsxmodified+45 -34
| @@ -1,13 +1,9 @@ | |||
| 1 | import { For, Show, Suspense, createEffect, createMemo, createResource, createSignal, lazy } from "solid-js"; | 1 | import { For, Show, Suspense, createEffect, createMemo, createResource, createSignal, lazy } from "solid-js"; |
| 2 | -import { deleteNoteFileById } from "@/api/notes"; | ||
| 3 | -import { getNoteFileBlob } from "@/api/notes"; | ||
| 4 | -import { getNoteFileUrl } from "@/api/notes"; | ||
| 5 | -import { getNoteFiles } from "@/api/notes"; | ||
| 6 | import { getSettings } from "@/api/settings"; | 2 | import { getSettings } from "@/api/settings"; |
| 7 | -import { postNoteFile } from "@/api/notes"; | ||
| 8 | import { formatApiError } from "@/api/client"; | 3 | import { formatApiError } from "@/api/client"; |
| 9 | import type { NoteFile } from "@/api/client"; | 4 | import type { NoteFile } from "@/api/client"; |
| 10 | import type { DrawScene } from "@/lib/draw-stroke"; | 5 | import type { DrawScene } from "@/lib/draw-stroke"; |
| 6 | +import type { NoteFileSource } from "@/lib/note-source"; | ||
| 11 | import { NoteFilePreview } from "@/components/notes/note-file-preview"; | 7 | import { NoteFilePreview } from "@/components/notes/note-file-preview"; |
| 12 | import { Alert } from "@/components/ui/alert"; | 8 | import { Alert } from "@/components/ui/alert"; |
| 13 | import { Button } from "@/components/ui/button"; | 9 | import { Button } from "@/components/ui/button"; |
| @@ -26,14 +22,20 @@ import { useT } from "@/stores/preferences-context"; | |||
| 26 | // Lazy so the drawing pad rides its own chunk, off the notes page's initial load. | 22 | // Lazy so the drawing pad rides its own chunk, off the notes page's initial load. |
| 27 | const DrawCanvas = lazy(() => import("@/components/ui/draw-canvas").then((m) => ({ default: m.DrawCanvas }))); | 23 | const DrawCanvas = lazy(() => import("@/components/ui/draw-canvas").then((m) => ({ default: m.DrawCanvas }))); |
| 28 | 24 | ||
| 29 | -const MAX_NOTE_FILES = 10; | ||
| 30 | const FILE_PAGE_SIZE = 4; | 25 | const FILE_PAGE_SIZE = 4; |
| 31 | 26 | ||
| 32 | /** Drawings are saved with this suffix so the grid can offer "Edit" without fetching every blob. */ | 27 | /** Drawings are saved with this suffix so the grid can offer "Edit" without fetching every blob. */ |
| 33 | const DRAWING_SUFFIX = ".hzdraw.png"; | 28 | const DRAWING_SUFFIX = ".hzdraw.png"; |
| 34 | const isDrawing = (file: NoteFile) => file.name.toLowerCase().endsWith(DRAWING_SUFFIX); | 29 | const isDrawing = (file: NoteFile) => file.name.toLowerCase().endsWith(DRAWING_SUFFIX); |
| 35 | 30 | ||
| 36 | -export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | 31 | +export function NoteFilesPanel(props: { |
| 32 | + noteId: string; | ||
| 33 | + active: boolean; | ||
| 34 | + /** Which note family the files hang off — personal notes or a course's. */ | ||
| 35 | + source: NoteFileSource; | ||
| 36 | + /** Read-only when false: no upload, drawing, or delete. Defaults to true. */ | ||
| 37 | + canManage?: boolean; | ||
| 38 | +}) { | ||
| 37 | let input: HTMLInputElement | undefined; | 39 | let input: HTMLInputElement | undefined; |
| 38 | const t = useT(); | 40 | const t = useT(); |
| 39 | const [error, setError] = createSignal(""); | 41 | const [error, setError] = createSignal(""); |
| @@ -45,11 +47,12 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | |||
| 45 | const [editTarget, setEditTarget] = createSignal<NoteFile | null>(null); | 47 | const [editTarget, setEditTarget] = createSignal<NoteFile | null>(null); |
| 46 | const [previewFile, setPreviewFile] = createSignal<NoteFile | null>(null); | 48 | const [previewFile, setPreviewFile] = createSignal<NoteFile | null>(null); |
| 47 | const [deleteTarget, setDeleteTarget] = createSignal<NoteFile | null>(null); | 49 | const [deleteTarget, setDeleteTarget] = createSignal<NoteFile | null>(null); |
| 50 | + const canManage = () => props.canManage !== false; | ||
| 48 | const [files, { refetch }] = createResource( | 51 | const [files, { refetch }] = createResource( |
| 49 | () => (props.active ? props.noteId : null), | 52 | () => (props.active ? props.noteId : null), |
| 50 | async (noteId) => { | 53 | async (noteId) => { |
| 51 | if (!noteId) return [] as NoteFile[]; | 54 | if (!noteId) return [] as NoteFile[]; |
| 52 | - return (await getNoteFiles(noteId, { limit: MAX_NOTE_FILES })).items; | 55 | + return (await props.source.listFiles(noteId, { limit: props.source.maxFiles })).items; |
| 53 | }, | 56 | }, |
| 54 | ); | 57 | ); |
| 55 | const [settings] = createResource(async () => { | 58 | const [settings] = createResource(async () => { |
| @@ -60,7 +63,7 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | |||
| 60 | } | 63 | } |
| 61 | }); | 64 | }); |
| 62 | const maxFileBytes = () => maxUploadBytes(settings()); | 65 | const maxFileBytes = () => maxUploadBytes(settings()); |
| 63 | - const atLimit = () => (files() ?? []).length >= MAX_NOTE_FILES; | 66 | + const atLimit = () => (files() ?? []).length >= props.source.maxFiles; |
| 64 | const totalPages = createMemo(() => Math.max(1, Math.ceil((files() ?? []).length / FILE_PAGE_SIZE))); | 67 | const totalPages = createMemo(() => Math.max(1, Math.ceil((files() ?? []).length / FILE_PAGE_SIZE))); |
| 65 | const pageFiles = createMemo(() => { | 68 | const pageFiles = createMemo(() => { |
| 66 | const start = filePage() * FILE_PAGE_SIZE; | 69 | const start = filePage() * FILE_PAGE_SIZE; |
| @@ -80,7 +83,7 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | |||
| 80 | } | 83 | } |
| 81 | setPending(true); | 84 | setPending(true); |
| 82 | try { | 85 | try { |
| 83 | - await postNoteFile(props.noteId, file); | 86 | + await props.source.uploadFile(props.noteId, file); |
| 84 | await refetch(); | 87 | await refetch(); |
| 85 | if (input) input.value = ""; | 88 | if (input) input.value = ""; |
| 86 | setFlash(t("common.created")); | 89 | setFlash(t("common.created")); |
| @@ -95,7 +98,7 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | |||
| 95 | 98 | ||
| 96 | const download = (file: NoteFile) => { | 99 | const download = (file: NoteFile) => { |
| 97 | const link = document.createElement("a"); | 100 | const link = document.createElement("a"); |
| 98 | - link.href = getNoteFileUrl(props.noteId, file.id); | 101 | + link.href = props.source.fileUrl(props.noteId, file.id); |
| 99 | link.download = file.name; | 102 | link.download = file.name; |
| 100 | link.click(); | 103 | link.click(); |
| 101 | }; | 104 | }; |
| @@ -109,7 +112,7 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | |||
| 109 | const openEditDrawing = async (file: NoteFile) => { | 112 | const openEditDrawing = async (file: NoteFile) => { |
| 110 | setError(""); | 113 | setError(""); |
| 111 | try { | 114 | try { |
| 112 | - const blob = await getNoteFileBlob(props.noteId, file.id); | 115 | + const blob = await props.source.fileBlob(props.noteId, file.id); |
| 113 | const { pngBytesToScene } = await import("@/lib/drawing-file"); | 116 | const { pngBytesToScene } = await import("@/lib/drawing-file"); |
| 114 | setEditScene(pngBytesToScene(new Uint8Array(await blob.arrayBuffer()))); | 117 | setEditScene(pngBytesToScene(new Uint8Array(await blob.arrayBuffer()))); |
| 115 | setEditTarget(file); | 118 | setEditTarget(file); |
| @@ -126,7 +129,7 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | |||
| 126 | if (!(await upload(file))) return; | 129 | if (!(await upload(file))) return; |
| 127 | if (target) { | 130 | if (target) { |
| 128 | try { | 131 | try { |
| 129 | - await deleteNoteFileById(props.noteId, target.id); | 132 | + await props.source.deleteFile(props.noteId, target.id); |
| 130 | await refetch(); | 133 | await refetch(); |
| 131 | } catch { | 134 | } catch { |
| 132 | // New drawing is saved; deleting the old copy failed — a stale duplicate | 135 | // New drawing is saved; deleting the old copy failed — a stale duplicate |
| @@ -146,7 +149,9 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | |||
| 146 | <div class="flex flex-wrap items-center justify-between gap-3"> | 149 | <div class="flex flex-wrap items-center justify-between gap-3"> |
| 147 | <div> | 150 | <div> |
| 148 | <h3 class="text-sm font-semibold">{t("notes.files")}</h3> | 151 | <h3 class="text-sm font-semibold">{t("notes.files")}</h3> |
| 149 | - <p class="mt-1 text-xs text-muted-foreground">{t("notes.filesHelp", { size: formatBytes(maxFileBytes()) })}</p> | 152 | + <Show when={canManage()}> |
| 153 | + <p class="mt-1 text-xs text-muted-foreground">{t("notes.filesHelp", { size: formatBytes(maxFileBytes()) })}</p> | ||
| 154 | + </Show> | ||
| 150 | </div> | 155 | </div> |
| 151 | <input | 156 | <input |
| 152 | ref={(el) => { | 157 | ref={(el) => { |
| @@ -157,20 +162,22 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | |||
| 157 | disabled={pending() || atLimit()} | 162 | disabled={pending() || atLimit()} |
| 158 | onChange={(event) => void upload(event.currentTarget.files?.[0])} | 163 | onChange={(event) => void upload(event.currentTarget.files?.[0])} |
| 159 | /> | 164 | /> |
| 160 | - <div class="grid grid-cols-2 gap-2 sm:flex sm:items-center"> | 165 | + <Show when={canManage()}> |
| 161 | - <Button type="button" variant="outline" size="sm" class="w-full sm:w-32 rounded-lg" disabled={pending() || atLimit()} onClick={openNewDrawing}> | 166 | + <div class="grid grid-cols-2 gap-2 sm:flex sm:items-center"> |
| 162 | - <IconEdit class="h-4 w-4 shrink-0" /> | 167 | + <Button type="button" variant="outline" size="sm" class="w-full sm:w-32 rounded-lg" disabled={pending() || atLimit()} onClick={openNewDrawing}> |
| 163 | - <span class="truncate">{t("notes.draw")}</span> | 168 | + <IconEdit class="h-4 w-4 shrink-0" /> |
| 164 | - </Button> | 169 | + <span class="truncate">{t("notes.draw")}</span> |
| 165 | - <Button type="button" size="sm" class="w-full sm:w-32 rounded-lg" disabled={pending() || atLimit()} onClick={() => input?.click()}> | 170 | + </Button> |
| 166 | - <IconPlus class="h-4 w-4 shrink-0" /> | 171 | + <Button type="button" size="sm" class="w-full sm:w-32 rounded-lg" disabled={pending() || atLimit()} onClick={() => input?.click()}> |
| 167 | - <span class="truncate">{t("notes.addFile")}</span> | 172 | + <IconPlus class="h-4 w-4 shrink-0" /> |
| 168 | - </Button> | 173 | + <span class="truncate">{t("notes.addFile")}</span> |
| 169 | - </div> | 174 | + </Button> |
| 175 | + </div> | ||
| 176 | + </Show> | ||
| 170 | </div> | 177 | </div> |
| 171 | 178 | ||
| 172 | {error() && <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">{error()}</p>} | 179 | {error() && <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">{error()}</p>} |
| 173 | - <Show when={atLimit()}> | 180 | + <Show when={canManage() && atLimit()}> |
| 174 | <p class="text-xs text-muted-foreground">{t("notes.fileLimit")}</p> | 181 | <p class="text-xs text-muted-foreground">{t("notes.fileLimit")}</p> |
| 175 | </Show> | 182 | </Show> |
| 176 | 183 | ||
| @@ -202,7 +209,7 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | |||
| 202 | <TableRowActions | 209 | <TableRowActions |
| 203 | label={t("common.actions")} | 210 | label={t("common.actions")} |
| 204 | actions={[ | 211 | actions={[ |
| 205 | - ...(isDrawing(file) | 212 | + ...(canManage() && isDrawing(file) |
| 206 | ? [ | 213 | ? [ |
| 207 | { | 214 | { |
| 208 | label: t("common.edit"), | 215 | label: t("common.edit"), |
| @@ -221,12 +228,16 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | |||
| 221 | icon: <IconDownload class="h-4 w-4" />, | 228 | icon: <IconDownload class="h-4 w-4" />, |
| 222 | onSelect: () => download(file), | 229 | onSelect: () => download(file), |
| 223 | }, | 230 | }, |
| 224 | - { | 231 | + ...(canManage() |
| 225 | - label: t("common.delete"), | 232 | + ? [ |
| 226 | - icon: <IconTrash class="h-4 w-4" />, | 233 | + { |
| 227 | - destructive: true, | 234 | + label: t("common.delete"), |
| 228 | - onSelect: () => setDeleteTarget(file), | 235 | + icon: <IconTrash class="h-4 w-4" />, |
| 229 | - }, | 236 | + destructive: true, |
| 237 | + onSelect: () => setDeleteTarget(file), | ||
| 238 | + }, | ||
| 239 | + ] | ||
| 240 | + : []), | ||
| 230 | ]} | 241 | ]} |
| 231 | /> | 242 | /> |
| 232 | </div> | 243 | </div> |
| @@ -243,7 +254,7 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | |||
| 243 | <Show when={(files() ?? []).length > FILE_PAGE_SIZE}> | 254 | <Show when={(files() ?? []).length > FILE_PAGE_SIZE}> |
| 244 | <PaginationControls page={filePage()} totalPages={totalPages()} onPageChange={setFilePage} /> | 255 | <PaginationControls page={filePage()} totalPages={totalPages()} onPageChange={setFilePage} /> |
| 245 | </Show> | 256 | </Show> |
| 246 | - <NoteFilePreview noteId={props.noteId} file={previewFile()} onClose={() => setPreviewFile(null)} /> | 257 | + <NoteFilePreview noteId={props.noteId} source={props.source} file={previewFile()} onClose={() => setPreviewFile(null)} /> |
| 247 | </Show> | 258 | </Show> |
| 248 | </Suspense> | 259 | </Suspense> |
| 249 | 260 | ||
| @@ -281,7 +292,7 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) { | |||
| 281 | onConfirm={async () => { | 292 | onConfirm={async () => { |
| 282 | const target = deleteTarget(); | 293 | const target = deleteTarget(); |
| 283 | if (!target) return; | 294 | if (!target) return; |
| 284 | - await deleteNoteFileById(props.noteId, target.id); | 295 | + await props.source.deleteFile(props.noteId, target.id); |
| 285 | if (previewFile()?.id === target.id) setPreviewFile(null); | 296 | if (previewFile()?.id === target.id) setPreviewFile(null); |
| 286 | setDeleteTarget(null); | 297 | setDeleteTarget(null); |
| 287 | await refetch(); | 298 | await refetch(); |
src/components/notes/note-list.tsxmodified+8 -0
| @@ -1,11 +1,16 @@ | |||
| 1 | import { For, Show, createSignal } from "solid-js"; | 1 | import { For, Show, createSignal } from "solid-js"; |
| 2 | import type { Note } from "@/api/client"; | 2 | import type { Note } from "@/api/client"; |
| 3 | +import type { NoteFileSource } from "@/lib/note-source"; | ||
| 3 | import { NoteCard } from "@/components/notes/note-card"; | 4 | import { NoteCard } from "@/components/notes/note-card"; |
| 4 | import { NoteReaderPanel } from "@/components/notes/note-reader-panel"; | 5 | import { NoteReaderPanel } from "@/components/notes/note-reader-panel"; |
| 5 | import { EmptyState } from "@/components/ui/empty-state"; | 6 | import { EmptyState } from "@/components/ui/empty-state"; |
| 6 | 7 | ||
| 7 | export function NoteList(props: { | 8 | export function NoteList(props: { |
| 8 | notes: Note[]; | 9 | notes: Note[]; |
| 10 | + /** Which note family these belong to — decides the file routes behind them. */ | ||
| 11 | + source: NoteFileSource; | ||
| 12 | + /** Hides edit/delete and the file controls when false. Defaults to true. */ | ||
| 13 | + canManage?: boolean; | ||
| 9 | emptyTitle: string; | 14 | emptyTitle: string; |
| 10 | emptyDescription?: string; | 15 | emptyDescription?: string; |
| 11 | onUpdate: (id: string, values: { title: string; content: string }) => Promise<void>; | 16 | onUpdate: (id: string, values: { title: string; content: string }) => Promise<void>; |
| @@ -30,6 +35,7 @@ export function NoteList(props: { | |||
| 30 | <li class="animate-fade-up"> | 35 | <li class="animate-fade-up"> |
| 31 | <NoteCard | 36 | <NoteCard |
| 32 | note={note} | 37 | note={note} |
| 38 | + canManage={props.canManage} | ||
| 33 | onOpen={setReadingNote} | 39 | onOpen={setReadingNote} |
| 34 | onUpdate={props.onUpdate} | 40 | onUpdate={props.onUpdate} |
| 35 | onDelete={props.onDelete} | 41 | onDelete={props.onDelete} |
| @@ -42,6 +48,8 @@ export function NoteList(props: { | |||
| 42 | 48 | ||
| 43 | <NoteReaderPanel | 49 | <NoteReaderPanel |
| 44 | note={readingNote()} | 50 | note={readingNote()} |
| 51 | + source={props.source} | ||
| 52 | + canManage={props.canManage} | ||
| 45 | open={readingNote() != null} | 53 | open={readingNote() != null} |
| 46 | onOpenChange={(open) => { | 54 | onOpenChange={(open) => { |
| 47 | if (!open) setReadingNote(null); | 55 | if (!open) setReadingNote(null); |
src/components/notes/note-reader-panel.tsxmodified+5 -1
| @@ -1,11 +1,15 @@ | |||
| 1 | import { Show } from "solid-js"; | 1 | import { Show } from "solid-js"; |
| 2 | import type { Note } from "@/api/client"; | 2 | import type { Note } from "@/api/client"; |
| 3 | +import type { NoteFileSource } from "@/lib/note-source"; | ||
| 3 | import { NoteFilesPanel } from "@/components/notes/note-files-panel"; | 4 | import { NoteFilesPanel } from "@/components/notes/note-files-panel"; |
| 4 | import { SidePanel } from "@/components/ui/side-panel"; | 5 | import { SidePanel } from "@/components/ui/side-panel"; |
| 5 | import { useT } from "@/stores/preferences-context"; | 6 | import { useT } from "@/stores/preferences-context"; |
| 6 | 7 | ||
| 7 | export function NoteReaderPanel(props: { | 8 | export function NoteReaderPanel(props: { |
| 8 | note: Note | null; | 9 | note: Note | null; |
| 10 | + source: NoteFileSource; | ||
| 11 | + /** Read-only file section when false. Defaults to true. */ | ||
| 12 | + canManage?: boolean; | ||
| 9 | open: boolean; | 13 | open: boolean; |
| 10 | onOpenChange: (open: boolean) => void; | 14 | onOpenChange: (open: boolean) => void; |
| 11 | }) { | 15 | }) { |
| @@ -32,7 +36,7 @@ export function NoteReaderPanel(props: { | |||
| 32 | </Show> | 36 | </Show> |
| 33 | </div> | 37 | </div> |
| 34 | </article> | 38 | </article> |
| 35 | - <NoteFilesPanel noteId={n().id} active={props.open} /> | 39 | + <NoteFilesPanel noteId={n().id} source={props.source} canManage={props.canManage} active={props.open} /> |
| 36 | </div> | 40 | </div> |
| 37 | )} | 41 | )} |
| 38 | </Show> | 42 | </Show> |
src/i18n/messages.tsmodified+18 -0
| @@ -531,6 +531,12 @@ export type MessageKey = | |||
| 531 | | "dashboard.quickReview.placeholder" | 531 | | "dashboard.quickReview.placeholder" |
| 532 | | "dashboard.quickReview.practice" | 532 | | "dashboard.quickReview.practice" |
| 533 | | "dashboard.quickReview.startQuiz" | 533 | | "dashboard.quickReview.startQuiz" |
| 534 | + | "courseNotes.title" | ||
| 535 | + | "courseNotes.item" | ||
| 536 | + | "courseNotes.new" | ||
| 537 | + | "courseNotes.add" | ||
| 538 | + | "courseNotes.empty" | ||
| 539 | + | "courseNotes.emptyManageHint" | ||
| 534 | | "notes.title" | 540 | | "notes.title" |
| 535 | | "notes.subtitle" | 541 | | "notes.subtitle" |
| 536 | | "notes.new" | 542 | | "notes.new" |
| @@ -2056,6 +2062,12 @@ const en: Dict = { | |||
| 2056 | "dashboard.quickReview.placeholder": "Choose a topic to review…", | 2062 | "dashboard.quickReview.placeholder": "Choose a topic to review…", |
| 2057 | "dashboard.quickReview.practice": "Practice", | 2063 | "dashboard.quickReview.practice": "Practice", |
| 2058 | "dashboard.quickReview.startQuiz": "Start quiz", | 2064 | "dashboard.quickReview.startQuiz": "Start quiz", |
| 2065 | + "courseNotes.title": "Lesson notes", | ||
| 2066 | + "courseNotes.item": "lesson note", | ||
| 2067 | + "courseNotes.new": "New lesson note", | ||
| 2068 | + "courseNotes.add": "Add note", | ||
| 2069 | + "courseNotes.empty": "No notes on this course yet.", | ||
| 2070 | + "courseNotes.emptyManageHint": "Write a note the whole class can read, and attach files to it.", | ||
| 2059 | "notes.title": "Notebook", | 2071 | "notes.title": "Notebook", |
| 2060 | "notes.subtitle": "Your private notebook for class ideas and reminders.", | 2072 | "notes.subtitle": "Your private notebook for class ideas and reminders.", |
| 2061 | "notes.new": "New note", | 2073 | "notes.new": "New note", |
| @@ -3587,6 +3599,12 @@ const tr: Dict = { | |||
| 3587 | "dashboard.quickReview.placeholder": "Tekrar için konu seç…", | 3599 | "dashboard.quickReview.placeholder": "Tekrar için konu seç…", |
| 3588 | "dashboard.quickReview.practice": "Alıştır", | 3600 | "dashboard.quickReview.practice": "Alıştır", |
| 3589 | "dashboard.quickReview.startQuiz": "Teste başla", | 3601 | "dashboard.quickReview.startQuiz": "Teste başla", |
| 3602 | + "courseNotes.title": "Ders notları", | ||
| 3603 | + "courseNotes.item": "ders notu", | ||
| 3604 | + "courseNotes.new": "Yeni ders notu", | ||
| 3605 | + "courseNotes.add": "Not ekle", | ||
| 3606 | + "courseNotes.empty": "Bu derse ait henüz not yok.", | ||
| 3607 | + "courseNotes.emptyManageHint": "Tüm sınıfın okuyabileceği bir not yazın, dosya da ekleyebilirsiniz.", | ||
| 3590 | "notes.title": "Defter", | 3608 | "notes.title": "Defter", |
| 3591 | "notes.subtitle": "Ders fikirleriniz ve hatırlatmalarınız için özel defteriniz.", | 3609 | "notes.subtitle": "Ders fikirleriniz ve hatırlatmalarınız için özel defteriniz.", |
| 3592 | "notes.new": "Yeni not", | 3610 | "notes.new": "Yeni not", |
src/lib/note-source.tsadded+37 -0
| @@ -0,0 +1,37 @@ | |||
| 1 | +import type { NoteFile, Page, PageParams } from "@/api/client"; | ||
| 2 | +import { deleteCourseNoteFileById, getCourseNoteFileBlob, getCourseNoteFileUrl, getCourseNoteFiles, postCourseNoteFile } from "@/api/course-notes"; | ||
| 3 | +import { deleteNoteFileById, getNoteFileBlob, getNoteFileUrl, getNoteFiles, postNoteFile } from "@/api/notes"; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * The file routes behind a note. `/notes` (personal) and `/course-notes` (a | ||
| 7 | + * course's notes) expose the same five operations over the same `NoteFile` | ||
| 8 | + * shape, so the note components take one of these instead of importing a | ||
| 9 | + * single domain's API directly. | ||
| 10 | + */ | ||
| 11 | +export type NoteFileSource = { | ||
| 12 | + /** Backend cap per note: MAX_NOTE_FILES / MAX_COURSE_NOTE_FILES, both 10. */ | ||
| 13 | + maxFiles: number; | ||
| 14 | + listFiles: (noteId: string, params?: PageParams, signal?: AbortSignal) => Promise<Page<NoteFile>>; | ||
| 15 | + uploadFile: (noteId: string, file: File, signal?: AbortSignal) => Promise<NoteFile>; | ||
| 16 | + deleteFile: (noteId: string, fileId: string) => Promise<void>; | ||
| 17 | + fileUrl: (noteId: string, fileId: string) => string; | ||
| 18 | + fileBlob: (noteId: string, fileId: string, signal?: AbortSignal) => Promise<Blob>; | ||
| 19 | +}; | ||
| 20 | + | ||
| 21 | +export const personalNoteFiles: NoteFileSource = { | ||
| 22 | + maxFiles: 10, | ||
| 23 | + listFiles: getNoteFiles, | ||
| 24 | + uploadFile: postNoteFile, | ||
| 25 | + deleteFile: deleteNoteFileById, | ||
| 26 | + fileUrl: getNoteFileUrl, | ||
| 27 | + fileBlob: getNoteFileBlob, | ||
| 28 | +}; | ||
| 29 | + | ||
| 30 | +export const courseNoteFiles: NoteFileSource = { | ||
| 31 | + maxFiles: 10, | ||
| 32 | + listFiles: getCourseNoteFiles, | ||
| 33 | + uploadFile: postCourseNoteFile, | ||
| 34 | + deleteFile: deleteCourseNoteFileById, | ||
| 35 | + fileUrl: getCourseNoteFileUrl, | ||
| 36 | + fileBlob: getCourseNoteFileBlob, | ||
| 37 | +}; | ||
src/pages/course-detail-page.tsxmodified+14 -2
| @@ -19,6 +19,7 @@ import { patchExamById } from "@/api/exams"; | |||
| 19 | import { ExamLink } from "@/components/exams/exam-link"; | 19 | import { ExamLink } from "@/components/exams/exam-link"; |
| 20 | import { ExamForm, type ExamFormValues } from "@/components/exams/exam-form"; | 20 | import { ExamForm, type ExamFormValues } from "@/components/exams/exam-form"; |
| 21 | import { ExamQuestionsPanel } from "@/components/exams/exam-questions-panel"; | 21 | import { ExamQuestionsPanel } from "@/components/exams/exam-questions-panel"; |
| 22 | +import { CourseNotesPanel } from "@/components/courses/course-notes-panel"; | ||
| 22 | import { CourseSubjectsPanel } from "@/components/courses/course-subjects-panel"; | 23 | import { CourseSubjectsPanel } from "@/components/courses/course-subjects-panel"; |
| 23 | import { CourseTeachersPanel } from "@/components/courses/course-teachers-panel"; | 24 | import { CourseTeachersPanel } from "@/components/courses/course-teachers-panel"; |
| 24 | import { CourseHomeworkPanel } from "@/components/homework/course-homework-panel"; | 25 | import { CourseHomeworkPanel } from "@/components/homework/course-homework-panel"; |
| @@ -31,7 +32,7 @@ import { Button } from "@/components/ui/button"; | |||
| 31 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 32 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 32 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | 33 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 33 | import { EmptyState } from "@/components/ui/empty-state"; | 34 | import { EmptyState } from "@/components/ui/empty-state"; |
| 34 | -import { IconBook, IconCalendarDays, IconEdit, IconExam, IconHomework, IconPlus, IconSchool, IconTrash, IconUsers } from "@/components/ui/icons"; | 35 | +import { IconBook, IconCalendarDays, IconEdit, IconExam, IconHomework, IconNote, IconPlus, IconSchool, IconTrash, IconUsers } from "@/components/ui/icons"; |
| 35 | import { createFlash } from "@/lib/flash"; | 36 | import { createFlash } from "@/lib/flash"; |
| 36 | import { cn } from "@/lib/cn"; | 37 | import { cn } from "@/lib/cn"; |
| 37 | import { Input } from "@/components/ui/input"; | 38 | import { Input } from "@/components/ui/input"; |
| @@ -118,10 +119,12 @@ function CourseDetailContent() { | |||
| 118 | const [showSessionForm, setShowSessionForm] = createSignal(false); | 119 | const [showSessionForm, setShowSessionForm] = createSignal(false); |
| 119 | const [showHomeworkForm, setShowHomeworkForm] = createSignal(false); | 120 | const [showHomeworkForm, setShowHomeworkForm] = createSignal(false); |
| 120 | const [showTeacherForm, setShowTeacherForm] = createSignal(false); | 121 | const [showTeacherForm, setShowTeacherForm] = createSignal(false); |
| 122 | + const [showNoteForm, setShowNoteForm] = createSignal(false); | ||
| 121 | const [showEnrollPanel, setShowEnrollPanel] = createSignal(false); | 123 | const [showEnrollPanel, setShowEnrollPanel] = createSignal(false); |
| 122 | const [subjectCount, setSubjectCount] = createSignal(0); | 124 | const [subjectCount, setSubjectCount] = createSignal(0); |
| 123 | const [sessionCount, setSessionCount] = createSignal(0); | 125 | const [sessionCount, setSessionCount] = createSignal(0); |
| 124 | const [homeworkCount, setHomeworkCount] = createSignal(0); | 126 | const [homeworkCount, setHomeworkCount] = createSignal(0); |
| 127 | + const [noteCount, setNoteCount] = createSignal(0); | ||
| 125 | const [enrollUserId, setEnrollUserId] = createSignal(""); | 128 | const [enrollUserId, setEnrollUserId] = createSignal(""); |
| 126 | const [error, setError] = createSignal(""); | 129 | const [error, setError] = createSignal(""); |
| 127 | const [pending, setPending] = createSignal(false); | 130 | const [pending, setPending] = createSignal(false); |
| @@ -599,11 +602,12 @@ function CourseDetailContent() { | |||
| 599 | )} | 602 | )} |
| 600 | 603 | ||
| 601 | <Tabs value={courseTab()} onChange={setCourseTab} class="space-y-4"> | 604 | <Tabs value={courseTab()} onChange={setCourseTab} class="space-y-4"> |
| 602 | - <TabsList class="grid w-full grid-cols-2 sm:grid-cols-3 xl:grid-cols-6" aria-label={c().title}> | 605 | + <TabsList class="grid w-full grid-cols-2 sm:grid-cols-3 xl:grid-cols-7" aria-label={c().title}> |
| 603 | <TabsTrigger value="subjects" class="min-w-0"><IconBook class="h-4 w-4" />{t("subjects.title")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{subjectCount()}</Badge></TabsTrigger> | 606 | <TabsTrigger value="subjects" class="min-w-0"><IconBook class="h-4 w-4" />{t("subjects.title")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{subjectCount()}</Badge></TabsTrigger> |
| 604 | <TabsTrigger value="exams" class="min-w-0"><IconExam class="h-4 w-4" />{t("courses.exams")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{examCount()}</Badge></TabsTrigger> | 607 | <TabsTrigger value="exams" class="min-w-0"><IconExam class="h-4 w-4" />{t("courses.exams")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{examCount()}</Badge></TabsTrigger> |
| 605 | <TabsTrigger value="homework" class="min-w-0"><IconHomework class="h-4 w-4" />{t("homework.title")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{homeworkCount()}</Badge></TabsTrigger> | 608 | <TabsTrigger value="homework" class="min-w-0"><IconHomework class="h-4 w-4" />{t("homework.title")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{homeworkCount()}</Badge></TabsTrigger> |
| 606 | <TabsTrigger value="sessions" class="min-w-0"><IconCalendarDays class="h-4 w-4" />{t("sessions.title")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{sessionCount()}</Badge></TabsTrigger> | 609 | <TabsTrigger value="sessions" class="min-w-0"><IconCalendarDays class="h-4 w-4" />{t("sessions.title")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{sessionCount()}</Badge></TabsTrigger> |
| 610 | + <TabsTrigger value="notes" class="min-w-0"><IconNote class="h-4 w-4" />{t("courseNotes.title")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{noteCount()}</Badge></TabsTrigger> | ||
| 607 | <TabsTrigger value="teachers" class="min-w-0"><IconSchool class="h-4 w-4" />{t("courses.teachers")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{assignedTeacherCount()}</Badge></TabsTrigger> | 611 | <TabsTrigger value="teachers" class="min-w-0"><IconSchool class="h-4 w-4" />{t("courses.teachers")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{assignedTeacherCount()}</Badge></TabsTrigger> |
| 608 | <Show when={hasCourseManagementRights()}> | 612 | <Show when={hasCourseManagementRights()}> |
| 609 | <TabsTrigger value="students" class="min-w-0"><IconUsers class="h-4 w-4" />{t("courses.roster")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{rosterCount()}</Badge></TabsTrigger> | 613 | <TabsTrigger value="students" class="min-w-0"><IconUsers class="h-4 w-4" />{t("courses.roster")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[10px] group-data-selected:bg-background group-data-selected:text-foreground">{rosterCount()}</Badge></TabsTrigger> |
| @@ -647,6 +651,14 @@ function CourseDetailContent() { | |||
| 647 | <CourseSessionsPanel courseId={id()} roster={roster() ?? []} canManage={canManage()} active={courseTab() === "sessions"} createOpen={showSessionForm()} onCreateOpenChange={setShowSessionForm} onCountChange={setSessionCount} /> | 651 | <CourseSessionsPanel courseId={id()} roster={roster() ?? []} canManage={canManage()} active={courseTab() === "sessions"} createOpen={showSessionForm()} onCreateOpenChange={setShowSessionForm} onCountChange={setSessionCount} /> |
| 648 | </TabsContent> | 652 | </TabsContent> |
| 649 | 653 | ||
| 654 | + <TabsContent value="notes" class="space-y-3"> | ||
| 655 | + <div class="flex flex-wrap items-center gap-2"> | ||
| 656 | + <Badge variant="secondary" class="rounded-full">{countDescription(noteCount(), t("courseNotes.item"))}</Badge> | ||
| 657 | + <Show when={canManage()}><Button type="button" variant="outline" size="sm" class="ml-auto rounded-lg" onClick={() => setShowNoteForm(true)}><IconPlus class="h-4 w-4" />{t("courseNotes.add")}</Button></Show> | ||
| 658 | + </div> | ||
| 659 | + <CourseNotesPanel courseId={id()} canManage={canManage()} active={courseTab() === "notes"} createOpen={showNoteForm()} onCreateOpenChange={setShowNoteForm} onCountChange={setNoteCount} /> | ||
| 660 | + </TabsContent> | ||
| 661 | + | ||
| 650 | <TabsContent value="teachers" class="space-y-3"> | 662 | <TabsContent value="teachers" class="space-y-3"> |
| 651 | <div class="flex flex-wrap items-center gap-2 text-sm"> | 663 | <div class="flex flex-wrap items-center gap-2 text-sm"> |
| 652 | <Badge variant="secondary" class="rounded-full">{countDescription(assignedTeacherCount(), t("courses.teachers"))}</Badge> | 664 | <Badge variant="secondary" class="rounded-full">{countDescription(assignedTeacherCount(), t("courses.teachers"))}</Badge> |
src/pages/notes-page.tsxmodified+2 -0
| @@ -19,6 +19,7 @@ import { PaginationControls } from "@/components/ui/pagination-controls"; | |||
| 19 | import { SidePanel } from "@/components/ui/side-panel"; | 19 | import { SidePanel } from "@/components/ui/side-panel"; |
| 20 | import { createFlash } from "@/lib/flash"; | 20 | import { createFlash } from "@/lib/flash"; |
| 21 | import { loadListPage, totalPages as pagesOf } from "@/lib/list-page"; | 21 | import { loadListPage, totalPages as pagesOf } from "@/lib/list-page"; |
| 22 | +import { personalNoteFiles } from "@/lib/note-source"; | ||
| 22 | import { useT } from "@/stores/preferences-context"; | 23 | import { useT } from "@/stores/preferences-context"; |
| 23 | 24 | ||
| 24 | const NOTE_PAGE_SIZE = 10; | 25 | const NOTE_PAGE_SIZE = 10; |
| @@ -154,6 +155,7 @@ function NotesContent() { | |||
| 154 | <Show when={list()}> | 155 | <Show when={list()}> |
| 155 | <NoteList | 156 | <NoteList |
| 156 | notes={pageItems()} | 157 | notes={pageItems()} |
| 158 | + source={personalNoteFiles} | ||
| 157 | emptyTitle={t("dashboard.emptyNotesTitle")} | 159 | emptyTitle={t("dashboard.emptyNotesTitle")} |
| 158 | emptyDescription={t("notes.empty")} | 160 | emptyDescription={t("notes.empty")} |
| 159 | onUpdate={(id, values) => | 161 | onUpdate={(id, values) => |