prevent org id taken error for flashing after create org

This commit is contained in:
miloschwartz
2025-06-18 16:22:01 -04:00
parent 0b8bb5a974
commit b56ba3ee23
4 changed files with 8 additions and 21 deletions

View File

@@ -45,6 +45,7 @@ export default function StepperForm() {
const [loading, setLoading] = useState(false);
const [isChecked, setIsChecked] = useState(false);
const [error, setError] = useState<string | null>(null);
const [orgCreated, setOrgCreated] = useState(false);
const orgSchema = z.object({
orgName: z.string().min(1, { message: t('orgNameRequired') }),
@@ -63,7 +64,7 @@ export default function StepperForm() {
const router = useRouter();
const checkOrgIdAvailability = useCallback(async (value: string) => {
if (loading) {
if (loading || orgCreated) {
return;
}
try {
@@ -76,7 +77,7 @@ export default function StepperForm() {
} catch (error) {
setOrgIdTaken(false);
}
}, []);
}, [loading, orgCreated, api]);
const debouncedCheckOrgIdAvailability = useCallback(
debounce(checkOrgIdAvailability, 300),
@@ -108,7 +109,7 @@ export default function StepperForm() {
});
if (res && res.status === 201) {
// setCurrentStep("site");
setOrgCreated(true);
router.push(`/${values.orgId}/settings/sites/create`);
}
} catch (e) {