blob: f053ab9c35043921a15173675e68722ec80a1bce (
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
26
27
28
29
30
31
|
import { apiClient } from "../api/client";
import { createReloadableAtomFamily } from "./utils";
export interface Card {
id: string;
deckId: string;
noteId: string;
isReversed: boolean;
front: string;
back: string;
state: number;
due: string;
reps: number;
lapses: number;
createdAt: string;
updatedAt: string;
}
// =====================
// Cards by Deck - Suspense-compatible
// =====================
export const cardsByDeckAtomFamily = createReloadableAtomFamily(
async (deckId: string) => {
const res = await apiClient.rpc.api.decks[":deckId"].cards.$get({
param: { deckId },
});
const data = await apiClient.handleResponse<{ cards: Card[] }>(res);
return data.cards;
},
);
|