From fbbf1772a191db0b098db728dadf63f003a35a82 Mon Sep 17 00:00:00 2001 From: Derock Date: Sat, 3 Feb 2024 21:56:49 -0500 Subject: [PATCH] wip: domains --- .../[serviceId]/domains/DomainsList.tsx | 85 ++++-------------- .../domains/_components/DomainEntry.tsx | 86 +++++++++++++++++++ .../service/[serviceId]/source/page.tsx | 7 ++ src/components/ui/button.tsx | 5 +- 4 files changed, 114 insertions(+), 69 deletions(-) create mode 100644 src/app/(dashboard)/project/[projectId]/service/[serviceId]/domains/_components/DomainEntry.tsx create mode 100644 src/app/(dashboard)/project/[projectId]/service/[serviceId]/source/page.tsx diff --git a/src/app/(dashboard)/project/[projectId]/service/[serviceId]/domains/DomainsList.tsx b/src/app/(dashboard)/project/[projectId]/service/[serviceId]/domains/DomainsList.tsx index bcf19e3..933ab92 100644 --- a/src/app/(dashboard)/project/[projectId]/service/[serviceId]/domains/DomainsList.tsx +++ b/src/app/(dashboard)/project/[projectId]/service/[serviceId]/domains/DomainsList.tsx @@ -1,30 +1,16 @@ "use client"; -import { ArrowRight, PlusIcon } from "lucide-react"; +import { PlusIcon } from "lucide-react"; import { useFieldArray } from "react-hook-form"; import { z } from "zod"; import { Button } from "~/components/ui/button"; -import { - Form, - FormControl, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "~/components/ui/form"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "~/components/ui/select"; +import { Form } from "~/components/ui/form"; import { FormSubmit, FormUnsavedChangesIndicator, - SimpleFormField, useForm, } from "~/hooks/forms"; +import DomainEntry from "./_components/DomainEntry"; const formValidator = z.object({ domains: z.array( @@ -71,55 +57,13 @@ export default function DomainsList(

Domains

{domainsForm.fields.map((field, index) => ( -
- ( - - Protocol - - - - )} - /> - {/* toggle */} - } - /> - - - - - - -
+ ))}
@@ -132,7 +76,14 @@ export default function DomainsList( diff --git a/src/app/(dashboard)/project/[projectId]/service/[serviceId]/domains/_components/DomainEntry.tsx b/src/app/(dashboard)/project/[projectId]/service/[serviceId]/domains/_components/DomainEntry.tsx new file mode 100644 index 0000000..c4ac040 --- /dev/null +++ b/src/app/(dashboard)/project/[projectId]/service/[serviceId]/domains/_components/DomainEntry.tsx @@ -0,0 +1,86 @@ +"use client"; + +import { ArrowRight, CogIcon, TrashIcon } from "lucide-react"; +import { useState } from "react"; +import { type UseFieldArrayReturn, type UseFormReturn } from "react-hook-form"; +import { Button } from "~/components/ui/button"; +import { Card } from "~/components/ui/card"; +import { Switch } from "~/components/ui/switch"; +import { SimpleFormField } from "~/hooks/forms"; + +type FieldData = { + domain: string; + internalPort: number; + https: boolean; + forceSSL: boolean; +}; + +export default function DomainEntry({ + form, + domains, + field, + index, +}: { + form: UseFormReturn< + { + domains: FieldData[]; + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + any, + undefined + >; + + domains: UseFieldArrayReturn< + { + domains: FieldData[]; + }, + "domains", + "id" + >; + + field: FieldData; + index: number; +}) { + const isOpen = useState(false); + + return ( + + ( +
+ +
+ )} + /> + + + + + + + +
+
+
+ ); +} diff --git a/src/app/(dashboard)/project/[projectId]/service/[serviceId]/source/page.tsx b/src/app/(dashboard)/project/[projectId]/service/[serviceId]/source/page.tsx new file mode 100644 index 0000000..fa2fd8e --- /dev/null +++ b/src/app/(dashboard)/project/[projectId]/service/[serviceId]/source/page.tsx @@ -0,0 +1,7 @@ +"use client"; + +export function SourcePage() { + return ( + + ) +} \ No newline at end of file diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx index ab09bc2..6753572 100644 --- a/src/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -60,6 +60,7 @@ const Button = React.forwardRef( ) => { const Comp = asChild ? Slot : "button"; const Child = asChild ? "span" : React.Fragment; + const iconPadding = children ? " mr-2" : ""; return ( ( disabled={isLoading || props.disabled} > - {isLoading && } - {Icon && !isLoading && } + {isLoading && } + {Icon && !isLoading && } {children}