Skip to content

Commit c6a7e6b

Browse files
committed
chore: use mocks db
1 parent 9c71d53 commit c6a7e6b

File tree

2 files changed

+60
-10
lines changed

2 files changed

+60
-10
lines changed

src/mocks/db.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,66 @@ export const db = factory({
77
pubkey: nullable(String),
88
version: nullable(String),
99
},
10+
quotes: {
11+
id: primaryKey(String),
12+
bill: nullable(String),
13+
endorser: nullable(String),
14+
status: nullable(String),
15+
submitted: nullable(String), // pending
16+
suggested_expiration: nullable(String), // pending
17+
ttl: nullable(String), // offered
18+
signatures: Array<string>, // accepted
19+
tstamp: nullable(String) // rejected
20+
}
1021
})
1122

1223
db.info.create({
24+
id: "0283bf290884eed3a7ca2663fc0260de2e2064d6b355ea13f98dec004b7a7ead99",
1325
name: "Bob's Wildcat mint",
1426
pubkey: "0283bf290884eed3a7ca2663fc0260de2e2064d6b355ea13f98dec004b7a7ead99",
1527
version: "Nutshell/0.15.0",
1628
})
29+
30+
db.quotes.create({
31+
id: "63777d15-ce53-4cca-94bf-7726c7930aab",
32+
status: "pending",
33+
})
34+
35+
db.quotes.create({
36+
id: "cd3fc93c-4507-4154-b51b-215b6f360a53",
37+
status: "pending",
38+
})
39+
40+
db.quotes.create({
41+
id: "d20ab61f-03c5-479f-930b-b6aca608b1e6",
42+
status: "pending",
43+
})
44+
45+
db.quotes.create({
46+
id: "57330ad9-30b1-45a7-b900-a37be37005d3",
47+
status: "offered",
48+
})
49+
50+
db.quotes.create({
51+
id: "62ea00be-66f2-4b04-b2c4-257d7409ce9f",
52+
status: "offered",
53+
})
54+
55+
db.quotes.create({
56+
id: "825e4fa8-dab3-4072-bb76-d58a975154af",
57+
status: "accepted",
58+
})
59+
60+
db.quotes.create({
61+
id: "0e96e7cc-4327-41c6-87bf-8096fd880117",
62+
status: "accepted",
63+
})
64+
65+
db.quotes.create({
66+
id: "38b835a4-dc5d-4433-8592-81c49c94d505",
67+
status: "rejected",
68+
})
69+
db.quotes.create({
70+
id: "2f5bc589-9bca-4899-adbf-76c881a4e418",
71+
status: "rejected",
72+
})

src/mocks/handlers/admin_quotes.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,17 @@ import { http, delay, HttpResponse } from "msw"
22
import { API_URL } from "@/constants/api"
33
import { ADMIN_QUOTE_PENDING } from "@/constants/endpoints"
44
import { ListPendingQuotesResponse } from "@/generated/client"
5+
import { db } from "../db"
56

67
export const fetchAdminQuotePending = http.get<never, never, ListPendingQuotesResponse>(
78
`${API_URL}${ADMIN_QUOTE_PENDING}`,
89
async () => {
910
await delay(1_000)
1011

12+
const data = db.quotes.getAll().filter((it) => it.status === 'pending');
13+
1114
return HttpResponse.json({
12-
quotes: [
13-
"63777d15-ce53-4cca-94bf-7726c7930aab",
14-
"cd3fc93c-4507-4154-b51b-215b6f360a53",
15-
"d20ab61f-03c5-479f-930b-b6aca608b1e6",
16-
"57330ad9-30b1-45a7-b900-a37be37005d3",
17-
"62ea00be-66f2-4b04-b2c4-257d7409ce9f",
18-
"597d3d44-4a65-4c87-8d50-628acda245f5",
19-
"0e96e7cc-4327-41c6-87bf-8096fd880117",
20-
"2f5bc589-9bca-4899-adbf-76c881a4e418",
21-
],
15+
quotes: data.map((it) => it.id),
2216
})
2317
},
2418
)

0 commit comments

Comments
 (0)