mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix(onboarding): step-org-create — simplify error handling, throw on empty name
This commit is contained in:
@@ -28,11 +28,11 @@ export const StepOrgCreate = () => {
|
|||||||
|
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
if (!name.trim()) return;
|
if (!name.trim()) throw new Error("Organisation name is required");
|
||||||
const result = await createOrganizationAction({ name: name.trim() });
|
const result = await createOrganizationAction({ name: name.trim() });
|
||||||
if (!result?.data?.success) {
|
if (!result?.data?.success) {
|
||||||
const data = result?.data;
|
const errorData = result?.data as { success: false; actionError?: any };
|
||||||
throw new Error((!data?.success && data?.actionError?.message) ? data.actionError.message : "Failed to create organisation");
|
throw new Error(errorData?.actionError?.message ?? "Failed to create organisation");
|
||||||
}
|
}
|
||||||
const org = result.data.value;
|
const org = result.data.value;
|
||||||
if (!org) throw new Error("Failed to create organisation");
|
if (!org) throw new Error("Failed to create organisation");
|
||||||
|
|||||||
Reference in New Issue
Block a user