refactor: add error components at page level

This commit is contained in:
Nicolas Meienberger 2026-02-28 17:05:23 +01:00
parent 39469cb08b
commit e86fcf1b9a
18 changed files with 20 additions and 8 deletions

View file

@ -3,6 +3,7 @@ import { DownloadRecoveryKeyPage } from "~/client/modules/auth/routes/download-r
export const Route = createFileRoute("/(auth)/download-recovery-key")({
component: DownloadRecoveryKeyPage,
errorComponent: () => <div>Failed to load recovery key</div>,
head: () => ({
meta: [
{ title: "Zerobyte - Download Recovery Key" },

View file

@ -4,6 +4,7 @@ import { LoginPage } from "~/client/modules/auth/routes/login";
export const Route = createFileRoute("/(auth)/login/error")({
component: RouteComponent,
errorComponent: () => <div>Failed to load login error</div>,
validateSearch: type({ error: "string?" }),
head: () => ({
meta: [

View file

@ -4,6 +4,7 @@ import { LoginPage } from "~/client/modules/auth/routes/login";
export const Route = createFileRoute("/(auth)/login")({
component: RouteComponent,
errorComponent: () => <div>Failed to load login</div>,
validateSearch: type({ error: "string?" }),
head: () => ({
meta: [

View file

@ -3,6 +3,7 @@ import { OnboardingPage } from "~/client/modules/auth/routes/onboarding";
export const Route = createFileRoute("/(auth)/onboarding")({
component: OnboardingPage,
errorComponent: () => <div>Failed to load onboarding</div>,
head: () => ({
meta: [
{ title: "Zerobyte - Onboarding" },

View file

@ -3,6 +3,7 @@ import { authMiddleware } from "~/middleware/auth";
export const Route = createFileRoute("/(auth)")({
component: () => <Outlet />,
errorComponent: () => <div>Failed to load auth</div>,
server: {
middleware: [authMiddleware],
},

View file

@ -8,6 +8,7 @@ import { getAdminUsersOptions, getRegistrationStatusOptions } from "~/client/api
export const Route = createFileRoute("/(dashboard)/admin/")({
validateSearch: type({ tab: "string?" }),
component: RouteComponent,
errorComponent: () => <div>Failed to load admin</div>,
loader: async ({ context }) => {
const authContext = await fetchUser();

View file

@ -6,6 +6,7 @@ import { getVolumeMountPath } from "~/client/lib/volume-path";
export const Route = createFileRoute("/(dashboard)/backups/$backupId/$snapshotId/restore")({
component: RouteComponent,
errorComponent: () => <div>Failed to load restore</div>,
loader: async ({ params, context }) => {
const schedule = await getBackupSchedule({ path: { shortId: params.backupId } });

View file

@ -13,6 +13,7 @@ import { prefetchOrSkip } from "~/utils/prefetch";
export const Route = createFileRoute("/(dashboard)/backups/$backupId/")({
component: RouteComponent,
errorComponent: () => <div>Failed to load backup</div>,
validateSearch: type({ snapshot: "string?" }),
loader: async ({ params, context }) => {
const { backupId } = params;

View file

@ -3,6 +3,7 @@ import { listRepositoriesOptions, listVolumesOptions } from "~/client/api-client
import { CreateBackupPage } from "~/client/modules/backups/routes/create-backup";
export const Route = createFileRoute("/(dashboard)/backups/create")({
errorComponent: () => <div>Failed to load backup creation</div>,
loader: async ({ context }) => {
await Promise.all([
context.queryClient.ensureQueryData({ ...listVolumesOptions() }),

View file

@ -4,6 +4,7 @@ import { BackupsPage } from "~/client/modules/backups/routes/backups";
export const Route = createFileRoute("/(dashboard)/backups/")({
component: RouteComponent,
errorComponent: () => <div>Failed to load backups</div>,
loader: async ({ context }) => {
await context.queryClient.ensureQueryData({
...listBackupSchedulesOptions(),

View file

@ -4,6 +4,7 @@ import { NotificationDetailsPage } from "~/client/modules/notifications/routes/n
export const Route = createFileRoute("/(dashboard)/notifications/$notificationId")({
component: RouteComponent,
errorComponent: () => <div>Failed to load notification</div>,
loader: async ({ params, context }) => {
const res = await context.queryClient.ensureQueryData({
...getNotificationDestinationOptions({ path: { id: params.notificationId } }),

View file

@ -3,11 +3,9 @@ import { CreateNotificationPage } from "~/client/modules/notifications/routes/cr
export const Route = createFileRoute("/(dashboard)/notifications/create")({
component: RouteComponent,
errorComponent: () => <div>Failed to load notification creation</div>,
staticData: {
breadcrumb: () => [
{ label: "Notifications", href: "/notifications" },
{ label: "Create" },
],
breadcrumb: () => [{ label: "Notifications", href: "/notifications" }, { label: "Create" }],
},
head: () => ({
meta: [

View file

@ -4,6 +4,7 @@ import { NotificationsPage } from "~/client/modules/notifications/routes/notific
export const Route = createFileRoute("/(dashboard)/notifications/")({
component: RouteComponent,
errorComponent: () => <div>Failed to load notifications</div>,
loader: async ({ context }) => {
await context.queryClient.ensureQueryData({ ...listNotificationDestinationsOptions() });
},

View file

@ -3,11 +3,9 @@ import { CreateRepositoryPage } from "~/client/modules/repositories/routes/creat
export const Route = createFileRoute("/(dashboard)/repositories/create")({
component: RouteComponent,
errorComponent: () => <div>Failed to load repository creation</div>,
staticData: {
breadcrumb: () => [
{ label: "Repositories", href: "/repositories" },
{ label: "Create" },
],
breadcrumb: () => [{ label: "Repositories", href: "/repositories" }, { label: "Create" }],
},
head: () => ({
meta: [

View file

@ -10,6 +10,7 @@ import { getOrganizationContext } from "~/server/lib/functions/organization-cont
export const Route = createFileRoute("/(dashboard)/settings/")({
component: RouteComponent,
validateSearch: type({ tab: "string?" }),
errorComponent: () => <div>Failed to load settings</div>,
loader: async ({ context }) => {
const authContext = await fetchUser();
const orgContext = await getOrganizationContext();

View file

@ -4,6 +4,7 @@ import { getOrganizationContext } from "~/server/lib/functions/organization-cont
export const Route = createFileRoute("/(dashboard)/settings/sso/new")({
component: RouteComponent,
errorComponent: () => <div>Failed to load SSO registration</div>,
loader: async () => {
const orgContext = await getOrganizationContext();
const role = orgContext.activeMember?.role;

View file

@ -3,6 +3,7 @@ import { CreateVolumePage } from "~/client/modules/volumes/routes/create-volume"
export const Route = createFileRoute("/(dashboard)/volumes/create")({
component: RouteComponent,
errorComponent: () => <div>Failed to load volume creation</div>,
staticData: {
breadcrumb: () => [{ label: "Volumes", href: "/volumes" }, { label: "Create" }],
},

View file

@ -10,6 +10,7 @@ export const Route = createFileRoute("/")({
},
],
}),
errorComponent: () => <div>Failed to load page</div>,
beforeLoad: () => {
throw redirect({ to: "/volumes" });
},