diff --git a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res index e14743f44..53dd7aeba 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res @@ -1,187 +1,3 @@ -let connectorsWithIntegrationSteps: array = [ - ADYEN, - CHECKOUT, - STRIPE, - PAYPAL, -] - -let mixpanelEventWrapper = ( - ~url: RescriptReactRouter.url, - ~selectedConnector, - ~actionName, - ~hyperswitchMixPanel: HSMixPanel.functionType, -) => { - if selectedConnector->Js.String2.length > 0 { - [selectedConnector, "global"]->Js.Array2.forEach(ele => - hyperswitchMixPanel( - ~pageName=url.path->LogicUtils.getListHead, - ~contextName=ele, - ~actionName, - (), - ) - ) - } -} - -module BusinessProfileRender = { - @react.component - let make = (~isUpdateFlow: bool, ~selectedConnector) => { - let url = RescriptReactRouter.useUrl() - let hyperswitchMixPanel = HSMixPanel.useSendEvent() - let {setDashboardPageState} = React.useContext(GlobalProvider.defaultContext) - let businessProfiles = Recoil.useRecoilValueFromAtom(HyperswitchAtom.businessProfilesAtom) - let arrayOfBusinessProfile = businessProfiles->MerchantAccountUtils.getArrayOfBusinessProfile - let defaultBusinessProfile = businessProfiles->MerchantAccountUtils.getValueFromBusinessProfile - let connectorLabelOnChange = ReactFinalForm.useField(`connector_label`).input.onChange - - let (showModalFromOtherScreen, setShowModalFromOtherScreen) = React.useState(_ => false) - - let hereTextStyle = isUpdateFlow - ? "text-grey-700 opacity-50 cursor-not-allowed" - : "text-blue-900 cursor-pointer" - - <> - - InputFields.selectInput( - ~input={ - ...input, - onChange: { - ev => { - let profileName = ( - arrayOfBusinessProfile - ->Js.Array2.find((ele: HSwitchSettingTypes.profileEntity) => - ele.profile_id === ev->Identity.formReactEventToString - ) - ->Belt.Option.getWithDefault(defaultBusinessProfile) - ).profile_name - connectorLabelOnChange( - `${selectedConnector}_${profileName}`->Identity.stringToFormReactEvent, - ) - input.onChange(ev) - mixpanelEventWrapper( - ~url, - ~selectedConnector, - ~actionName=`settings_choose_profile`, - ~hyperswitchMixPanel, - ) - } - }, - }, - ~deselectDisable=true, - ~disableSelect=isUpdateFlow, - ~customStyle="max-h-48", - ~options={ - arrayOfBusinessProfile->MerchantAccountUtils.businessProfileNameDropDownOption - }, - ~buttonText="Select Profile", - ~placeholder="", - (), - ), - (), - )} - /> - -
- {"Manage your list of profiles."->React.string} - { - setDashboardPageState(_ => #HOME) - RescriptReactRouter.push("/business-profiles") - }}> - {React.string("here.")} - -
-
- - - } -} - -module VerifyConnectoModal = { - @react.component - let make = ( - ~showVerifyModal, - ~setShowVerifyModal, - ~connector, - ~verifyErrorMessage, - ~suggestedActionExists, - ~suggestedAction, - ~setVerifyDone, - ) => { - let hyperswitchMixPanel = HSMixPanel.useSendEvent() - let url = RescriptReactRouter.useUrl() - { - setVerifyDone(_ => NoAttempt) - setShowVerifyModal(_ => false) - }}> -
-
-
- warning -
-
- {"Are you sure you want to proceed?"->React.string} -
-
- {`Received the following error from ${connector->LogicUtils.snakeToTitle}:`->React.string} -
-
- {`${verifyErrorMessage->Belt.Option.getWithDefault("")}`->React.string} -
- - {suggestedAction} - -
-
-
- -
-
-
-
- } -} - @react.component let make = ( ~currentStep, @@ -503,7 +319,7 @@ let make = ( - = [ + ADYEN, + CHECKOUT, + STRIPE, + PAYPAL, +] + let getCurrencyOption: CurrencyUtils.currencyCode => SelectBox.dropdownOption = currencyType => { open CurrencyUtils { @@ -236,3 +243,174 @@ module ConnectorConfigurationFields = { } } + +module BusinessProfileRender = { + @react.component + let make = (~isUpdateFlow: bool, ~selectedConnector) => { + let url = RescriptReactRouter.useUrl() + let hyperswitchMixPanel = HSMixPanel.useSendEvent() + let {setDashboardPageState} = React.useContext(GlobalProvider.defaultContext) + let businessProfiles = Recoil.useRecoilValueFromAtom(HyperswitchAtom.businessProfilesAtom) + let arrayOfBusinessProfile = businessProfiles->MerchantAccountUtils.getArrayOfBusinessProfile + let defaultBusinessProfile = businessProfiles->MerchantAccountUtils.getValueFromBusinessProfile + let connectorLabelOnChange = ReactFinalForm.useField(`connector_label`).input.onChange + + let (showModalFromOtherScreen, setShowModalFromOtherScreen) = React.useState(_ => false) + + let hereTextStyle = isUpdateFlow + ? "text-grey-700 opacity-50 cursor-not-allowed" + : "text-blue-900 cursor-pointer" + let _onClickHandler = countryOrLabel => { + if !isUpdateFlow { + setShowModalFromOtherScreen(_ => true) + ConnectorUtils.mixpanelEventWrapper( + ~url, + ~selectedConnector, + ~actionName=`add_new_${countryOrLabel}`, + ~hyperswitchMixPanel, + ) + } + setDashboardPageState(_ => #HOME) + } + + <> + + InputFields.selectInput( + ~input={ + ...input, + onChange: { + ev => { + let profileName = ( + arrayOfBusinessProfile + ->Js.Array2.find((ele: HSwitchSettingTypes.profileEntity) => + ele.profile_id === ev->Identity.formReactEventToString + ) + ->Belt.Option.getWithDefault(defaultBusinessProfile) + ).profile_name + connectorLabelOnChange( + `${selectedConnector}_${profileName}`->Identity.stringToFormReactEvent, + ) + input.onChange(ev) + ConnectorUtils.mixpanelEventWrapper( + ~url, + ~selectedConnector, + ~actionName=`settings_choose_profile`, + ~hyperswitchMixPanel, + ) + } + }, + }, + ~deselectDisable=true, + ~disableSelect=isUpdateFlow, + ~customStyle="max-h-48", + ~options={ + arrayOfBusinessProfile->MerchantAccountUtils.businessProfileNameDropDownOption + }, + ~buttonText="Select Profile", + ~placeholder="", + (), + ), + (), + )} + /> + +
+ {"Manage your list of profiles."->React.string} + { + setDashboardPageState(_ => #HOME) + RescriptReactRouter.push("/business-profiles") + }}> + {React.string("here.")} + +
+
+ + + } +} + +module VerifyConnectorModal = { + @react.component + let make = ( + ~showVerifyModal, + ~setShowVerifyModal, + ~connector, + ~verifyErrorMessage, + ~suggestedActionExists, + ~suggestedAction, + ~setVerifyDone, + ) => { + let hyperswitchMixPanel = HSMixPanel.useSendEvent() + let url = RescriptReactRouter.useUrl() + { + setVerifyDone(_ => NoAttempt) + setShowVerifyModal(_ => false) + }}> +
+
+
+ warning +
+
+ {"Are you sure you want to proceed?"->React.string} +
+
+ {`Received the following error from ${connector->LogicUtils.snakeToTitle}:`->React.string} +
+
+ {`${verifyErrorMessage->Belt.Option.getWithDefault("")}`->React.string} +
+ + {suggestedAction} + +
+
+
+ +
+
+
+
+ } +} diff --git a/src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res b/src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res index db23c7c4b..1e910e50e 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res @@ -1,7 +1,15 @@ open ConnectorTypes type colType = - Name | TestMode | Status | Actions | ProfileId | ProfileName | ConnectorLabel | PaymentMethods + | Name + | TestMode + | Status + | Disabled + | Actions + | ProfileId + | ProfileName + | ConnectorLabel + | PaymentMethods let defaultColumns = [ Name, @@ -9,6 +17,7 @@ let defaultColumns = [ ProfileName, ConnectorLabel, Status, + Disabled, TestMode, Actions, PaymentMethods, @@ -119,6 +128,7 @@ let getProcessorPayloadType = dict => { profile_id: dict->getString("profile_id", ""), merchant_connector_id: dict->getString("merchant_connector_id", ""), frm_configs: dict->getArrayFromDict("frm_configs", [])->convertFRMConfigJsonToObj, + status: dict->getString("status", "inactive"), } } @@ -151,7 +161,8 @@ let getHeading = colType => { switch colType { | Name => Table.makeHeaderInfo(~key="connector_name", ~title="Processor", ~showSort=false, ()) | TestMode => Table.makeHeaderInfo(~key="test_mode", ~title="Test Mode", ~showSort=false, ()) - | Status => Table.makeHeaderInfo(~key="disabled", ~title="Status", ~showSort=false, ()) + | Status => Table.makeHeaderInfo(~key="status", ~title="Status", ~showSort=false, ()) + | Disabled => Table.makeHeaderInfo(~key="disabled", ~title="Disabled", ~showSort=false, ()) | Actions => Table.makeHeaderInfo(~key="actions", ~title="", ~showSort=false, ()) | ProfileId => Table.makeHeaderInfo(~key="profile_id", ~title="Profile Id", ~showSort=false, ()) | ProfileName => @@ -167,10 +178,11 @@ let getCell = (connector: connectorPayload, colType): Table.cell => { switch colType { | Name => Text(connector.connector_name->LogicUtils.getTitle) | TestMode => Text(connector.test_mode ? "True" : "False") + | Disabled => Text(connector.disabled ? "True" : "False") | Status => Label({ - title: (connector.disabled ? "Disabled" : "Enabled")->Js.String2.toUpperCase, - color: connector.disabled ? LabelRed : LabelGreen, + title: connector.status->Js.String2.toUpperCase, + color: connector.status === "inactive" ? LabelRed : LabelGreen, }) | ProfileId => Text(connector.profile_id) | ProfileName => diff --git a/src/screens/HyperSwitch/Connectors/ConnectorTypes.res b/src/screens/HyperSwitch/Connectors/ConnectorTypes.res index cfa47adaf..aae08ea04 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorTypes.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorTypes.res @@ -208,4 +208,5 @@ type connectorPayload = { metadata?: Js.Json.t, merchant_connector_id: string, frm_configs?: array, + status: string, } diff --git a/src/screens/HyperSwitch/Connectors/ConnectorUtils.res b/src/screens/HyperSwitch/Connectors/ConnectorUtils.res index 6efda5fa1..f6acebf53 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorUtils.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorUtils.res @@ -1029,6 +1029,7 @@ let constructConnectorRequestBody = (wasmRequest: wasmRequest, payload: Js.Json. let dict = Js.Dict.fromArray([ ("connector_account_details", connectorAccountDetails), ("connector_label", dict->getString("connector_label", "")->Js.Json.string), + ("status", dict->getString("status", "active")->Js.Json.string), ]) values ->getDictFromJsonObject @@ -1135,3 +1136,21 @@ let getConnectorPaymentMethodDetails = async ( } } } + +let mixpanelEventWrapper = ( + ~url: RescriptReactRouter.url, + ~selectedConnector, + ~actionName, + ~hyperswitchMixPanel: HSMixPanel.functionType, +) => { + if selectedConnector->Js.String2.length > 0 { + [selectedConnector, "global"]->Js.Array2.forEach(ele => + hyperswitchMixPanel( + ~pageName=url.path->LogicUtils.getListHead, + ~contextName=ele, + ~actionName, + (), + ) + ) + } +} diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res b/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res index 33224ae07..730cdaa64 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res @@ -48,7 +48,9 @@ module AdvanceSettings = {

- + } @@ -240,9 +242,8 @@ let make = ( let updateDetails = useUpdateMethod() - open ConnectorAccountDetails React.useEffect1(() => { - mixpanelEventWrapper( + ConnectorUtils.mixpanelEventWrapper( ~url, ~selectedConnector=frmName, ~actionName=`${isUpdateFlow ? "settings_entry_updateflow" : "settings_entry"}`, diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res index a1640eb9b..f56874670 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res @@ -134,7 +134,7 @@ module ConfigureProcessor = { loadingText="Processing..." text="Proceed" buttonSize={Small} />}> - diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res index 4031cdcde..0bd6b074a 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res @@ -38,7 +38,7 @@ module ConnectorDetailsForm = {
- @@ -51,7 +51,7 @@ module ConnectorDetailsForm = { bodyType connectorLabelDetailField /> - { {getComponentToRender()}
-