refactor: notifications
This commit is contained in:
parent
e424009dd3
commit
975ff23799
7 changed files with 169 additions and 85 deletions
|
|
@ -1,31 +1,20 @@
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import { Bell, Plus } from "lucide-react";
|
import { Bell, Plus } from "lucide-react";
|
||||||
import { useId } from "react";
|
import { useId } from "react";
|
||||||
import { useNavigate } from "react-router";
|
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { createNotificationDestinationMutation } from "~/client/api-client/@tanstack/react-query.gen";
|
import { createNotificationDestinationMutation } from "~/client/api-client/@tanstack/react-query.gen";
|
||||||
import { Button } from "~/client/components/ui/button";
|
import { Button } from "~/client/components/ui/button";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "~/client/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "~/client/components/ui/card";
|
||||||
import { parseError } from "~/client/lib/errors";
|
import { parseError } from "~/client/lib/errors";
|
||||||
import type { Route } from "./+types/create-notification";
|
|
||||||
import { Alert, AlertDescription } from "~/client/components/ui/alert";
|
import { Alert, AlertDescription } from "~/client/components/ui/alert";
|
||||||
import { CreateNotificationForm, type NotificationFormValues } from "../components/create-notification-form";
|
import { CreateNotificationForm, type NotificationFormValues } from "../components/create-notification-form";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
|
||||||
export const handle = {
|
export const handle = {
|
||||||
breadcrumb: () => [{ label: "Notifications", href: "/notifications" }, { label: "Create" }],
|
breadcrumb: () => [{ label: "Notifications", href: "/notifications" }, { label: "Create" }],
|
||||||
};
|
};
|
||||||
|
|
||||||
export function meta(_: Route.MetaArgs) {
|
export function CreateNotificationPage() {
|
||||||
return [
|
|
||||||
{ title: "Zerobyte - Create Notification" },
|
|
||||||
{
|
|
||||||
name: "description",
|
|
||||||
content: "Create a new notification destination for backup alerts.",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function CreateNotification() {
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const formId = useId();
|
const formId = useId();
|
||||||
|
|
||||||
|
|
@ -33,7 +22,7 @@ export default function CreateNotification() {
|
||||||
...createNotificationDestinationMutation(),
|
...createNotificationDestinationMutation(),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success("Notification destination created successfully");
|
toast.success("Notification destination created successfully");
|
||||||
void navigate(`/notifications`);
|
void navigate({ to: `/notifications` });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -64,7 +53,7 @@ export default function CreateNotification() {
|
||||||
)}
|
)}
|
||||||
<CreateNotificationForm mode="create" formId={formId} onSubmit={handleSubmit} />
|
<CreateNotificationForm mode="create" formId={formId} onSubmit={handleSubmit} />
|
||||||
<div className="flex justify-end gap-2 pt-4 border-t">
|
<div className="flex justify-end gap-2 pt-4 border-t">
|
||||||
<Button type="button" variant="secondary" onClick={() => navigate("/notifications")}>
|
<Button type="button" variant="secondary" onClick={() => navigate({ to: "/notifications" })}>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="submit" form={formId} loading={createNotification.isPending}>
|
<Button type="submit" form={formId} loading={createNotification.isPending}>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useSuspenseQuery } from "@tanstack/react-query";
|
||||||
import { redirect, useNavigate } from "react-router";
|
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { useState, useId } from "react";
|
import { useState, useId } from "react";
|
||||||
import {
|
import {
|
||||||
|
|
@ -20,53 +19,34 @@ import {
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from "~/client/components/ui/alert-dialog";
|
} from "~/client/components/ui/alert-dialog";
|
||||||
import { parseError } from "~/client/lib/errors";
|
import { parseError } from "~/client/lib/errors";
|
||||||
import { getNotificationDestination } from "~/client/api-client/sdk.gen";
|
|
||||||
import type { Route } from "./+types/notification-details";
|
|
||||||
import { cn } from "~/client/lib/utils";
|
import { cn } from "~/client/lib/utils";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "~/client/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "~/client/components/ui/card";
|
||||||
import { Bell, Save, TestTube2, Trash2 } from "lucide-react";
|
import { Bell, Save, TestTube2, Trash2 } from "lucide-react";
|
||||||
import { Alert, AlertDescription } from "~/client/components/ui/alert";
|
import { Alert, AlertDescription } from "~/client/components/ui/alert";
|
||||||
import { CreateNotificationForm, type NotificationFormValues } from "../components/create-notification-form";
|
import { CreateNotificationForm, type NotificationFormValues } from "../components/create-notification-form";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
|
||||||
export const handle = {
|
// export const handle = {
|
||||||
breadcrumb: (match: Route.MetaArgs) => [
|
// breadcrumb: (match: Route.MetaArgs) => [
|
||||||
{ label: "Notifications", href: "/notifications" },
|
// { label: "Notifications", href: "/notifications" },
|
||||||
{ label: match.params.id },
|
// { label: match.params.id },
|
||||||
],
|
// ],
|
||||||
};
|
// };
|
||||||
|
|
||||||
export function meta({ params }: Route.MetaArgs) {
|
export function NotificationDetailsPage({ notificationId }: { notificationId: string }) {
|
||||||
return [
|
|
||||||
{ title: `Zerobyte - Notification ${params.id}` },
|
|
||||||
{
|
|
||||||
name: "description",
|
|
||||||
content: "View and edit notification destination settings.",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const clientLoader = async ({ params }: Route.ClientLoaderArgs) => {
|
|
||||||
const destination = await getNotificationDestination({ path: { id: params.id ?? "" } });
|
|
||||||
if (destination.data) return destination.data;
|
|
||||||
|
|
||||||
return redirect("/notifications");
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function NotificationDetailsPage({ loaderData }: Route.ComponentProps) {
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const formId = useId();
|
const formId = useId();
|
||||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||||
|
|
||||||
const { data } = useQuery({
|
const { data } = useSuspenseQuery({
|
||||||
...getNotificationDestinationOptions({ path: { id: String(loaderData.id) } }),
|
...getNotificationDestinationOptions({ path: { id: notificationId } }),
|
||||||
initialData: loaderData,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteDestination = useMutation({
|
const deleteDestination = useMutation({
|
||||||
...deleteNotificationDestinationMutation(),
|
...deleteNotificationDestinationMutation(),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success("Notification destination deleted successfully");
|
toast.success("Notification destination deleted successfully");
|
||||||
void navigate("/notifications");
|
void navigate({ to: "/notifications" });
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
toast.error("Failed to delete notification destination", {
|
toast.error("Failed to delete notification destination", {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||||
import { Bell, Plus, RotateCcw } from "lucide-react";
|
import { Bell, Plus, RotateCcw } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router";
|
|
||||||
import { EmptyState } from "~/client/components/empty-state";
|
import { EmptyState } from "~/client/components/empty-state";
|
||||||
import { StatusDot } from "~/client/components/status-dot";
|
import { StatusDot } from "~/client/components/status-dot";
|
||||||
import { Button } from "~/client/components/ui/button";
|
import { Button } from "~/client/components/ui/button";
|
||||||
|
|
@ -9,31 +8,14 @@ import { Card } from "~/client/components/ui/card";
|
||||||
import { Input } from "~/client/components/ui/input";
|
import { Input } from "~/client/components/ui/input";
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "~/client/components/ui/select";
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "~/client/components/ui/select";
|
||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "~/client/components/ui/table";
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "~/client/components/ui/table";
|
||||||
import type { Route } from "./+types/notifications";
|
|
||||||
import { listNotificationDestinations } from "~/client/api-client";
|
|
||||||
import { listNotificationDestinationsOptions } from "~/client/api-client/@tanstack/react-query.gen";
|
import { listNotificationDestinationsOptions } from "~/client/api-client/@tanstack/react-query.gen";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
|
||||||
export const handle = {
|
export const handle = {
|
||||||
breadcrumb: () => [{ label: "Notifications" }],
|
breadcrumb: () => [{ label: "Notifications" }],
|
||||||
};
|
};
|
||||||
|
|
||||||
export function meta(_: Route.MetaArgs) {
|
export function NotificationsPage() {
|
||||||
return [
|
|
||||||
{ title: "Zerobyte - Notifications" },
|
|
||||||
{
|
|
||||||
name: "description",
|
|
||||||
content: "Manage notification destinations for backup alerts.",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const clientLoader = async () => {
|
|
||||||
const result = await listNotificationDestinations();
|
|
||||||
if (result.data) return result.data;
|
|
||||||
return [];
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function Notifications({ loaderData }: Route.ComponentProps) {
|
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
const [searchQuery, setSearchQuery] = useState("");
|
||||||
const [typeFilter, setTypeFilter] = useState("");
|
const [typeFilter, setTypeFilter] = useState("");
|
||||||
const [statusFilter, setStatusFilter] = useState("");
|
const [statusFilter, setStatusFilter] = useState("");
|
||||||
|
|
@ -46,19 +28,16 @@ export default function Notifications({ loaderData }: Route.ComponentProps) {
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { data } = useQuery({
|
const { data } = useSuspenseQuery({
|
||||||
...listNotificationDestinationsOptions(),
|
...listNotificationDestinationsOptions(),
|
||||||
initialData: loaderData,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const filteredNotifications =
|
const filteredNotifications = data.filter((notification) => {
|
||||||
data?.filter((notification) => {
|
const matchesSearch = notification.name.toLowerCase().includes(searchQuery.toLowerCase());
|
||||||
const matchesSearch = notification.name.toLowerCase().includes(searchQuery.toLowerCase());
|
const matchesType = !typeFilter || notification.type === typeFilter;
|
||||||
const matchesType = !typeFilter || notification.type === typeFilter;
|
const matchesStatus = !statusFilter || (statusFilter === "enabled" ? notification.enabled : !notification.enabled);
|
||||||
const matchesStatus =
|
return matchesSearch && matchesType && matchesStatus;
|
||||||
!statusFilter || (statusFilter === "enabled" ? notification.enabled : !notification.enabled);
|
});
|
||||||
return matchesSearch && matchesType && matchesStatus;
|
|
||||||
}) || [];
|
|
||||||
|
|
||||||
const hasNoNotifications = data.length === 0;
|
const hasNoNotifications = data.length === 0;
|
||||||
const hasNoFilteredNotifications = filteredNotifications.length === 0 && !hasNoNotifications;
|
const hasNoFilteredNotifications = filteredNotifications.length === 0 && !hasNoNotifications;
|
||||||
|
|
@ -70,7 +49,7 @@ export default function Notifications({ loaderData }: Route.ComponentProps) {
|
||||||
title="No notification destinations"
|
title="No notification destinations"
|
||||||
description="Set up notification channels to receive alerts when your backups complete or fail."
|
description="Set up notification channels to receive alerts when your backups complete or fail."
|
||||||
button={
|
button={
|
||||||
<Button onClick={() => navigate("/notifications/create")}>
|
<Button onClick={() => navigate({ to: "/notifications/create" })}>
|
||||||
<Plus size={16} className="mr-2" />
|
<Plus size={16} className="mr-2" />
|
||||||
Create Destination
|
Create Destination
|
||||||
</Button>
|
</Button>
|
||||||
|
|
@ -84,13 +63,13 @@ export default function Notifications({ loaderData }: Route.ComponentProps) {
|
||||||
<div className="flex flex-col lg:flex-row items-stretch lg:items-center gap-2 md:justify-between p-4 bg-card-header py-4">
|
<div className="flex flex-col lg:flex-row items-stretch lg:items-center gap-2 md:justify-between p-4 bg-card-header py-4">
|
||||||
<span className="flex flex-col sm:flex-row items-stretch md:items-center gap-0 flex-wrap ">
|
<span className="flex flex-col sm:flex-row items-stretch md:items-center gap-0 flex-wrap ">
|
||||||
<Input
|
<Input
|
||||||
className="w-full lg:w-[180px] min-w-[180px] -mr-px -mt-px"
|
className="w-full lg:w-45 min-w-45 -mr-px -mt-px"
|
||||||
placeholder="Search destinations…"
|
placeholder="Search destinations…"
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
/>
|
/>
|
||||||
<Select value={typeFilter} onValueChange={setTypeFilter}>
|
<Select value={typeFilter} onValueChange={setTypeFilter}>
|
||||||
<SelectTrigger className="w-full lg:w-[180px] min-w-[180px] -mr-px -mt-px">
|
<SelectTrigger className="w-full lg:w-45 min-w-45 -mr-px -mt-px">
|
||||||
<SelectValue placeholder="All types" />
|
<SelectValue placeholder="All types" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
|
|
@ -105,7 +84,7 @@ export default function Notifications({ loaderData }: Route.ComponentProps) {
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<Select value={statusFilter} onValueChange={setStatusFilter}>
|
<Select value={statusFilter} onValueChange={setStatusFilter}>
|
||||||
<SelectTrigger className="w-full lg:w-[180px] min-w-[180px] -mt-px">
|
<SelectTrigger className="w-full lg:w-45 min-w-45 -mt-px">
|
||||||
<SelectValue placeholder="All status" />
|
<SelectValue placeholder="All status" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
|
|
@ -120,7 +99,7 @@ export default function Notifications({ loaderData }: Route.ComponentProps) {
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
<Button onClick={() => navigate("/notifications/create")}>
|
<Button onClick={() => navigate({ to: "/notifications/create" })}>
|
||||||
<Plus size={16} className="mr-2" />
|
<Plus size={16} className="mr-2" />
|
||||||
Create Destination
|
Create Destination
|
||||||
</Button>
|
</Button>
|
||||||
|
|
@ -129,7 +108,7 @@ export default function Notifications({ loaderData }: Route.ComponentProps) {
|
||||||
<Table className="border-t">
|
<Table className="border-t">
|
||||||
<TableHeader className="bg-card-header">
|
<TableHeader className="bg-card-header">
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableHead className="w-[100px] uppercase">Name</TableHead>
|
<TableHead className="w-25 uppercase">Name</TableHead>
|
||||||
<TableHead className="uppercase text-left">Type</TableHead>
|
<TableHead className="uppercase text-left">Type</TableHead>
|
||||||
<TableHead className="uppercase text-center">Status</TableHead>
|
<TableHead className="uppercase text-center">Status</TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
@ -152,7 +131,7 @@ export default function Notifications({ loaderData }: Route.ComponentProps) {
|
||||||
<TableRow
|
<TableRow
|
||||||
key={notification.id}
|
key={notification.id}
|
||||||
className="hover:bg-accent/50 hover:cursor-pointer"
|
className="hover:bg-accent/50 hover:cursor-pointer"
|
||||||
onClick={() => navigate(`/notifications/${notification.id}`)}
|
onClick={() => navigate({ to: `/notifications/${notification.id}` })}
|
||||||
>
|
>
|
||||||
<TableCell className="font-medium text-strong-accent">{notification.name}</TableCell>
|
<TableCell className="font-medium text-strong-accent">{notification.name}</TableCell>
|
||||||
<TableCell className="capitalize">{notification.type}</TableCell>
|
<TableCell className="capitalize">{notification.type}</TableCell>
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,14 @@ import { Route as authLoginRouteImport } from './routes/(auth)/login'
|
||||||
import { Route as authDownloadRecoveryKeyRouteImport } from './routes/(auth)/download-recovery-key'
|
import { Route as authDownloadRecoveryKeyRouteImport } from './routes/(auth)/download-recovery-key'
|
||||||
import { Route as dashboardVolumesIndexRouteImport } from './routes/(dashboard)/volumes/index'
|
import { Route as dashboardVolumesIndexRouteImport } from './routes/(dashboard)/volumes/index'
|
||||||
import { Route as dashboardRepositoriesIndexRouteImport } from './routes/(dashboard)/repositories/index'
|
import { Route as dashboardRepositoriesIndexRouteImport } from './routes/(dashboard)/repositories/index'
|
||||||
|
import { Route as dashboardNotificationsIndexRouteImport } from './routes/(dashboard)/notifications/index'
|
||||||
import { Route as dashboardBackupsIndexRouteImport } from './routes/(dashboard)/backups/index'
|
import { Route as dashboardBackupsIndexRouteImport } from './routes/(dashboard)/backups/index'
|
||||||
import { Route as dashboardVolumesCreateRouteImport } from './routes/(dashboard)/volumes/create'
|
import { Route as dashboardVolumesCreateRouteImport } from './routes/(dashboard)/volumes/create'
|
||||||
import { Route as dashboardVolumesVolumeIdRouteImport } from './routes/(dashboard)/volumes/$volumeId'
|
import { Route as dashboardVolumesVolumeIdRouteImport } from './routes/(dashboard)/volumes/$volumeId'
|
||||||
import { Route as dashboardRepositoriesCreateRouteImport } from './routes/(dashboard)/repositories/create'
|
import { Route as dashboardRepositoriesCreateRouteImport } from './routes/(dashboard)/repositories/create'
|
||||||
import { Route as dashboardRepositoriesRepositoryIdRouteImport } from './routes/(dashboard)/repositories/$repositoryId'
|
import { Route as dashboardRepositoriesRepositoryIdRouteImport } from './routes/(dashboard)/repositories/$repositoryId'
|
||||||
|
import { Route as dashboardNotificationsCreateRouteImport } from './routes/(dashboard)/notifications/create'
|
||||||
|
import { Route as dashboardNotificationsNotificationIdRouteImport } from './routes/(dashboard)/notifications/$notificationId'
|
||||||
import { Route as dashboardBackupsCreateRouteImport } from './routes/(dashboard)/backups/create'
|
import { Route as dashboardBackupsCreateRouteImport } from './routes/(dashboard)/backups/create'
|
||||||
import { Route as dashboardBackupsScheduleIdRouteImport } from './routes/(dashboard)/backups/$scheduleId'
|
import { Route as dashboardBackupsScheduleIdRouteImport } from './routes/(dashboard)/backups/$scheduleId'
|
||||||
import { Route as dashboardRepositoriesRepoIdSnapshotIdRouteImport } from './routes/(dashboard)/repositories/$repoId.$snapshotId'
|
import { Route as dashboardRepositoriesRepoIdSnapshotIdRouteImport } from './routes/(dashboard)/repositories/$repoId.$snapshotId'
|
||||||
|
|
@ -62,6 +65,12 @@ const dashboardRepositoriesIndexRoute =
|
||||||
path: '/repositories/',
|
path: '/repositories/',
|
||||||
getParentRoute: () => dashboardRouteRoute,
|
getParentRoute: () => dashboardRouteRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
const dashboardNotificationsIndexRoute =
|
||||||
|
dashboardNotificationsIndexRouteImport.update({
|
||||||
|
id: '/notifications/',
|
||||||
|
path: '/notifications/',
|
||||||
|
getParentRoute: () => dashboardRouteRoute,
|
||||||
|
} as any)
|
||||||
const dashboardBackupsIndexRoute = dashboardBackupsIndexRouteImport.update({
|
const dashboardBackupsIndexRoute = dashboardBackupsIndexRouteImport.update({
|
||||||
id: '/backups/',
|
id: '/backups/',
|
||||||
path: '/backups/',
|
path: '/backups/',
|
||||||
|
|
@ -90,6 +99,18 @@ const dashboardRepositoriesRepositoryIdRoute =
|
||||||
path: '/repositories/$repositoryId',
|
path: '/repositories/$repositoryId',
|
||||||
getParentRoute: () => dashboardRouteRoute,
|
getParentRoute: () => dashboardRouteRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
const dashboardNotificationsCreateRoute =
|
||||||
|
dashboardNotificationsCreateRouteImport.update({
|
||||||
|
id: '/notifications/create',
|
||||||
|
path: '/notifications/create',
|
||||||
|
getParentRoute: () => dashboardRouteRoute,
|
||||||
|
} as any)
|
||||||
|
const dashboardNotificationsNotificationIdRoute =
|
||||||
|
dashboardNotificationsNotificationIdRouteImport.update({
|
||||||
|
id: '/notifications/$notificationId',
|
||||||
|
path: '/notifications/$notificationId',
|
||||||
|
getParentRoute: () => dashboardRouteRoute,
|
||||||
|
} as any)
|
||||||
const dashboardBackupsCreateRoute = dashboardBackupsCreateRouteImport.update({
|
const dashboardBackupsCreateRoute = dashboardBackupsCreateRouteImport.update({
|
||||||
id: '/backups/create',
|
id: '/backups/create',
|
||||||
path: '/backups/create',
|
path: '/backups/create',
|
||||||
|
|
@ -127,11 +148,14 @@ export interface FileRoutesByFullPath {
|
||||||
'/onboarding': typeof authOnboardingRoute
|
'/onboarding': typeof authOnboardingRoute
|
||||||
'/backups/$scheduleId': typeof dashboardBackupsScheduleIdRoute
|
'/backups/$scheduleId': typeof dashboardBackupsScheduleIdRoute
|
||||||
'/backups/create': typeof dashboardBackupsCreateRoute
|
'/backups/create': typeof dashboardBackupsCreateRoute
|
||||||
|
'/notifications/$notificationId': typeof dashboardNotificationsNotificationIdRoute
|
||||||
|
'/notifications/create': typeof dashboardNotificationsCreateRoute
|
||||||
'/repositories/$repositoryId': typeof dashboardRepositoriesRepositoryIdRoute
|
'/repositories/$repositoryId': typeof dashboardRepositoriesRepositoryIdRoute
|
||||||
'/repositories/create': typeof dashboardRepositoriesCreateRoute
|
'/repositories/create': typeof dashboardRepositoriesCreateRoute
|
||||||
'/volumes/$volumeId': typeof dashboardVolumesVolumeIdRoute
|
'/volumes/$volumeId': typeof dashboardVolumesVolumeIdRoute
|
||||||
'/volumes/create': typeof dashboardVolumesCreateRoute
|
'/volumes/create': typeof dashboardVolumesCreateRoute
|
||||||
'/backups/': typeof dashboardBackupsIndexRoute
|
'/backups/': typeof dashboardBackupsIndexRoute
|
||||||
|
'/notifications/': typeof dashboardNotificationsIndexRoute
|
||||||
'/repositories/': typeof dashboardRepositoriesIndexRoute
|
'/repositories/': typeof dashboardRepositoriesIndexRoute
|
||||||
'/volumes/': typeof dashboardVolumesIndexRoute
|
'/volumes/': typeof dashboardVolumesIndexRoute
|
||||||
'/repositories/$repoId/$snapshotId': typeof dashboardRepositoriesRepoIdSnapshotIdRoute
|
'/repositories/$repoId/$snapshotId': typeof dashboardRepositoriesRepoIdSnapshotIdRoute
|
||||||
|
|
@ -145,11 +169,14 @@ export interface FileRoutesByTo {
|
||||||
'/onboarding': typeof authOnboardingRoute
|
'/onboarding': typeof authOnboardingRoute
|
||||||
'/backups/$scheduleId': typeof dashboardBackupsScheduleIdRoute
|
'/backups/$scheduleId': typeof dashboardBackupsScheduleIdRoute
|
||||||
'/backups/create': typeof dashboardBackupsCreateRoute
|
'/backups/create': typeof dashboardBackupsCreateRoute
|
||||||
|
'/notifications/$notificationId': typeof dashboardNotificationsNotificationIdRoute
|
||||||
|
'/notifications/create': typeof dashboardNotificationsCreateRoute
|
||||||
'/repositories/$repositoryId': typeof dashboardRepositoriesRepositoryIdRoute
|
'/repositories/$repositoryId': typeof dashboardRepositoriesRepositoryIdRoute
|
||||||
'/repositories/create': typeof dashboardRepositoriesCreateRoute
|
'/repositories/create': typeof dashboardRepositoriesCreateRoute
|
||||||
'/volumes/$volumeId': typeof dashboardVolumesVolumeIdRoute
|
'/volumes/$volumeId': typeof dashboardVolumesVolumeIdRoute
|
||||||
'/volumes/create': typeof dashboardVolumesCreateRoute
|
'/volumes/create': typeof dashboardVolumesCreateRoute
|
||||||
'/backups': typeof dashboardBackupsIndexRoute
|
'/backups': typeof dashboardBackupsIndexRoute
|
||||||
|
'/notifications': typeof dashboardNotificationsIndexRoute
|
||||||
'/repositories': typeof dashboardRepositoriesIndexRoute
|
'/repositories': typeof dashboardRepositoriesIndexRoute
|
||||||
'/volumes': typeof dashboardVolumesIndexRoute
|
'/volumes': typeof dashboardVolumesIndexRoute
|
||||||
'/repositories/$repoId/$snapshotId': typeof dashboardRepositoriesRepoIdSnapshotIdRoute
|
'/repositories/$repoId/$snapshotId': typeof dashboardRepositoriesRepoIdSnapshotIdRoute
|
||||||
|
|
@ -165,11 +192,14 @@ export interface FileRoutesById {
|
||||||
'/(auth)/onboarding': typeof authOnboardingRoute
|
'/(auth)/onboarding': typeof authOnboardingRoute
|
||||||
'/(dashboard)/backups/$scheduleId': typeof dashboardBackupsScheduleIdRoute
|
'/(dashboard)/backups/$scheduleId': typeof dashboardBackupsScheduleIdRoute
|
||||||
'/(dashboard)/backups/create': typeof dashboardBackupsCreateRoute
|
'/(dashboard)/backups/create': typeof dashboardBackupsCreateRoute
|
||||||
|
'/(dashboard)/notifications/$notificationId': typeof dashboardNotificationsNotificationIdRoute
|
||||||
|
'/(dashboard)/notifications/create': typeof dashboardNotificationsCreateRoute
|
||||||
'/(dashboard)/repositories/$repositoryId': typeof dashboardRepositoriesRepositoryIdRoute
|
'/(dashboard)/repositories/$repositoryId': typeof dashboardRepositoriesRepositoryIdRoute
|
||||||
'/(dashboard)/repositories/create': typeof dashboardRepositoriesCreateRoute
|
'/(dashboard)/repositories/create': typeof dashboardRepositoriesCreateRoute
|
||||||
'/(dashboard)/volumes/$volumeId': typeof dashboardVolumesVolumeIdRoute
|
'/(dashboard)/volumes/$volumeId': typeof dashboardVolumesVolumeIdRoute
|
||||||
'/(dashboard)/volumes/create': typeof dashboardVolumesCreateRoute
|
'/(dashboard)/volumes/create': typeof dashboardVolumesCreateRoute
|
||||||
'/(dashboard)/backups/': typeof dashboardBackupsIndexRoute
|
'/(dashboard)/backups/': typeof dashboardBackupsIndexRoute
|
||||||
|
'/(dashboard)/notifications/': typeof dashboardNotificationsIndexRoute
|
||||||
'/(dashboard)/repositories/': typeof dashboardRepositoriesIndexRoute
|
'/(dashboard)/repositories/': typeof dashboardRepositoriesIndexRoute
|
||||||
'/(dashboard)/volumes/': typeof dashboardVolumesIndexRoute
|
'/(dashboard)/volumes/': typeof dashboardVolumesIndexRoute
|
||||||
'/(dashboard)/repositories/$repoId/$snapshotId': typeof dashboardRepositoriesRepoIdSnapshotIdRoute
|
'/(dashboard)/repositories/$repoId/$snapshotId': typeof dashboardRepositoriesRepoIdSnapshotIdRoute
|
||||||
|
|
@ -185,11 +215,14 @@ export interface FileRouteTypes {
|
||||||
| '/onboarding'
|
| '/onboarding'
|
||||||
| '/backups/$scheduleId'
|
| '/backups/$scheduleId'
|
||||||
| '/backups/create'
|
| '/backups/create'
|
||||||
|
| '/notifications/$notificationId'
|
||||||
|
| '/notifications/create'
|
||||||
| '/repositories/$repositoryId'
|
| '/repositories/$repositoryId'
|
||||||
| '/repositories/create'
|
| '/repositories/create'
|
||||||
| '/volumes/$volumeId'
|
| '/volumes/$volumeId'
|
||||||
| '/volumes/create'
|
| '/volumes/create'
|
||||||
| '/backups/'
|
| '/backups/'
|
||||||
|
| '/notifications/'
|
||||||
| '/repositories/'
|
| '/repositories/'
|
||||||
| '/volumes/'
|
| '/volumes/'
|
||||||
| '/repositories/$repoId/$snapshotId'
|
| '/repositories/$repoId/$snapshotId'
|
||||||
|
|
@ -203,11 +236,14 @@ export interface FileRouteTypes {
|
||||||
| '/onboarding'
|
| '/onboarding'
|
||||||
| '/backups/$scheduleId'
|
| '/backups/$scheduleId'
|
||||||
| '/backups/create'
|
| '/backups/create'
|
||||||
|
| '/notifications/$notificationId'
|
||||||
|
| '/notifications/create'
|
||||||
| '/repositories/$repositoryId'
|
| '/repositories/$repositoryId'
|
||||||
| '/repositories/create'
|
| '/repositories/create'
|
||||||
| '/volumes/$volumeId'
|
| '/volumes/$volumeId'
|
||||||
| '/volumes/create'
|
| '/volumes/create'
|
||||||
| '/backups'
|
| '/backups'
|
||||||
|
| '/notifications'
|
||||||
| '/repositories'
|
| '/repositories'
|
||||||
| '/volumes'
|
| '/volumes'
|
||||||
| '/repositories/$repoId/$snapshotId'
|
| '/repositories/$repoId/$snapshotId'
|
||||||
|
|
@ -222,11 +258,14 @@ export interface FileRouteTypes {
|
||||||
| '/(auth)/onboarding'
|
| '/(auth)/onboarding'
|
||||||
| '/(dashboard)/backups/$scheduleId'
|
| '/(dashboard)/backups/$scheduleId'
|
||||||
| '/(dashboard)/backups/create'
|
| '/(dashboard)/backups/create'
|
||||||
|
| '/(dashboard)/notifications/$notificationId'
|
||||||
|
| '/(dashboard)/notifications/create'
|
||||||
| '/(dashboard)/repositories/$repositoryId'
|
| '/(dashboard)/repositories/$repositoryId'
|
||||||
| '/(dashboard)/repositories/create'
|
| '/(dashboard)/repositories/create'
|
||||||
| '/(dashboard)/volumes/$volumeId'
|
| '/(dashboard)/volumes/$volumeId'
|
||||||
| '/(dashboard)/volumes/create'
|
| '/(dashboard)/volumes/create'
|
||||||
| '/(dashboard)/backups/'
|
| '/(dashboard)/backups/'
|
||||||
|
| '/(dashboard)/notifications/'
|
||||||
| '/(dashboard)/repositories/'
|
| '/(dashboard)/repositories/'
|
||||||
| '/(dashboard)/volumes/'
|
| '/(dashboard)/volumes/'
|
||||||
| '/(dashboard)/repositories/$repoId/$snapshotId'
|
| '/(dashboard)/repositories/$repoId/$snapshotId'
|
||||||
|
|
@ -293,6 +332,13 @@ declare module '@tanstack/react-router' {
|
||||||
preLoaderRoute: typeof dashboardRepositoriesIndexRouteImport
|
preLoaderRoute: typeof dashboardRepositoriesIndexRouteImport
|
||||||
parentRoute: typeof dashboardRouteRoute
|
parentRoute: typeof dashboardRouteRoute
|
||||||
}
|
}
|
||||||
|
'/(dashboard)/notifications/': {
|
||||||
|
id: '/(dashboard)/notifications/'
|
||||||
|
path: '/notifications'
|
||||||
|
fullPath: '/notifications/'
|
||||||
|
preLoaderRoute: typeof dashboardNotificationsIndexRouteImport
|
||||||
|
parentRoute: typeof dashboardRouteRoute
|
||||||
|
}
|
||||||
'/(dashboard)/backups/': {
|
'/(dashboard)/backups/': {
|
||||||
id: '/(dashboard)/backups/'
|
id: '/(dashboard)/backups/'
|
||||||
path: '/backups'
|
path: '/backups'
|
||||||
|
|
@ -328,6 +374,20 @@ declare module '@tanstack/react-router' {
|
||||||
preLoaderRoute: typeof dashboardRepositoriesRepositoryIdRouteImport
|
preLoaderRoute: typeof dashboardRepositoriesRepositoryIdRouteImport
|
||||||
parentRoute: typeof dashboardRouteRoute
|
parentRoute: typeof dashboardRouteRoute
|
||||||
}
|
}
|
||||||
|
'/(dashboard)/notifications/create': {
|
||||||
|
id: '/(dashboard)/notifications/create'
|
||||||
|
path: '/notifications/create'
|
||||||
|
fullPath: '/notifications/create'
|
||||||
|
preLoaderRoute: typeof dashboardNotificationsCreateRouteImport
|
||||||
|
parentRoute: typeof dashboardRouteRoute
|
||||||
|
}
|
||||||
|
'/(dashboard)/notifications/$notificationId': {
|
||||||
|
id: '/(dashboard)/notifications/$notificationId'
|
||||||
|
path: '/notifications/$notificationId'
|
||||||
|
fullPath: '/notifications/$notificationId'
|
||||||
|
preLoaderRoute: typeof dashboardNotificationsNotificationIdRouteImport
|
||||||
|
parentRoute: typeof dashboardRouteRoute
|
||||||
|
}
|
||||||
'/(dashboard)/backups/create': {
|
'/(dashboard)/backups/create': {
|
||||||
id: '/(dashboard)/backups/create'
|
id: '/(dashboard)/backups/create'
|
||||||
path: '/backups/create'
|
path: '/backups/create'
|
||||||
|
|
@ -369,11 +429,14 @@ declare module '@tanstack/react-router' {
|
||||||
interface dashboardRouteRouteChildren {
|
interface dashboardRouteRouteChildren {
|
||||||
dashboardBackupsScheduleIdRoute: typeof dashboardBackupsScheduleIdRoute
|
dashboardBackupsScheduleIdRoute: typeof dashboardBackupsScheduleIdRoute
|
||||||
dashboardBackupsCreateRoute: typeof dashboardBackupsCreateRoute
|
dashboardBackupsCreateRoute: typeof dashboardBackupsCreateRoute
|
||||||
|
dashboardNotificationsNotificationIdRoute: typeof dashboardNotificationsNotificationIdRoute
|
||||||
|
dashboardNotificationsCreateRoute: typeof dashboardNotificationsCreateRoute
|
||||||
dashboardRepositoriesRepositoryIdRoute: typeof dashboardRepositoriesRepositoryIdRoute
|
dashboardRepositoriesRepositoryIdRoute: typeof dashboardRepositoriesRepositoryIdRoute
|
||||||
dashboardRepositoriesCreateRoute: typeof dashboardRepositoriesCreateRoute
|
dashboardRepositoriesCreateRoute: typeof dashboardRepositoriesCreateRoute
|
||||||
dashboardVolumesVolumeIdRoute: typeof dashboardVolumesVolumeIdRoute
|
dashboardVolumesVolumeIdRoute: typeof dashboardVolumesVolumeIdRoute
|
||||||
dashboardVolumesCreateRoute: typeof dashboardVolumesCreateRoute
|
dashboardVolumesCreateRoute: typeof dashboardVolumesCreateRoute
|
||||||
dashboardBackupsIndexRoute: typeof dashboardBackupsIndexRoute
|
dashboardBackupsIndexRoute: typeof dashboardBackupsIndexRoute
|
||||||
|
dashboardNotificationsIndexRoute: typeof dashboardNotificationsIndexRoute
|
||||||
dashboardRepositoriesIndexRoute: typeof dashboardRepositoriesIndexRoute
|
dashboardRepositoriesIndexRoute: typeof dashboardRepositoriesIndexRoute
|
||||||
dashboardVolumesIndexRoute: typeof dashboardVolumesIndexRoute
|
dashboardVolumesIndexRoute: typeof dashboardVolumesIndexRoute
|
||||||
dashboardRepositoriesRepoIdSnapshotIdRoute: typeof dashboardRepositoriesRepoIdSnapshotIdRoute
|
dashboardRepositoriesRepoIdSnapshotIdRoute: typeof dashboardRepositoriesRepoIdSnapshotIdRoute
|
||||||
|
|
@ -384,12 +447,16 @@ interface dashboardRouteRouteChildren {
|
||||||
const dashboardRouteRouteChildren: dashboardRouteRouteChildren = {
|
const dashboardRouteRouteChildren: dashboardRouteRouteChildren = {
|
||||||
dashboardBackupsScheduleIdRoute: dashboardBackupsScheduleIdRoute,
|
dashboardBackupsScheduleIdRoute: dashboardBackupsScheduleIdRoute,
|
||||||
dashboardBackupsCreateRoute: dashboardBackupsCreateRoute,
|
dashboardBackupsCreateRoute: dashboardBackupsCreateRoute,
|
||||||
|
dashboardNotificationsNotificationIdRoute:
|
||||||
|
dashboardNotificationsNotificationIdRoute,
|
||||||
|
dashboardNotificationsCreateRoute: dashboardNotificationsCreateRoute,
|
||||||
dashboardRepositoriesRepositoryIdRoute:
|
dashboardRepositoriesRepositoryIdRoute:
|
||||||
dashboardRepositoriesRepositoryIdRoute,
|
dashboardRepositoriesRepositoryIdRoute,
|
||||||
dashboardRepositoriesCreateRoute: dashboardRepositoriesCreateRoute,
|
dashboardRepositoriesCreateRoute: dashboardRepositoriesCreateRoute,
|
||||||
dashboardVolumesVolumeIdRoute: dashboardVolumesVolumeIdRoute,
|
dashboardVolumesVolumeIdRoute: dashboardVolumesVolumeIdRoute,
|
||||||
dashboardVolumesCreateRoute: dashboardVolumesCreateRoute,
|
dashboardVolumesCreateRoute: dashboardVolumesCreateRoute,
|
||||||
dashboardBackupsIndexRoute: dashboardBackupsIndexRoute,
|
dashboardBackupsIndexRoute: dashboardBackupsIndexRoute,
|
||||||
|
dashboardNotificationsIndexRoute: dashboardNotificationsIndexRoute,
|
||||||
dashboardRepositoriesIndexRoute: dashboardRepositoriesIndexRoute,
|
dashboardRepositoriesIndexRoute: dashboardRepositoriesIndexRoute,
|
||||||
dashboardVolumesIndexRoute: dashboardVolumesIndexRoute,
|
dashboardVolumesIndexRoute: dashboardVolumesIndexRoute,
|
||||||
dashboardRepositoriesRepoIdSnapshotIdRoute:
|
dashboardRepositoriesRepoIdSnapshotIdRoute:
|
||||||
|
|
|
||||||
27
app/routes/(dashboard)/notifications/$notificationId.tsx
Normal file
27
app/routes/(dashboard)/notifications/$notificationId.tsx
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { getNotificationDestinationOptions } from "~/client/api-client/@tanstack/react-query.gen";
|
||||||
|
import { NotificationDetailsPage } from "~/client/modules/notifications/routes/notification-details";
|
||||||
|
|
||||||
|
export const Route = createFileRoute("/(dashboard)/notifications/$notificationId")({
|
||||||
|
component: RouteComponent,
|
||||||
|
loader: async ({ params, context }) => {
|
||||||
|
const res = await context.queryClient.ensureQueryData({
|
||||||
|
...getNotificationDestinationOptions({ path: { id: params.notificationId } }),
|
||||||
|
});
|
||||||
|
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
head: ({ loaderData }) => ({
|
||||||
|
meta: [
|
||||||
|
{ title: `Zerobyte - ${loaderData?.name}` },
|
||||||
|
{
|
||||||
|
name: "description",
|
||||||
|
content: "View and edit notification destination settings.",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
function RouteComponent() {
|
||||||
|
return <NotificationDetailsPage notificationId={Route.useParams().notificationId} />;
|
||||||
|
}
|
||||||
19
app/routes/(dashboard)/notifications/create.tsx
Normal file
19
app/routes/(dashboard)/notifications/create.tsx
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { CreateNotificationPage } from "~/client/modules/notifications/routes/create-notification";
|
||||||
|
|
||||||
|
export const Route = createFileRoute("/(dashboard)/notifications/create")({
|
||||||
|
component: RouteComponent,
|
||||||
|
head: () => ({
|
||||||
|
meta: [
|
||||||
|
{ title: "Zerobyte - Create Notification" },
|
||||||
|
{
|
||||||
|
name: "description",
|
||||||
|
content: "Create a new notification destination for backup alerts.",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
function RouteComponent() {
|
||||||
|
return <CreateNotificationPage />;
|
||||||
|
}
|
||||||
23
app/routes/(dashboard)/notifications/index.tsx
Normal file
23
app/routes/(dashboard)/notifications/index.tsx
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { listNotificationDestinationsOptions } from "~/client/api-client/@tanstack/react-query.gen";
|
||||||
|
import { NotificationsPage } from "~/client/modules/notifications/routes/notifications";
|
||||||
|
|
||||||
|
export const Route = createFileRoute("/(dashboard)/notifications/")({
|
||||||
|
component: RouteComponent,
|
||||||
|
loader: async ({ context }) => {
|
||||||
|
await context.queryClient.ensureQueryData({ ...listNotificationDestinationsOptions() });
|
||||||
|
},
|
||||||
|
head: () => ({
|
||||||
|
meta: [
|
||||||
|
{ title: "Zerobyte - Notifications" },
|
||||||
|
{
|
||||||
|
name: "description",
|
||||||
|
content: "Manage notification destinations for backup alerts.",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
function RouteComponent() {
|
||||||
|
return <NotificationsPage />;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue