From dbcb8efcbc3e0eeaf35562f1a771510546678c47 Mon Sep 17 00:00:00 2001 From: Riddhi Agrawal Date: Wed, 13 Dec 2023 17:11:22 +0530 Subject: [PATCH] fix: connector label and profile id default value fix --- .../ConfigureConnector.res | 13 +++++++++ .../CommonConnectorFlow/SetupConnector.res | 1 + .../SetupConnectorCredentials.res | 29 ++++++++++++++++--- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res index 3f539e137..0c6ece28c 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res @@ -51,6 +51,19 @@ let make = (~connectProcessorValue: connectProcessor) => { } } + React.useEffect2(() => { + setInitialValues(prevJson => { + let prevJsonDict = prevJson->LogicUtils.getDictFromJsonObject + prevJsonDict->Js.Dict.set( + "connector_label", + `${selectedConnector->ConnectorUtils.getConnectorNameString}_${activeBusinessProfile.profile_name}`->Js.Json.string, + ) + prevJsonDict->Js.Json.object_ + }) + + None + }, (selectedConnector, activeBusinessProfile.profile_name)) + let volumeBasedRoutingAPICall = async () => { try { open LogicUtils diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res index 82cdf8b01..a1640eb9b 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res @@ -148,6 +148,7 @@ module ConfigureProcessor = { checkboxText="" /> + } } diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res index 505ce095b..e1f3206ad 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res @@ -15,6 +15,7 @@ module ConnectorDetailsForm = { ~verifyErrorMessage, ~checkboxText, ) => { + let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom let (showVerifyModal, setShowVerifyModal) = React.useState(_ => false) let ( @@ -37,6 +38,11 @@ module ConnectorDetailsForm = { )
+ + + getConnectorNameTypeFromString} @@ -86,6 +92,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { let (connectorDetails, setConnectorDetails) = React.useState(_ => Js.Json.null) let (isLoading, setIsLoading) = React.useState(_ => false) let merchantId = HSLocalStorage.getFromMerchantDetails("merchant_id") + let (initialValues, setInitialValues) = React.useState(_ => Js.Json.null) let getDetails = async () => { let _wasmResult = await Window.connectorWasmInit() @@ -110,12 +117,28 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { connectorWebHookDetails, connectorLabelDetailField, ) = getConnectorFields(connectorDetails) + let businessProfiles = Recoil.useRecoilValueFromAtom(HyperswitchAtom.businessProfilesAtom) + let defaultBusinessProfile = businessProfiles->MerchantAccountUtils.getValueFromBusinessProfile let (suggestedAction, suggestedActionExists) = getSuggestedAction( ~verifyErrorMessage, ~connector={connectorName}, ) + React.useEffect1(() => { + setInitialValues(prevJson => { + let prevJsonDict = prevJson->LogicUtils.getDictFromJsonObject + prevJsonDict->Js.Dict.set( + "connector_label", + `${selectedConnector->ConnectorUtils.getConnectorNameString}_${defaultBusinessProfile.profile_name}`->Js.Json.string, + ) + prevJsonDict->Js.Dict.set("profile_id", defaultBusinessProfile.profile_id->Js.Json.string) + prevJsonDict->Js.Json.object_ + }) + + None + }, [selectedConnector]) + let {profile_id} = HyperswitchAtom.businessProfilesAtom ->Recoil.useRecoilValueFromAtom @@ -349,10 +372,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { } -
Js.Json.object_} - onSubmit={handleSubmit} - validate={validateMandatoryField}> +
@@ -396,6 +416,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { suggestedAction setVerifyDone /> + }