From e997476b31f87ccc16e71522d3ca36aaab7c9122 Mon Sep 17 00:00:00 2001
From: "gpt-engineer-app[bot]"
<159125892+gpt-engineer-app[bot]@users.noreply.github.com>
Date: Thu, 23 Apr 2026 21:55:30 +0000
Subject: [PATCH 1/2] Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
---
src/routes/clients.$clientId.tsx | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/routes/clients.$clientId.tsx b/src/routes/clients.$clientId.tsx
index 34e0f9f..faf6bc9 100644
--- a/src/routes/clients.$clientId.tsx
+++ b/src/routes/clients.$clientId.tsx
@@ -227,11 +227,19 @@ function ClientDetail() {
{client.board_members.map((m: any, i: number) => (
-
-
{m.name}
- {m.role &&
{m.role}}
- {m.email &&
{m.email}}
- {m.phone &&
{m.phone}}
+
+
+ {m.name}
+ {m.role && {m.role}}
+
+
))}
From 1629c5c135644a16740ada6e7508029f2db06a17 Mon Sep 17 00:00:00 2001
From: "gpt-engineer-app[bot]"
<159125892+gpt-engineer-app[bot]@users.noreply.github.com>
Date: Thu, 23 Apr 2026 21:55:45 +0000
Subject: [PATCH 2/2] Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
---
src/components/clients/client-form-dialog.tsx | 44 +++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/src/components/clients/client-form-dialog.tsx b/src/components/clients/client-form-dialog.tsx
index 78282fa..efd14a2 100644
--- a/src/components/clients/client-form-dialog.tsx
+++ b/src/components/clients/client-form-dialog.tsx
@@ -134,6 +134,50 @@ export function ClientFormDialog({
toast.error("Could not save client", { description: error.message });
return;
}
+
+ // Auto-create contacts for board members that aren't already in contacts
+ try {
+ const members = (values.board_members || []).filter((m) => m.name?.trim());
+ if (members.length > 0) {
+ const emails = members.map((m) => m.email?.trim().toLowerCase()).filter(Boolean) as string[];
+ const names = members.map((m) => m.name.trim());
+ const { data: existing } = await supabase
+ .from("contacts")
+ .select("name,email")
+ .or(
+ [
+ emails.length ? `email.in.(${emails.join(",")})` : "",
+ `name.in.(${names.map((n) => `"${n.replace(/"/g, '\\"')}"`).join(",")})`,
+ ]
+ .filter(Boolean)
+ .join(","),
+ );
+ const existingEmails = new Set((existing ?? []).map((c) => c.email?.toLowerCase()).filter(Boolean));
+ const existingNames = new Set((existing ?? []).map((c) => c.name?.toLowerCase()));
+ const toInsert = members
+ .filter((m) => {
+ const e = m.email?.trim().toLowerCase();
+ if (e && existingEmails.has(e)) return false;
+ if (existingNames.has(m.name.trim().toLowerCase())) return false;
+ return true;
+ })
+ .map((m) => ({
+ name: m.name.trim(),
+ title: m.role?.trim() || null,
+ email: m.email?.trim() || null,
+ phone: m.phone?.trim() || null,
+ contact_type: "board_member",
+ created_by: user?.id ?? null,
+ }));
+ if (toInsert.length > 0) {
+ await supabase.from("contacts").insert(toInsert);
+ }
+ }
+ } catch (e) {
+ // Non-fatal
+ console.warn("Board member contact sync failed", e);
+ }
+
toast.success(client ? "Client updated" : "Client created");
onOpenChange(false);
onSaved?.();