aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/client/atoms/noteTypes.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/atoms/noteTypes.ts')
-rw-r--r--src/client/atoms/noteTypes.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/client/atoms/noteTypes.ts b/src/client/atoms/noteTypes.ts
new file mode 100644
index 0000000..adc9d44
--- /dev/null
+++ b/src/client/atoms/noteTypes.ts
@@ -0,0 +1,22 @@
+import { apiClient } from "../api/client";
+import { createReloadableAtom } from "./utils";
+
+export interface NoteType {
+ id: string;
+ name: string;
+ frontTemplate: string;
+ backTemplate: string;
+ isReversible: boolean;
+ createdAt: string;
+ updatedAt: string;
+}
+
+// =====================
+// NoteTypes List - Suspense-compatible
+// =====================
+
+export const noteTypesAtom = createReloadableAtom(async () => {
+ const res = await apiClient.rpc.api["note-types"].$get();
+ const data = await apiClient.handleResponse<{ noteTypes: NoteType[] }>(res);
+ return data.noteTypes;
+});