@@ -3,7 +3,7 @@ import { H3 } from "@/components/Headings"
33import { PageTitle } from "@/components/PageTitle"
44import { Button } from "@/components/ui/button"
55import { Skeleton } from "@/components/ui/skeleton"
6- import { listPendingQuotesOptions } from "@/generated/client/@tanstack/react-query.gen"
6+ import { listAcceptedQuotesOptions , listPendingQuotesOptions } from "@/generated/client/@tanstack/react-query.gen"
77import useLocalStorage from "@/hooks/use-local-storage"
88import { useSuspenseQuery } from "@tanstack/react-query"
99import { LoaderIcon } from "lucide-react"
@@ -18,32 +18,63 @@ function Loader() {
1818 )
1919}
2020
21- function QuoteListPendingRaw ( ) {
22- const { data } = useSuspenseQuery ( {
23- ...listPendingQuotesOptions ( { } ) ,
21+ function QuoteListPending ( ) {
22+ const navigate = useNavigate ( )
23+
24+ const { data, isFetching } = useSuspenseQuery ( {
25+ ...listPendingQuotesOptions ( ) ,
2426 } )
2527
2628 return (
2729 < >
28- < pre className = "text-sm bg-accent text-accent-foreground rounded-lg p-2 my-2" >
29- { JSON . stringify ( data , null , 2 ) }
30- </ pre >
30+ < H3 >
31+ < span className = "flex items-center gap-1" >
32+ < span > Pending</ span >
33+ < span > { isFetching && < LoaderIcon className = "stroke-1 animate-spin" /> } </ span >
34+ </ span >
35+ </ H3 >
36+
37+ < div className = "flex flex-col gap-1" >
38+ { data . quotes . map ( ( it , index ) => {
39+ return (
40+ < div key = { index } className = "flex gap-1 items-center text-sm" >
41+ { isFetching ? (
42+ < > { it } </ >
43+ ) : (
44+ < >
45+ < Link to = { "/quotes/:id" . replace ( ":id" , it ) } > { it } </ Link >
46+ </ >
47+ ) }
48+
49+ < Button
50+ size = "sm"
51+ disabled = { isFetching }
52+ onClick = { ( ) => {
53+ void navigate ( "/quotes/:id" . replace ( ":id" , it ) )
54+ } }
55+ >
56+ View
57+ </ Button >
58+ </ div >
59+ )
60+ } ) }
61+ </ div >
3162 </ >
3263 )
3364}
3465
35- function QuoteListPending ( ) {
66+ function QuoteListAccepted ( ) {
3667 const navigate = useNavigate ( )
3768
3869 const { data, isFetching } = useSuspenseQuery ( {
39- ...listPendingQuotesOptions ( { } ) ,
70+ ...listAcceptedQuotesOptions ( ) ,
4071 } )
4172
4273 return (
4374 < >
4475 < H3 >
4576 < span className = "flex items-center gap-1" >
46- < span > Pending </ span >
77+ < span > Accepted </ span >
4778 < span > { isFetching && < LoaderIcon className = "stroke-1 animate-spin" /> } </ span >
4879 </ span >
4980 </ H3 >
@@ -80,14 +111,36 @@ function QuoteListPending() {
80111function DevSection ( ) {
81112 const [ devMode ] = useLocalStorage ( "devMode" , false )
82113
83- return < > { devMode && < QuoteListPendingRaw /> } </ >
114+ const { data : quotesPending } = useSuspenseQuery ( {
115+ ...listPendingQuotesOptions ( { } ) ,
116+ } )
117+
118+ const { data : quotesAccepted } = useSuspenseQuery ( {
119+ ...listPendingQuotesOptions ( { } ) ,
120+ } )
121+
122+ return (
123+ < >
124+ { devMode && (
125+ < >
126+ < pre className = "text-sm bg-accent text-accent-foreground rounded-lg p-2 my-2" >
127+ { JSON . stringify ( quotesPending , null , 2 ) }
128+ </ pre >
129+ < pre className = "text-sm bg-accent text-accent-foreground rounded-lg p-2 my-2" >
130+ { JSON . stringify ( quotesAccepted , null , 2 ) }
131+ </ pre >
132+ </ >
133+ ) }
134+ </ >
135+ )
84136}
85137
86138function PageBody ( ) {
87139 return (
88140 < >
89141 < Suspense fallback = { < Loader /> } >
90142 < QuoteListPending />
143+ < QuoteListAccepted />
91144 </ Suspense >
92145 </ >
93146 )
0 commit comments