fix(onboarding): step-org-create — simplify error handling, throw on empty name

This commit is contained in:
Théo LAGACHE
2026-06-18 11:39:18 +02:00
parent 19776344a3
commit 4ea5babba6
@@ -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");