mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 10:33:01 +00:00
select newly created project/org
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export function CreateProject({
|
||||
}: {
|
||||
organisationId?: number;
|
||||
trigger?: React.ReactNode;
|
||||
completeAction?: () => void | Promise<void>;
|
||||
completeAction?: (projectId: number) => void | Promise<void>;
|
||||
}) {
|
||||
const serverURL = import.meta.env.VITE_SERVER_URL?.trim() || "http://localhost:3000";
|
||||
|
||||
@@ -113,10 +113,17 @@ export function CreateProject({
|
||||
return;
|
||||
}
|
||||
|
||||
const project = (await res.json()) as { id?: number };
|
||||
if (!project.id) {
|
||||
setError("failed to create project");
|
||||
setSubmitting(false);
|
||||
return;
|
||||
}
|
||||
|
||||
setOpen(false);
|
||||
reset();
|
||||
try {
|
||||
await completeAction?.();
|
||||
await completeAction?.(project.id);
|
||||
} catch (actionErr) {
|
||||
console.error(actionErr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user