33 lines
773 B
TypeScript
33 lines
773 B
TypeScript
import { notFound } from "next/navigation";
|
|
import { api } from "@/server/api/client";
|
|
import { TRPCError } from "@trpc/server";
|
|
import DayView from "@/components/dashboard/days/DayView";
|
|
import LoadingSpinner from "@/components/ui/spinner";
|
|
|
|
export default async function DayPage({
|
|
params,
|
|
}: {
|
|
params: { dateQuery: string };
|
|
}) {
|
|
let day;
|
|
try {
|
|
day = await api.days.get({ dateQuery: params.dateQuery });
|
|
} catch (e) {
|
|
if (e instanceof TRPCError) {
|
|
if (e.code == "NOT_FOUND") {
|
|
notFound();
|
|
}
|
|
}
|
|
throw e;
|
|
}
|
|
|
|
return (
|
|
params.dateQuery === undefined ?
|
|
<LoadingSpinner />
|
|
:
|
|
<DayView
|
|
day={day}
|
|
/>
|
|
);
|
|
}
|