import { useMutation } from "@tanstack/react-query"; import { Bell, Plus } from "lucide-react"; import { useId } from "react"; 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 { Alert, AlertDescription } from "~/client/components/ui/alert"; import { CreateNotificationForm, type NotificationFormValues } from "../components/create-notification-form"; import { useNavigate } from "@tanstack/react-router"; export function CreateNotificationPage() { const navigate = useNavigate(); const formId = useId(); const createNotification = useMutation({ ...createNotificationDestinationMutation(), onSuccess: () => { toast.success("Notification destination created successfully"); void navigate({ to: `/notifications` }); }, }); const handleSubmit = (values: NotificationFormValues) => { createNotification.mutate({ body: { name: values.name, config: values } }); }; return (
Create Notification Destination
{createNotification.isError && ( Failed to create notification destination:
{parseError(createNotification.error)?.message}
)}
); }