Skip to content

Commit 6aadf75

Browse files
committed
chore: use generated tanstack query options
1 parent e467cf3 commit 6aadf75

File tree

2 files changed

+30
-51
lines changed

2 files changed

+30
-51
lines changed

src/pages/quotes/QuotePage.tsx

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { PageTitle } from "@/components/PageTitle"
33
import { Skeleton } from "@/components/ui/skeleton"
44
import { Table, TableBody, TableCell, TableRow } from "@/components/ui/table"
55
import { InfoReply } from "@/generated/client"
6-
import useApiClient from "@/hooks/use-api-client"
6+
import { adminLookupQuoteOptions } from "@/generated/client/@tanstack/react-query.gen"
77
import useLocalStorage from "@/hooks/use-local-storage"
88
import { useSuspenseQuery } from "@tanstack/react-query"
99
import { Suspense } from "react"
@@ -49,16 +49,12 @@ function Quote({ value }: { value: InfoReply }) {
4949
function DevSection({ id }: { id: InfoReply["id"] }) {
5050
const [devMode] = useLocalStorage("devMode", false)
5151

52-
const client = useApiClient()
53-
5452
const { data } = useSuspenseQuery({
55-
queryKey: ["quote", id],
56-
queryFn: () =>
57-
client.adminLookupQuote({
58-
path: {
59-
id,
60-
},
61-
}),
53+
...adminLookupQuoteOptions({
54+
path: {
55+
id,
56+
},
57+
}),
6258
})
6359

6460
return (
@@ -75,25 +71,17 @@ function DevSection({ id }: { id: InfoReply["id"] }) {
7571
}
7672

7773
function PageBody({ id }: { id: InfoReply["id"] }) {
78-
const client = useApiClient()
79-
8074
const { data } = useSuspenseQuery({
81-
queryKey: ["quote", id],
82-
queryFn: () =>
83-
client.adminLookupQuote({
84-
path: {
85-
id,
86-
},
87-
}),
75+
...adminLookupQuoteOptions({
76+
path: {
77+
id,
78+
},
79+
}),
8880
})
8981

9082
return (
9183
<>
92-
{data.data && (
93-
<>
94-
<Quote value={data.data} />
95-
</>
96-
)}
84+
<Quote value={data} />
9785
</>
9886
)
9987
}

src/pages/quotes/QuotesPage.tsx

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { H3 } from "@/components/Headings"
33
import { PageTitle } from "@/components/PageTitle"
44
import { Button } from "@/components/ui/button"
55
import { Skeleton } from "@/components/ui/skeleton"
6-
import useApiClient from "@/hooks/use-api-client"
6+
import { listPendingQuotesOptions } from "@/generated/client/@tanstack/react-query.gen"
77
import useLocalStorage from "@/hooks/use-local-storage"
88
import { useSuspenseQuery } from "@tanstack/react-query"
99
import { ViewIcon } from "lucide-react"
@@ -19,11 +19,8 @@ function Loader() {
1919
}
2020

2121
function QuoteListPendingRaw() {
22-
const client = useApiClient()
23-
2422
const { data } = useSuspenseQuery({
25-
queryKey: ["quotes-pending"],
26-
queryFn: () => client.listPendingQuotes(),
23+
...listPendingQuotesOptions({}),
2724
})
2825

2926
return (
@@ -37,35 +34,29 @@ function QuoteListPendingRaw() {
3734

3835
function QuoteListPending() {
3936
const navigate = useNavigate()
40-
const client = useApiClient()
4137

4238
const { data } = useSuspenseQuery({
43-
queryKey: ["quotes-pending"],
44-
queryFn: () => client.listPendingQuotes(),
39+
...listPendingQuotesOptions({}),
4540
})
4641

4742
return (
4843
<>
4944
<div className="flex flex-col gap-1">
50-
{data.data ? (
51-
data.data.quotes.map((it, index) => {
52-
return (
53-
<div key={index} className="flex gap-1 items-center text-sm">
54-
<Link to={"/quotes/:id".replace(":id", it)}>{it}</Link>
55-
<Button
56-
size="sm"
57-
onClick={() => {
58-
void navigate("/quotes/:id".replace(":id", it))
59-
}}
60-
>
61-
<ViewIcon />
62-
</Button>
63-
</div>
64-
)
65-
})
66-
) : (
67-
<></>
68-
)}
45+
{data.quotes.map((it, index) => {
46+
return (
47+
<div key={index} className="flex gap-1 items-center text-sm">
48+
<Link to={"/quotes/:id".replace(":id", it)}>{it}</Link>
49+
<Button
50+
size="sm"
51+
onClick={() => {
52+
void navigate("/quotes/:id".replace(":id", it))
53+
}}
54+
>
55+
<ViewIcon />
56+
</Button>
57+
</div>
58+
)
59+
})}
6960
</div>
7061
</>
7162
)

0 commit comments

Comments
 (0)