gitscope
← marzneshin / v0.3.2 / dashboard/src/routes/_dashboard/hosts/$inboundId/create.tsx
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/routes/_dashboard/hosts/$inboundId/create.tsx · TypeScript
Blame Raw
 1import { createFileRoute, useNavigate } from "@tanstack/react-router";
 2import { HostsMutationDialog } from "@marzneshin/features/hosts";
 3import { AlertDialog, AlertDialogContent } from "@marzneshin/components";
 4import { useDialog } from "@marzneshin/hooks";
 5
 6const HostCreate = () => {
 7    const [createDialogOpen, setCreateDialogOpen] = useDialog(true);
 8    const { inboundId } = Route.useParams();
 9    const navigate = useNavigate({ from: "/hosts/$inboundId/create" });
10
11    return (
12        <HostsMutationDialog
13            open={createDialogOpen}
14            onOpenChange={setCreateDialogOpen}
15            inboundId={Number(inboundId)}
16            onClose={() => navigate({ to: "/hosts" })}
17        />
18    );
19}
20
21export const Route = createFileRoute('/_dashboard/hosts/$inboundId/create')({
22    errorComponent: () => (
23        <AlertDialog open={true}>
24            <AlertDialogContent>Host not found</AlertDialogContent>
25        </AlertDialog>
26    ),
27    component: HostCreate,
28});