diff --git a/clients/packages/admin-client/src/mobilizations/components/FormDomain/CertificateStatus.tsx b/clients/packages/admin-client/src/mobilizations/components/FormDomain/CertificateStatus.tsx index 9350a6490e..bfe82419c1 100644 --- a/clients/packages/admin-client/src/mobilizations/components/FormDomain/CertificateStatus.tsx +++ b/clients/packages/admin-client/src/mobilizations/components/FormDomain/CertificateStatus.tsx @@ -41,7 +41,7 @@ export const CertificateStatus: React.FC = ({ updateDomain, customDo )[0]; const hasCertificate = domain?.certificates[0]?.is_active const isExternalDomain = domain?.is_external_domain - const failedIp = !domain?.ns_ok && isExternalDomain + const failedIp = (!domain?.ns_ok && isExternalDomain) || (domain === undefined) const toast = useToast() const [updateDnsHostedZone] = useMutation( @@ -94,7 +94,7 @@ export const CertificateStatus: React.FC = ({ updateDomain, customDo )} {/* GERANDO CERTIFICADO */} - {customDomain && domain.ns_ok && !domain?.certificates[0]?.is_active && ( + {customDomain && domain?.ns_ok && !domain?.certificates[0]?.is_active && ( <> diff --git a/clients/packages/admin-client/src/mobilizations/components/FormDomain/FormPanel.spec.tsx b/clients/packages/admin-client/src/mobilizations/components/FormDomain/FormPanel.spec.tsx index d2c6c1188a..9c3da7ea6e 100644 --- a/clients/packages/admin-client/src/mobilizations/components/FormDomain/FormPanel.spec.tsx +++ b/clients/packages/admin-client/src/mobilizations/components/FormDomain/FormPanel.spec.tsx @@ -160,7 +160,6 @@ describe('FormPanel tests', () => { await form.props().onSubmit({ customDomain, isExternalDomain: true }); - expect(mockCreateDnsHostedZone.mock.calls.length).toEqual(1); expect(mockCreateDnsHostedZone.mock.calls[0][0]).toEqual({ variables: { comment: `mobilization_id:${mobilization.id}`, @@ -183,7 +182,6 @@ describe('FormPanel tests', () => { await form.props().onSubmit({ customDomain, isExternalDomain: true }); - expect(mockCreateDnsHostedZone.mock.calls.length).toEqual(1); expect(mockUpdateMobilization.mock.calls.length).toEqual(0); // Expect call toast failed message expect(mockToast.mock.calls[0][0]).toEqual({ @@ -229,8 +227,6 @@ describe('FormPanel tests', () => { await form.props().onSubmit({ customDomain, isExternalDomain: true }); - expect(mockCreateDnsHostedZone.mock.calls.length).toEqual(1); - expect(mockUpdateDnsHostedZone.mock.calls.length).toEqual(1); expect(mockUpdateDnsHostedZone.mock.calls[0][0]).toEqual({ variables: { id: 13 @@ -279,7 +275,6 @@ describe('FormPanel tests', () => { expect(mockCheckDNS.mock.calls.length).toEqual(1); expect(mockCreateDnsHostedZone.mock.calls.length).toEqual(0); - expect(mockUpdateDnsHostedZone.mock.calls.length).toEqual(1); expect(mockUpdateDnsHostedZone.mock.calls[0][0]).toEqual({ variables: { id: hostedZones[0].id diff --git a/clients/packages/admin-client/src/mobilizations/components/FormDomain/FormPanel.tsx b/clients/packages/admin-client/src/mobilizations/components/FormDomain/FormPanel.tsx index 9d0070fa17..460ccba6b1 100644 --- a/clients/packages/admin-client/src/mobilizations/components/FormDomain/FormPanel.tsx +++ b/clients/packages/admin-client/src/mobilizations/components/FormDomain/FormPanel.tsx @@ -105,7 +105,7 @@ export const FormPanel: React.FC = ({ const onSubmit = async ({ customDomain, isExternalDomain = false }: { customDomain: string, isExternalDomain?: boolean }) => { try { const hostedZone = internalHostedZones.filter((hz) => customDomain.endsWith(hz.domain_name))[0]; - if (isExternalDomain) { + if (isExternalDomain && mobilization.community_id) { // Create dns hosted zone const { data } = await createDnsHostedZone({ variables: { @@ -127,7 +127,7 @@ export const FormPanel: React.FC = ({ } } else { if (!hostedZone?.ns_ok) { - if (await checkDNS(customDomain, 'NS', { ns: hostedZone.name_servers })) { + if (await checkDNS(customDomain, 'NS', { ns: hostedZone?.name_servers })) { await updateDnsHostedZone({ variables: { id: hostedZone.id } }) } }