diff --git a/app/(main)/ix/ix-site-editor.tsx b/app/(main)/ix/ix-site-editor.tsx new file mode 100644 index 00000000..4454dc70 --- /dev/null +++ b/app/(main)/ix/ix-site-editor.tsx @@ -0,0 +1,228 @@ +"use client" + +import { useId, type ReactNode } from "react" +import Link from "next/link" +import { PlusIcon, XIcon } from "lucide-react" +import type { IxSite } from "@mmapp/contracts/internet-exchange" +import { Button } from "@/components/ui/button" +import { Field, FieldLabel } from "@/components/ui/field" +import { Input } from "@/components/ui/input" +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" +import { Checkbox } from "@/components/ui/checkbox" +import { Textarea } from "@/components/ui/textarea" + +type Binding = IxSite["interfaces"][number] +type Group = IxSite["groups"][number] +type Path = Group["primary"] +type Peer = IxSite["neighbors"][number] +type Choice = { value: string; label: string } + +function TextField({ label, value, edit, numeric, placeholder }: { + label: string; value: string | number; edit: (value: string) => void; numeric?: boolean; placeholder?: string +}) { + const id = useId() + return + {label} + { if (!numeric || /^\d*$/.test(event.target.value)) edit(event.target.value) }} /> + +} + +function Pick({ label, value, options, edit, disabled }: { + label: string; value?: T; options: readonly { value: T; label: string }[]; edit: (value: T) => void; disabled: boolean +}) { + const id = useId() + return + {label} + + +} + +function Flag({ label, checked, edit, disabled }: { + label: string; checked: boolean; edit: (value: boolean) => void; disabled: boolean +}) { + const id = useId() + return + + {label} + +} + +function Lines({ label, value, edit }: { label: string; value: string[]; edit: (value: string[]) => void }) { + const id = useId() + return + {label} +