select newly created project/org

This commit is contained in:
Oliver Bryan
2025-12-29 05:50:50 +00:00
parent 034b1a1d72
commit 7355570a0b
3 changed files with 50 additions and 10 deletions

View File

@@ -25,7 +25,7 @@ export function CreateOrganisation({
completeAction,
}: {
trigger?: React.ReactNode;
completeAction?: () => void | Promise<void>;
completeAction?: (organisationId: number) => void | Promise<void>;
}) {
const serverURL = import.meta.env.VITE_SERVER_URL?.trim() || "http://localhost:3000";
@@ -109,10 +109,17 @@ export function CreateOrganisation({
return;
}
const organisation = (await res.json()) as { id?: number };
if (!organisation.id) {
setError("failed to create organisation");
setSubmitting(false);
return;
}
setOpen(false);
reset();
try {
await completeAction?.();
await completeAction?.(organisation.id);
} catch (actionErr) {
console.error(actionErr);
}