diff --git a/frontend/src/components/AddDomainWizard.jsx b/frontend/src/components/AddDomainWizard.jsx index 1614377..b52b6e4 100644 --- a/frontend/src/components/AddDomainWizard.jsx +++ b/frontend/src/components/AddDomainWizard.jsx @@ -88,7 +88,7 @@ const AddDomainWizard = ({ onClose, onSuccess, customer }) => { }; // Step 2: Select CF account type - const handleStep2Next = () => { + const handleStep2Next = async () => { if (!cfAccountType) { setError('Please select a Cloudflare account option'); return; @@ -100,7 +100,29 @@ const AddDomainWizard = ({ onClose, onSuccess, customer }) => { } setError(null); - setCurrentStep(3); + + // If company account, create domain immediately and skip to step 4 + if (cfAccountType === 'company') { + setLoading(true); + try { + const response = await api.post('/api/customer/domains', { + domain_name: domainName, + cf_account_type: 'company', + cf_account_id: selectedCompanyAccount.id, + }); + + setDomainId(response.data.domain.id); + setDnsPreview(response.data.dns_preview); + setNsInstructions(response.data.ns_instructions); + setCurrentStep(4); // Skip step 3, go directly to NS setup + } catch (err) { + setError(err.response?.data?.error || 'Failed to create domain'); + } finally { + setLoading(false); + } + } else { + setCurrentStep(3); // Go to API token input + } }; // Step 3: Handle based on account type