From bc3380b11822df14469c628f672d6dbae5005266 Mon Sep 17 00:00:00 2001 From: Oliver Bryan <04oliverbryan@gmail.com> Date: Mon, 29 Dec 2025 05:32:03 +0000 Subject: [PATCH] "completeAction" and custom "trigger" params --- .../src/components/create-organisation.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/frontend/src/components/create-organisation.tsx b/packages/frontend/src/components/create-organisation.tsx index 5dd6bc5..610a169 100644 --- a/packages/frontend/src/components/create-organisation.tsx +++ b/packages/frontend/src/components/create-organisation.tsx @@ -4,7 +4,6 @@ import { Dialog, DialogClose, DialogContent, - DialogDescription, DialogHeader, DialogTitle, DialogTrigger, @@ -19,10 +18,15 @@ const slugify = (value: string) => .toLowerCase() .replace(/[^a-z0-9]+/g, "-") .replace(/^-+/, "") - .replace(/-+$/, "") .replace(/-{2,}/g, "-"); -export function CreateOrganisation() { +export function CreateOrganisation({ + trigger, + completeAction, +}: { + trigger?: React.ReactNode; + completeAction?: () => void | Promise; +}) { const serverURL = import.meta.env.VITE_SERVER_URL?.trim() || "http://localhost:3000"; const userId = JSON.parse(localStorage.getItem("user") || "{}").id as number | undefined; @@ -106,7 +110,12 @@ export function CreateOrganisation() { } setOpen(false); - window.location.reload(); + reset(); + try { + await completeAction?.(); + } catch (actionErr) { + console.error(actionErr); + } } catch (err) { console.error(err); setError("failed to create organisation"); @@ -117,7 +126,7 @@ export function CreateOrganisation() { return ( - + {trigger || }