blob: fb99b14480450b786ef0a3e67a617bb97d103d59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import { atomWithSuspenseQuery } from "jotai-tanstack-query";
import { apiClient } from "../api/client";
export interface NoteType {
id: string;
name: string;
frontTemplate: string;
backTemplate: string;
isReversible: boolean;
createdAt: string;
updatedAt: string;
}
// =====================
// NoteTypes List - Suspense-compatible
// =====================
export const noteTypesAtom = atomWithSuspenseQuery(() => ({
queryKey: ["noteTypes"],
queryFn: async () => {
const res = await apiClient.rpc.api["note-types"].$get();
const data = await apiClient.handleResponse<{ noteTypes: NoteType[] }>(res);
return data.noteTypes;
},
}));
|