From 975ff23799b977f1ccfb7a9b28abb27b5f2befb8 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Sun, 8 Feb 2026 15:54:00 +0100 Subject: [PATCH] refactor: notifications --- .../routes/create-notification.tsx | 19 ++---- .../routes/notification-details.tsx | 44 ++++-------- .../notifications/routes/notifications.tsx | 55 +++++---------- app/routeTree.gen.ts | 67 +++++++++++++++++++ .../notifications/$notificationId.tsx | 27 ++++++++ .../(dashboard)/notifications/create.tsx | 19 ++++++ .../(dashboard)/notifications/index.tsx | 23 +++++++ 7 files changed, 169 insertions(+), 85 deletions(-) create mode 100644 app/routes/(dashboard)/notifications/$notificationId.tsx create mode 100644 app/routes/(dashboard)/notifications/create.tsx create mode 100644 app/routes/(dashboard)/notifications/index.tsx diff --git a/app/client/modules/notifications/routes/create-notification.tsx b/app/client/modules/notifications/routes/create-notification.tsx index c6db625c..b70b8281 100644 --- a/app/client/modules/notifications/routes/create-notification.tsx +++ b/app/client/modules/notifications/routes/create-notification.tsx @@ -1,31 +1,20 @@ import { useMutation } from "@tanstack/react-query"; import { Bell, Plus } from "lucide-react"; import { useId } from "react"; -import { useNavigate } from "react-router"; import { toast } from "sonner"; import { createNotificationDestinationMutation } from "~/client/api-client/@tanstack/react-query.gen"; import { Button } from "~/client/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "~/client/components/ui/card"; import { parseError } from "~/client/lib/errors"; -import type { Route } from "./+types/create-notification"; import { Alert, AlertDescription } from "~/client/components/ui/alert"; import { CreateNotificationForm, type NotificationFormValues } from "../components/create-notification-form"; +import { useNavigate } from "@tanstack/react-router"; export const handle = { breadcrumb: () => [{ label: "Notifications", href: "/notifications" }, { label: "Create" }], }; -export function meta(_: Route.MetaArgs) { - return [ - { title: "Zerobyte - Create Notification" }, - { - name: "description", - content: "Create a new notification destination for backup alerts.", - }, - ]; -} - -export default function CreateNotification() { +export function CreateNotificationPage() { const navigate = useNavigate(); const formId = useId(); @@ -33,7 +22,7 @@ export default function CreateNotification() { ...createNotificationDestinationMutation(), onSuccess: () => { toast.success("Notification destination created successfully"); - void navigate(`/notifications`); + void navigate({ to: `/notifications` }); }, }); @@ -64,7 +53,7 @@ export default function CreateNotification() { )}
- @@ -84,13 +63,13 @@ export default function Notifications({ loaderData }: Route.ComponentProps) {
setSearchQuery(e.target.value)} />