diff --git a/src/components/general/client-row.tsx b/src/components/general/client-row.tsx
index a74ad0f..2d73867 100644
--- a/src/components/general/client-row.tsx
+++ b/src/components/general/client-row.tsx
@@ -58,6 +58,20 @@ export default function ClientRow({ client, rules }: Props) {
{client.name || "—"}
+
+ {typeof host_id == "number" ? (
+
+ {host_id == 0 ? "Main" : `Host #${host_id}`}
+
+ ) : (
+
+ —
+
+ )}
+ |
{client.wg_ip_address || "—"}
|
@@ -86,7 +100,7 @@ export default function ClientRow({ client, rules }: Props) {
{formatUnixTimestamp({ timestamp: client.created_at })}
-
+
);
-}
\ No newline at end of file
+}
diff --git a/src/pages/admin/clients/(functions)/submit-client-form.ts b/src/pages/admin/clients/(functions)/submit-client-form.ts
deleted file mode 100644
index 4e82ec9..0000000
--- a/src/pages/admin/clients/(functions)/submit-client-form.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import type { BUN_SQLITE_WGUI_CLIENTS } from "@/db/types/db";
-import adminCrudHandler from "@/src/functions/frontend/admin-crud-handler";
-import type { AddClientFormData } from "@/src/types";
-import type { Dispatch, SetStateAction } from "react";
-
-type Params = {
- setBusy: Dispatch>;
- busy: boolean;
- setError: Dispatch>;
- error?: string;
- data: AddClientFormData;
- open: boolean;
- setOpen: Dispatch>;
- onCreated?: () => void;
- host_id: number;
-};
-
-export default async function submitClientForm({
- busy,
- setBusy,
- setError,
- error,
- data,
- open,
- setOpen,
- onCreated,
- host_id,
-}: Params) {
- setBusy(true);
- setError(undefined);
-
- const res = await adminCrudHandler({
- action: "insert",
- table: "clients",
- insert_data: [
- {
- name: data.client_name || "",
- wg_ip_address: data.tunnel_ip || "",
- allowed_ips: data.allowed_ips || "",
- host_id,
- },
- ],
- });
-
- setBusy(false);
-
- if (!res.success) {
- setError(res.msg || "Could not add client");
- return;
- }
-
- setOpen(false);
- onCreated?.();
-}
diff --git a/src/pages/admin/clients/(partials)/client-form-action.tsx b/src/pages/admin/clients/(partials)/client-form-action.tsx
new file mode 100644
index 0000000..3ce9472
--- /dev/null
+++ b/src/pages/admin/clients/(partials)/client-form-action.tsx
@@ -0,0 +1,19 @@
+import Button from "@/src/components/twui/layout/Button";
+
+type Props = {
+ host_id: number;
+};
+
+export default function ClientFormAction({ host_id }: Props) {
+ const label =
+ host_id == 0 ? "Add client to Main Host" : `Add client to Host ${host_id}`;
+
+ return (
+
+ );
+}
\ No newline at end of file
diff --git a/src/pages/admin/clients/(partials)/client-form-host-select.tsx b/src/pages/admin/clients/(partials)/client-form-host-select.tsx
new file mode 100644
index 0000000..41655ff
--- /dev/null
+++ b/src/pages/admin/clients/(partials)/client-form-host-select.tsx
@@ -0,0 +1,27 @@
+import type { Dispatch, SetStateAction } from "react";
+import type { BUN_SQLITE_WGUI_HOSTS } from "@/db/types/db";
+import Select from "@/src/components/twui/form/Select";
+
+type Props = {
+ hosts: BUN_SQLITE_WGUI_HOSTS[];
+ host_id: number;
+ setHostId: Dispatch>;
+};
+
+export default function ClientFormHostSelect({
+ hosts,
+ host_id,
+ setHostId,
+}: Props) {
+ return (
+ |