mirror of
https://github.com/temetro/temetro.git
synced 2026-07-26 11:58:14 +00:00
ea2ecb572c
- lib/notes.ts: list/get/create/update/delete via the API client. - New /notes route + nav item (and shared lib/nav.ts entry, i18n key) so it shows in the sidebar and command palette. - components/notes/notes-view.tsx: a note list + "New note", with save/delete and toasts. - components/notes/notes-editor.tsx: a Word-like COSS Toolbar driving Tiptap (StarterKit + Placeholder) — bold/italic/underline, H1–H2, bullet/numbered lists, undo/redo — plus a title field and Save. Installed @coss/toolbar and @coss/toggle-group and the Tiptap packages. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import { apiFetch } from "@/lib/api-client";
|
|
|
|
// A doctor's note. `content` is rich-text editor HTML. Mirrors the backend
|
|
// `src/types/note.ts`. Notes are scoped to the active clinic + signed-in author.
|
|
export type Note = {
|
|
id: string;
|
|
title: string;
|
|
content: string;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
};
|
|
|
|
export type NoteInput = { title: string; content: string };
|
|
|
|
export function listNotes(): Promise<Note[]> {
|
|
return apiFetch<Note[]>("/api/notes");
|
|
}
|
|
|
|
export function getNote(id: string): Promise<Note> {
|
|
return apiFetch<Note>(`/api/notes/${id}`);
|
|
}
|
|
|
|
export function createNote(input: NoteInput): Promise<Note> {
|
|
return apiFetch<Note>("/api/notes", {
|
|
method: "POST",
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|
|
|
|
export function updateNote(id: string, input: NoteInput): Promise<Note> {
|
|
return apiFetch<Note>(`/api/notes/${id}`, {
|
|
method: "PUT",
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|
|
|
|
export function deleteNote(id: string): Promise<void> {
|
|
return apiFetch<void>(`/api/notes/${id}`, { method: "DELETE" });
|
|
}
|