Skip to content

Commit 36e38f5

Browse files
committed
chore: quote data in table
1 parent aee3d27 commit 36e38f5

File tree

3 files changed

+55
-6
lines changed

3 files changed

+55
-6
lines changed

src/components/Breadcrumbs.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from "@/components/ui/breadcrumb"
1010
import { Link } from "react-router"
1111

12-
export function Breadcrumbs({ children }: PropsWithChildren<unknown>) {
12+
export function Breadcrumbs({ parents, children }: PropsWithChildren<{ parents?: React.ReactNode[] }>) {
1313
return (
1414
<Breadcrumb>
1515
<BreadcrumbList>
@@ -19,6 +19,20 @@ export function Breadcrumbs({ children }: PropsWithChildren<unknown>) {
1919
</BreadcrumbLink>
2020
</BreadcrumbItem>
2121
<BreadcrumbSeparator />
22+
{parents && (
23+
<>
24+
{parents.map((it, index) => (
25+
<>
26+
<BreadcrumbItem key={index}>
27+
<BreadcrumbLink asChild>
28+
<Link to="/">{it}</Link>
29+
</BreadcrumbLink>
30+
</BreadcrumbItem>
31+
<BreadcrumbSeparator />
32+
</>
33+
))}
34+
</>
35+
)}
2236
<BreadcrumbItem>
2337
<BreadcrumbPage>{children}</BreadcrumbPage>
2438
</BreadcrumbItem>

src/pages/quotes/QuotePage.tsx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Breadcrumbs } from "@/components/Breadcrumbs"
22
import { PageTitle } from "@/components/PageTitle"
33
import { Skeleton } from "@/components/ui/skeleton"
4+
import { Table, TableBody, TableCell, TableRow } from "@/components/ui/table"
45
import { InfoReply } from "@/generated/client"
56
import useApiClient from "@/hooks/use-api-client"
67
import useLocalStorage from "@/hooks/use-local-storage"
78
import { useSuspenseQuery } from "@tanstack/react-query"
89
import { Suspense } from "react"
9-
import { useParams } from "react-router"
10+
import { Link, useParams } from "react-router"
1011

1112
function Loader() {
1213
return (
@@ -20,7 +21,26 @@ function Quote({ value }: { value: InfoReply }) {
2021
return (
2122
<>
2223
<div className="flex flex-col gap-1">
23-
<div className="flex-1">{value.id}</div>
24+
<Table>
25+
<TableBody>
26+
<TableRow>
27+
<TableCell>id: </TableCell>
28+
<TableCell>{value.id}</TableCell>
29+
</TableRow>
30+
<TableRow>
31+
<TableCell>status: </TableCell>
32+
<TableCell>{value.status}</TableCell>
33+
</TableRow>
34+
<TableRow>
35+
<TableCell>endorser: </TableCell>
36+
<TableCell>{value.endorser || "(empty)"}</TableCell>
37+
</TableRow>
38+
<TableRow>
39+
<TableCell>bill: </TableCell>
40+
<TableCell>{value.bill || "(empty)"}</TableCell>
41+
</TableRow>
42+
</TableBody>
43+
</Table>
2444
</div>
2545
</>
2646
)
@@ -87,7 +107,15 @@ export default function QuotePage() {
87107

88108
return (
89109
<>
90-
<Breadcrumbs>Quote {id}</Breadcrumbs>
110+
<Breadcrumbs
111+
parents={[
112+
<>
113+
<Link to="/quotes">Quotes</Link>
114+
</>,
115+
]}
116+
>
117+
{id}
118+
</Breadcrumbs>
91119
<PageTitle>Quote {id}</PageTitle>
92120
<Suspense fallback={<Loader />}>
93121
<PageBody id={id} />

src/pages/quotes/QuotesPage.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import useLocalStorage from "@/hooks/use-local-storage"
88
import { useSuspenseQuery } from "@tanstack/react-query"
99
import { ViewIcon } from "lucide-react"
1010
import { Suspense } from "react"
11+
import { Link, useNavigate } from "react-router"
1112

1213
function Loader() {
1314
return (
@@ -35,6 +36,7 @@ function QuoteListPendingRaw() {
3536
}
3637

3738
function QuoteListPending() {
39+
const navigate = useNavigate()
3840
const client = useApiClient()
3941

4042
const { data } = useSuspenseQuery({
@@ -49,8 +51,13 @@ function QuoteListPending() {
4951
data.data.quotes.map((it, index) => {
5052
return (
5153
<div key={index} className="flex gap-1 items-center text-sm">
52-
<span>{it}</span>
53-
<Button size="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+
>
5461
<ViewIcon />
5562
</Button>
5663
</div>

0 commit comments

Comments
 (0)