From 45c8ebd00280d8b4a2d1209db4764a77cca59f43 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Tue, 11 Jun 2024 11:35:58 +0200 Subject: [PATCH 1/2] Always select first integration type by default --- resources/ts/Pages/Integrations/New.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/ts/Pages/Integrations/New.tsx b/resources/ts/Pages/Integrations/New.tsx index 37cb95941..a1f700e1b 100644 --- a/resources/ts/Pages/Integrations/New.tsx +++ b/resources/ts/Pages/Integrations/New.tsx @@ -45,11 +45,13 @@ const New = ({ subscriptions }: Props) => { ) .map((subscription) => subscription.id); + const integrationTypesInfo = useIntegrationTypesInfo(); + const url = new URL(document.location.href); const activeTypeFromUrl = url.searchParams.get("type"); const activeType = isIntegrationType(activeTypeFromUrl) ? activeTypeFromUrl - : IntegrationType.EntryApi; + : integrationTypesInfo[0].type; const initialFormValues = { integrationType: activeType, @@ -95,7 +97,6 @@ const New = ({ subscriptions }: Props) => { [IntegrationType.SearchApi, IntegrationType.Widgets] as IntegrationType[] ).includes(data.integrationType); - const integrationTypesInfo = useIntegrationTypesInfo(); const pricingPlans = useGetPricingPlans(data.integrationType, subscriptions); return ( From 3343c2b4537e411ec9f0bf4fc37d546899141380 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Tue, 25 Jun 2024 12:25:31 +0200 Subject: [PATCH 2/2] Add safe access for integration type --- resources/ts/Pages/Integrations/New.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/ts/Pages/Integrations/New.tsx b/resources/ts/Pages/Integrations/New.tsx index a1f700e1b..3bde64454 100644 --- a/resources/ts/Pages/Integrations/New.tsx +++ b/resources/ts/Pages/Integrations/New.tsx @@ -51,7 +51,7 @@ const New = ({ subscriptions }: Props) => { const activeTypeFromUrl = url.searchParams.get("type"); const activeType = isIntegrationType(activeTypeFromUrl) ? activeTypeFromUrl - : integrationTypesInfo[0].type; + : integrationTypesInfo?.[0].type ?? IntegrationType.EntryApi; const initialFormValues = { integrationType: activeType,