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({
|
||||
mutationFn: async () => {
|
||||
if (!name.trim()) return;
|
||||
if (!name.trim()) throw new Error("Organisation name is required");
|
||||
const result = await createOrganizationAction({ name: name.trim() });
|
||||
if (!result?.data?.success) {
|
||||
const data = result?.data;
|
||||
throw new Error((!data?.success && data?.actionError?.message) ? data.actionError.message : "Failed to create organisation");
|
||||
const errorData = result?.data as { success: false; actionError?: any };
|
||||
throw new Error(errorData?.actionError?.message ?? "Failed to create organisation");
|
||||
}
|
||||
const org = result.data.value;
|
||||
if (!org) throw new Error("Failed to create organisation");
|
||||
|
||||
Reference in New Issue
Block a user