import type { LoaderFunction } from "remix"; import { useLoaderData, Link, useCatch } from "remix"; import type { Expense } from "@prisma/client"; import { db } from "~/utils/db.server"; type LoaderData = { lastExpenses: Expense[] }; export const loader: LoaderFunction = async () => { const lastExpenses = await db.expense.findMany({ take: 25, orderBy: { createdAt: "desc" }, }); const data: LoaderData = { lastExpenses }; return data; }; export default function JokesIndexRoute() { const data = useLoaderData(); return (

Here show statistics

Add an expense
); } export function CatchBoundary() { const caught = useCatch(); if (caught.status === 404) { return (
There are no expenses to display.
); } throw new Error(`Unexpected caught response with status: ${caught.status}`); } export function ErrorBoundary() { return
I did a whoopsies.
; }