77import { Bar , BarChart , ResponsiveContainer , XAxis , YAxis } from "recharts" ;
88import { createFileRoute } from "@tanstack/react-router" ;
99
10- import { $fetch } from "@/api" ;
10+ import { fetchOverview } from "@/api" ;
1111import {
1212 Card ,
1313 CardContent ,
@@ -19,17 +19,17 @@ import { Table, TableBody, TableCell, TableRow } from "@/components/ui/table";
1919
2020export const Route = createFileRoute ( "/" ) ( {
2121 component : Index ,
22- loader : ( ) => $fetch ( "/" ) ,
22+ loader : ( ) => fetchOverview ( ) ,
2323 errorComponent : ( ) => < h1 > Error</ h1 > ,
2424} ) ;
2525
2626function Index ( ) {
27- const { data } = Route . useLoaderData ( ) ;
27+ const data = Route . useLoaderData ( ) ;
2828
2929 return (
3030 < >
3131 < h2 className = "scroll-m-20 border-b pb-2 text-3xl tracking-tight first:mt-0" >
32- Exploring < span className = "font-bold" > { data ? .file_name } </ span >
32+ Exploring < span className = "font-bold" > { data . file_name } </ span >
3333 </ h2 >
3434
3535 < div className = "grid gap-4 md:grid-cols-2 md:gap-8 lg:grid-cols-4" >
@@ -39,7 +39,7 @@ function Index() {
3939 < TableIcon className = "h-4 w-4 text-muted-foreground" />
4040 </ CardHeader >
4141 < CardContent >
42- < div className = "text-2xl font-bold" > { data ? .tables } </ div >
42+ < div className = "text-2xl font-bold" > { data . tables } </ div >
4343 < p className = "text-xs text-muted-foreground" >
4444 The number of tables in the DB.
4545 </ p >
@@ -51,7 +51,7 @@ function Index() {
5151 < DatabaseZap className = "h-4 w-4 text-muted-foreground" />
5252 </ CardHeader >
5353 < CardContent >
54- < div className = "text-2xl font-bold" > { data ? .indexes } </ div >
54+ < div className = "text-2xl font-bold" > { data . indexes } </ div >
5555 < p className = "text-xs text-muted-foreground" >
5656 The number of indexes across the whole DB.
5757 </ p >
@@ -63,7 +63,7 @@ function Index() {
6363 < TextSearch className = "h-4 w-4 text-muted-foreground" />
6464 </ CardHeader >
6565 < CardContent >
66- < div className = "text-2xl font-bold" > { data ? .views } </ div >
66+ < div className = "text-2xl font-bold" > { data . views } </ div >
6767 < p className = "text-xs text-muted-foreground" >
6868 The number of views in the DB.
6969 </ p >
@@ -75,7 +75,7 @@ function Index() {
7575 < Workflow className = "h-4 w-4 text-muted-foreground" />
7676 </ CardHeader >
7777 < CardContent >
78- < div className = "text-2xl font-bold" > { data ? .triggers } </ div >
78+ < div className = "text-2xl font-bold" > { data . triggers } </ div >
7979 < p className = "text-xs text-muted-foreground" >
8080 The number of triggers in the DB.
8181 </ p >
@@ -89,7 +89,7 @@ function Index() {
8989 < CardTitle > Rows Per Table</ CardTitle >
9090 </ CardHeader >
9191 < CardContent className = "pl-2" >
92- < TheBarChart counts = { data ? .counts ?? [ ] } />
92+ < TheBarChart counts = { data . counts } />
9393 </ CardContent >
9494 </ Card >
9595 < Card className = "xl:col-span-3" >
@@ -109,9 +109,7 @@ function Index() {
109109 The size of the DB on disk.
110110 </ div >
111111 </ TableCell >
112- < TableCell className = "text-right" >
113- { data ?. file_size }
114- </ TableCell >
112+ < TableCell className = "text-right" > { data . file_size } </ TableCell >
115113 </ TableRow >
116114
117115 < TableRow >
@@ -122,7 +120,7 @@ function Index() {
122120 </ div >
123121 </ TableCell >
124122 < TableCell className = "text-right" >
125- { data ? .sqlite_version }
123+ { data . sqlite_version }
126124 </ TableCell >
127125 </ TableRow >
128126
@@ -134,7 +132,7 @@ function Index() {
134132 </ div >
135133 </ TableCell >
136134 < TableCell className = "text-right" >
137- { data ? .created . toUTCString ( ) }
135+ { data . created . toUTCString ( ) }
138136 </ TableCell >
139137 </ TableRow >
140138
@@ -146,7 +144,7 @@ function Index() {
146144 </ div >
147145 </ TableCell >
148146 < TableCell className = "text-right" >
149- { data ? .modified . toUTCString ( ) }
147+ { data . modified . toUTCString ( ) }
150148 </ TableCell >
151149 </ TableRow >
152150 </ TableBody >
0 commit comments