diff --git a/internal/network/config.go b/internal/network/config.go
index 8a28d51..18f7b13 100644
--- a/internal/network/config.go
+++ b/internal/network/config.go
@@ -29,7 +29,7 @@ type IPv4StaticConfig struct {
type IPv6StaticConfig struct {
Address null.String `json:"address,omitempty" validate_type:"ipv6" required:"true"`
- Prefix null.String `json:"prefix,omitempty" validate_type:"ipv6" required:"true"`
+ Prefix null.String `json:"prefix,omitempty" required:"true"`
Gateway null.String `json:"gateway,omitempty" validate_type:"ipv6" required:"true"`
DNS []string `json:"dns,omitempty" validate_type:"ipv6" required:"true"`
}
diff --git a/ui/src/components/Ipv6NetworkCard.tsx b/ui/src/components/Ipv6NetworkCard.tsx
index fabb7b6..ac9d20f 100644
--- a/ui/src/components/Ipv6NetworkCard.tsx
+++ b/ui/src/components/Ipv6NetworkCard.tsx
@@ -33,56 +33,54 @@ export default function Ipv6NetworkCard({
{networkState?.ipv6_addresses && networkState?.ipv6_addresses.length > 0 && (
IPv6 Addresses
- {networkState.ipv6_addresses.map(
- addr => (
-
-
-
-
- Address
-
- {addr.address}
-
-
- {addr.valid_lifetime && (
-
-
- Valid Lifetime
-
-
- {addr.valid_lifetime === "" ? (
-
- N/A
-
- ) : (
-
- )}
-
-
- )}
- {addr.preferred_lifetime && (
-
-
- Preferred Lifetime
-
-
- {addr.preferred_lifetime === "" ? (
-
- N/A
-
- ) : (
-
- )}
-
-
- )}
+ {networkState.ipv6_addresses.map(addr => (
+
+
+
+
+ Address
+
+ {addr.address}
+
+ {addr.valid_lifetime && (
+
+
+ Valid Lifetime
+
+
+ {addr.valid_lifetime === "" ? (
+
+ N/A
+
+ ) : (
+
+ )}
+
+
+ )}
+ {addr.preferred_lifetime && (
+
+
+ Preferred Lifetime
+
+
+ {addr.preferred_lifetime === "" ? (
+
+ N/A
+
+ ) : (
+
+ )}
+
+
+ )}
- ),
- )}
+
+ ))}
)}
diff --git a/ui/src/components/StaticIpv4Card.tsx b/ui/src/components/StaticIpv4Card.tsx
index f7913c9..044d2bf 100644
--- a/ui/src/components/StaticIpv4Card.tsx
+++ b/ui/src/components/StaticIpv4Card.tsx
@@ -1,6 +1,6 @@
import { LuPlus, LuX } from "react-icons/lu";
import { useFieldArray, useFormContext } from "react-hook-form";
-import validator from "validator";
+import { useEffect } from "react";
import { GridCard } from "@/components/Card";
import { Button } from "@/components/Button";
@@ -8,10 +8,15 @@ import { InputFieldWithLabel } from "@/components/InputField";
export default function StaticIpv4Card() {
const formMethods = useFormContext();
- const { register, formState } = formMethods;
+ const { register, formState, watch } = formMethods;
const { fields, append, remove } = useFieldArray({ name: "ipv4_static.dns" });
+ useEffect(() => {
+ if (fields.length === 0) append("");
+ }, [append, fields.length]);
+
+ const dns = watch("ipv4_static.dns");
return (
@@ -59,11 +64,11 @@ export default function StaticIpv4Card() {
size="SM"
placeholder="1.1.1.1"
{...register(`ipv4_static.dns.${index}`, {
- validate: (value: string) => {
- if (value === "") return true;
- if (!validator.isIP(value)) return "Invalid IP address";
- return true;
- },
+ // validate: (value: string) => {
+ // if (value === "") return true;
+ // if (!validator.isIP(value)) return "Invalid IP address";
+ // return true;
+ // },
})}
error={formState.errors.ipv4_static?.dns?.[index]?.message}
/>
@@ -92,6 +97,7 @@ export default function StaticIpv4Card() {
LeadingIcon={LuPlus}
type="button"
text="Add DNS Server"
+ disabled={dns[0] === ""}
/>
diff --git a/ui/src/components/StaticIpv6Card.tsx b/ui/src/components/StaticIpv6Card.tsx
new file mode 100644
index 0000000..845f2ed
--- /dev/null
+++ b/ui/src/components/StaticIpv6Card.tsx
@@ -0,0 +1,107 @@
+import { LuPlus, LuX } from "react-icons/lu";
+import { useFieldArray, useFormContext } from "react-hook-form";
+import validator from "validator";
+import { useEffect } from "react";
+
+import { GridCard } from "@/components/Card";
+import { Button } from "@/components/Button";
+import { InputFieldWithLabel } from "@/components/InputField";
+
+export default function StaticIpv6Card() {
+ const formMethods = useFormContext();
+ const { register, formState, watch } = formMethods;
+
+ const { fields, append, remove } = useFieldArray({ name: "ipv6_static.dns" });
+
+ useEffect(() => {
+ if (fields.length === 0) append("");
+ }, [append, fields.length]);
+
+ const dns = watch("ipv6_static.dns");
+ return (
+