Better error handling
This commit is contained in:
parent
0e8478dab1
commit
f524df7e1b
3 changed files with 28 additions and 28 deletions
|
|
@ -28,7 +28,7 @@ export default function RootLayout({
|
||||||
enableSystem
|
enableSystem
|
||||||
disableTransitionOnChange
|
disableTransitionOnChange
|
||||||
>
|
>
|
||||||
<Navbar />
|
|
||||||
{children}
|
{children}
|
||||||
<Toaster />
|
<Toaster />
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
|
|
|
||||||
53
app/page.tsx
53
app/page.tsx
|
|
@ -6,6 +6,7 @@ import { Button } from '@/components/ui/button';
|
||||||
import { useRoutes } from '@/lib/clientActions';
|
import { useRoutes } from '@/lib/clientActions';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import Loading from '@/components/Loading';
|
import Loading from '@/components/Loading';
|
||||||
|
import Error from '@/components/Error';
|
||||||
|
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
|
@ -13,32 +14,30 @@ export default function Home() {
|
||||||
const { data: routes, error, isLoading } = useRoutes();
|
const { data: routes, error, isLoading } = useRoutes();
|
||||||
let routesMap: Route[] = routes as Route[];
|
let routesMap: Route[] = routes as Route[];
|
||||||
|
|
||||||
if (error) return <div>Error loading routes</div>
|
if(error) return <Error />
|
||||||
if(isLoading) return (
|
if(isLoading) return <Loading />
|
||||||
<Loading />
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main>
|
<main>
|
||||||
<div className='flex items-center justify-center p-6'>
|
<div className='flex items-center justify-center p-6'>
|
||||||
<Card className='flex'>
|
<Card className='flex'>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>Active Routes</CardTitle>
|
<CardTitle>Active Routes</CardTitle>
|
||||||
<CardDescription>Amount of configured routes</CardDescription>
|
<CardDescription>Amount of configured routes</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className='flex items-center'>
|
<CardContent className='flex items-center'>
|
||||||
<div>
|
<div>
|
||||||
<p className='text-xl font-semibold translate-y-2'>{routesMap.length}</p>
|
<p className='text-xl font-semibold translate-y-2'>{routesMap.length}</p>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<CardFooter>
|
<CardFooter>
|
||||||
<Button className='translate-y-2.5'>Create</Button>
|
<Button className='translate-y-2.5'>Create</Button>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
<div className='grid grid-flow-row-dense md:grid-cols-6 sm:grid-cols-2 p-2'>
|
<div className='grid grid-flow-row-dense md:grid-cols-6 sm:grid-cols-2 p-2'>
|
||||||
<RouteCards routes={routes as Route[]} />
|
<RouteCards routes={routes as Route[]} />
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
"lint": "next lint"
|
"lint": "next lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@radix-ui/react-alert-dialog": "^1.0.5",
|
||||||
"@radix-ui/react-avatar": "^1.0.4",
|
"@radix-ui/react-avatar": "^1.0.4",
|
||||||
"@radix-ui/react-icons": "^1.3.0",
|
"@radix-ui/react-icons": "^1.3.0",
|
||||||
"@radix-ui/react-navigation-menu": "^1.1.4",
|
"@radix-ui/react-navigation-menu": "^1.1.4",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue