diff --git a/src/hooks/ListHooks.res b/src/hooks/ListHooks.res index 26931e8f9..038e96b48 100644 --- a/src/hooks/ListHooks.res +++ b/src/hooks/ListHooks.res @@ -1,5 +1,6 @@ open APIUtils let useListCount = (~entityName) => { + open ConnectorUtils let fetchDetails = useGetMethod() let (count, setCount) = React.useState(() => 0) @@ -11,15 +12,9 @@ let useListCount = (~entityName) => { let count = switch entityName { | ROUTING => response->getDictFromJsonObject->getArrayFromDict("records", [])->Array.length | CONNECTOR => - response - ->getObjectArrayFromJson - ->HSwitchUtils.filterList(~removeFromList=FRMPlayer) - ->Array.length + response->getObjectArrayFromJson->filterList(~removeFromList=FRMPlayer)->Array.length | FRAUD_RISK_MANAGEMENT => - response - ->getObjectArrayFromJson - ->HSwitchUtils.filterList(~removeFromList=Connector) - ->Array.length + response->getObjectArrayFromJson->filterList(~removeFromList=Connector)->Array.length | _ => response->getArrayFromJson([])->Array.length } setCount(_ => count) diff --git a/src/screens/HyperSwitch/Analytics/HomePageOverview/HomePageOverviewComponent.res b/src/screens/HyperSwitch/Analytics/HomePageOverview/HomePageOverviewComponent.res index 541bf598d..349c28a17 100644 --- a/src/screens/HyperSwitch/Analytics/HomePageOverview/HomePageOverviewComponent.res +++ b/src/screens/HyperSwitch/Analytics/HomePageOverview/HomePageOverviewComponent.res @@ -3,25 +3,21 @@ open HomeUtils module ConnectorOverview = { @react.component let make = () => { + open ConnectorUtils let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading) let (configuredConnectors, setConfiguredConnectors) = React.useState(_ => []) - let fetchConnectorListResponse = ConnectorUtils.useFetchConnectorList() + let fetchConnectorListResponse = useFetchConnectorList() let getConnectorList = async () => { open LogicUtils try { let response = await fetchConnectorListResponse() let connectorsList = - response->HSwitchUtils.getProcessorsListFromJson( - ~removeFromList=HSwitchUtils.FRMPlayer, - (), - ) + response->getProcessorsListFromJson(~removeFromList=ConnectorTypes.FRMPlayer, ()) let arr = connectorsList->Array.map(paymentMethod => - paymentMethod - ->getString("connector_name", "") - ->ConnectorUtils.getConnectorNameTypeFromString + paymentMethod->getString("connector_name", "")->getConnectorNameTypeFromString ) setConfiguredConnectors(_ => arr) setScreenState(_ => Success) @@ -42,7 +38,7 @@ module ConnectorOverview = { ->Array.mapWithIndex((connector, index) => { let iconStyle = `${index === 0 ? "" : "-ml-4"} z-${(30 - index * 10)->Js.Int.toString}` ConnectorUtils.getConnectorNameString->String.toUpperCase} + gateway={connector->getConnectorNameString->String.toUpperCase} className={`w-12 h-12 rounded-full border-3 border-white ${iconStyle} bg-white`} /> }) diff --git a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res index 50ddf3082..ab5523bc7 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res @@ -202,16 +202,13 @@ let make = (~setCurrentStep, ~setInitialValues, ~initialValues, ~isUpdateFlow, ~ | _ => "Loading..." } - let (suggestedAction, suggestedActionExists) = ConnectorUtils.getSuggestedAction( - ~verifyErrorMessage, - ~connector, - ) + let (suggestedAction, suggestedActionExists) = getSuggestedAction(~verifyErrorMessage, ~connector)
- ConnectorUtils.onSubmit( + onSubmit( ~values, ~onSubmitVerify, ~onSubmitMain, diff --git a/src/screens/HyperSwitch/Connectors/ConnectorList.res b/src/screens/HyperSwitch/Connectors/ConnectorList.res index 0250e758b..7b40eb854 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorList.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorList.res @@ -27,13 +27,14 @@ module NewProcessorCards = { ~showIcons: bool, ~isPayoutFlow: bool, ) => { + open ConnectorUtils let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom let connectorsAvailableForIntegration = featureFlagDetails.isLiveMode - ? ConnectorUtils.connectorListForLive + ? connectorListForLive : isPayoutFlow - ? ConnectorUtils.payoutConnectorList - : ConnectorUtils.connectorList + ? payoutConnectorList + : connectorList let unConfiguredConnectors = connectorsAvailableForIntegration->Array.filter(total => @@ -91,8 +92,8 @@ module NewProcessorCards = { className="grid gap-x-5 gap-y-6 2xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2 grid-cols-1 mb-5"> {connectorList ->Array.mapWithIndex((connector, i) => { - let connectorName = connector->ConnectorUtils.getConnectorNameString - let connectorInfo = connector->ConnectorUtils.getConnectorInfo + let connectorName = connector->getConnectorNameString + let connectorInfo = connector->getConnectorInfo let size = "w-14 h-14 rounded-sm"
{connectorList ->Array.mapWithIndex((connector, i) => { - let connectorName = connector->ConnectorUtils.getConnectorNameString + let connectorName = connector->getConnectorNameString let size = "w-14 h-14 rounded-sm" string_of_int} @@ -181,9 +182,7 @@ module NewProcessorCards = { let connectorListFiltered = { if searchedConnector->String.length > 0 { connectorsAvailableForIntegration->Array.filter(item => - item - ->ConnectorUtils.getConnectorNameString - ->String.includes(searchedConnector->String.toLowerCase) + item->getConnectorNameString->String.includes(searchedConnector->String.toLowerCase) ) } else { connectorsAvailableForIntegration @@ -196,7 +195,7 @@ module NewProcessorCards = { {connectorListFiltered->iconsConnectors("Connect a new connector", true, ())} { {featureFlagDetails.testProcessors - ->ConnectorUtils.dummyConnectorList + ->dummyConnectorList ->iconsConnectors("Connect a test connector", false, ~showSearch=false, ())} } @@ -204,7 +203,7 @@ module NewProcessorCards = { <> {featureFlagDetails.testProcessors - ->ConnectorUtils.dummyConnectorList + ->dummyConnectorList ->descriptedConnectors("Connect a test connector", false, ~showSearch=false, ())} {connectorListFiltered->descriptedConnectors("Connect a new connector", true, ())} @@ -236,14 +235,14 @@ let make = (~isPayoutFlow=false) => { let detailedCardCount = 5 let showConnectorIcons = configuredConnectors->len > detailedCardCount let (searchText, setSearchText) = React.useState(_ => "") - let fetchConnectorListResponse = ConnectorUtils.useFetchConnectorList() + let fetchConnectorListResponse = useFetchConnectorList() let getConnectorListAndUpdateState = async () => { open LogicUtils try { let response = await fetchConnectorListResponse() - let removeFromList = isPayoutFlow ? HSwitchUtils.PayoutConnector : HSwitchUtils.FRMPlayer - let connectorsList = response->HSwitchUtils.getProcessorsListFromJson(~removeFromList, ()) + let removeFromList = isPayoutFlow ? ConnectorTypes.PayoutConnector : ConnectorTypes.FRMPlayer + let connectorsList = response->getProcessorsListFromJson(~removeFromList, ()) let previousData = connectorsList->Array.map(ConnectorTableUtils.getProcessorPayloadType) setFilteredConnectorData(_ => previousData->Array.map(Js.Nullable.return)) diff --git a/src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res b/src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res index fc08d9674..a55d39358 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res @@ -28,7 +28,7 @@ let make = ( React.useEffect1(() => { setScreenState(_ => Loading) initialValues - ->ConnectorUtils.getConnectorPaymentMethodDetails( + ->getConnectorPaymentMethodDetails( setPaymentMethods, setMetaData, setScreenState, @@ -52,7 +52,7 @@ let make = ( let body = constructConnectorRequestBody(obj, initialValues)->ignoreFields( connectorID->Option.getWithDefault(""), - ConnectorUtils.connectorIgnoredField, + connectorIgnoredField, ) let connectorUrl = getURL(~entityName=CONNECTOR, ~methodType=Post, ~id=connectorID, ()) let response = await updateAPIHook(connectorUrl, body, Post) diff --git a/src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res b/src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res index c3f4e93c9..ace7fd93d 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res @@ -208,11 +208,9 @@ let getCell = (connector: connectorPayload, colType): Table.cell => { } } -let connectorsTableDefaultColumns = Recoil.atom(. "connectorsTableDefaultColumns", defaultColumns) - let getArrayDataFromJson = (json, itemToObjMapper: Js.Dict.t => connectorPayload) => { json - ->HSwitchUtils.getProcessorsListFromJson() + ->ConnectorUtils.getProcessorsListFromJson() ->Array.map(itemToObjMapper) ->Array.filter(item => !(item.connector_name->String.includes("apple"))) } diff --git a/src/screens/HyperSwitch/Connectors/ConnectorTypes.res b/src/screens/HyperSwitch/Connectors/ConnectorTypes.res index 9f01bbd29..b259a90cb 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorTypes.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorTypes.res @@ -211,3 +211,5 @@ type connectorPayload = { frm_configs?: array, status: string, } + +type processors = FRMPlayer | Connector | PayoutConnector diff --git a/src/screens/HyperSwitch/Connectors/ConnectorUtils.res b/src/screens/HyperSwitch/Connectors/ConnectorUtils.res index ef6983e16..e8dbf723a 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorUtils.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorUtils.res @@ -845,8 +845,8 @@ let validateConnectorRequiredFields = ( let walletType = fieldName->getPaymentMethodTypeFromString if walletType !== GooglePay && walletType !== ApplePay { let key = `metadata.${fieldName}` - let errorKey = connectorMetaDataFields->LogicUtils.getString(fieldName, "") - let value = valuesFlattenJson->LogicUtils.getString(`metadata.${fieldName}`, "") + let errorKey = connectorMetaDataFields->getString(fieldName, "") + let value = valuesFlattenJson->getString(`metadata.${fieldName}`, "") if value->String.length === 0 && connector->getMetaDataRequiredFields(fieldName) { Dict.set(newDict, key, `Please enter ${errorKey}`->Js.Json.string) } @@ -857,9 +857,8 @@ let validateConnectorRequiredFields = ( ->Dict.keysToArray ->Array.forEach(fieldName => { let key = `connector_webhook_details.${fieldName}` - let errorKey = connectorWebHookDetails->LogicUtils.getString(fieldName, "") - let value = - valuesFlattenJson->LogicUtils.getString(`connector_webhook_details.${fieldName}`, "") + let errorKey = connectorWebHookDetails->getString(fieldName, "") + let value = valuesFlattenJson->getString(`connector_webhook_details.${fieldName}`, "") if value->String.length === 0 && connector->getWebHookRequiredFields(fieldName) { Dict.set(newDict, key, `Please enter ${errorKey}`->Js.Json.string) } @@ -867,8 +866,8 @@ let validateConnectorRequiredFields = ( connectorLabelDetailField ->Dict.keysToArray ->Array.forEach(fieldName => { - let errorKey = connectorLabelDetailField->LogicUtils.getString(fieldName, "") - let value = valuesFlattenJson->LogicUtils.getString(fieldName, "") + let errorKey = connectorLabelDetailField->getString(fieldName, "") + let value = valuesFlattenJson->getString(fieldName, "") if value->String.length === 0 { Dict.set(newDict, fieldName, `Please enter ${errorKey}`->Js.Json.string) } @@ -895,19 +894,16 @@ let getConnectorDetailsValue = (connectorInfo: ConnectorTypes.connectorPayload, } let getConnectorFields = connectorDetails => { + open LogicUtils let connectorAccountDict = - connectorDetails->LogicUtils.getDictFromJsonObject->LogicUtils.getDictfromDict("connector_auth") + connectorDetails->getDictFromJsonObject->getDictfromDict("connector_auth") let bodyType = connectorAccountDict->Dict.keysToArray->Belt.Array.get(0)->Option.getWithDefault("") - let connectorAccountFields = connectorAccountDict->LogicUtils.getDictfromDict(bodyType) - let connectorMetaDataFields = - connectorDetails->LogicUtils.getDictFromJsonObject->LogicUtils.getDictfromDict("metadata") - let isVerifyConnector = - connectorDetails->LogicUtils.getDictFromJsonObject->LogicUtils.getBool("is_verifiable", false) + let connectorAccountFields = connectorAccountDict->getDictfromDict(bodyType) + let connectorMetaDataFields = connectorDetails->getDictFromJsonObject->getDictfromDict("metadata") + let isVerifyConnector = connectorDetails->getDictFromJsonObject->getBool("is_verifiable", false) let connectorWebHookDetails = - connectorDetails - ->LogicUtils.getDictFromJsonObject - ->LogicUtils.getDictfromDict("connector_webhook_details") + connectorDetails->getDictFromJsonObject->getDictfromDict("connector_webhook_details") let connectorLabelDetailField = Dict.fromArray([ ("connector_label", "Connector label"->Js.Json.string), ]) @@ -1167,3 +1163,27 @@ let getConnectorPaymentMethodDetails = async ( } } } + +let filterList = (items, ~removeFromList: ConnectorTypes.processors) => { + open LogicUtils + items->Array.filter(dict => { + let connectorType = dict->getString("connector_type", "") + let isPayoutConnector = connectorType == "payout_processor" + let isConnector = connectorType !== "payment_vas" && !isPayoutConnector + + switch removeFromList { + | Connector => !isConnector + | FRMPlayer => isConnector + | PayoutConnector => isPayoutConnector + } + }) +} + +let getProcessorsListFromJson = ( + json, + ~removeFromList: ConnectorTypes.processors=FRMPlayer, + (), +) => { + open LogicUtils + json->getArrayFromJson([])->Array.map(getDictFromJsonObject)->filterList(~removeFromList) +} diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res index 8478df27e..fb1e6228f 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res @@ -7,9 +7,10 @@ module SelectProcessor = { ~setConnectorConfigureState, ~connectorArray, ) => { + open ConnectorUtils let url = RescriptReactRouter.useUrl() let mixpanelEvent = MixpanelHook.useSendEvent() - let connectorName = selectedConnector->ConnectorUtils.getConnectorNameString + let connectorName = selectedConnector->getConnectorNameString let {setQuickStartPageState} = React.useContext(GlobalProvider.defaultContext) Array.filter(value => - !(connectorArray->Array.includes(value->ConnectorUtils.getConnectorNameString)) + connectorList={connectorList->Array.filter(value => + !(connectorArray->Array.includes(value->getConnectorNameString)) )} /> @@ -61,7 +62,7 @@ module ConfigureProcessor = { open ConnectorUtils let mixpanelEvent = MixpanelHook.useSendEvent() let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom - let connectorName = selectedConnector->ConnectorUtils.getConnectorNameString + let connectorName = selectedConnector->getConnectorNameString let connectorDetails = React.useMemo1(() => { try { @@ -85,7 +86,7 @@ module ConfigureProcessor = { ) = getConnectorFields(connectorDetails) let onSubmit = async (values, _) => { - let body = ConnectorUtils.generateInitialValuesDict( + let body = generateInitialValuesDict( ~values, ~connector=connectorName, ~bodyType, @@ -167,15 +168,16 @@ module SelectPaymentMethods = { ~setButtonState: (Button.buttonState => Button.buttonState) => unit, ~buttonState, ) => { + open ConnectorUtils let {quickStartPageState} = React.useContext(GlobalProvider.defaultContext) let updateAPIHook = APIUtils.useUpdateMethod() let showToast = ToastState.useShowToast() let mixpanelEvent = MixpanelHook.useSendEvent() let usePostEnumDetails = EnumVariantHook.usePostEnumDetails() - let connectorName = selectedConnector->ConnectorUtils.getConnectorNameString + let connectorName = selectedConnector->getConnectorNameString let (paymentMethodsEnabled, setPaymentMethods) = React.useState(_ => - Dict.make()->Js.Json.object_->ConnectorUtils.getPaymentMethodEnabled + Dict.make()->Js.Json.object_->getPaymentMethodEnabled ) let (metaData, setMetaData) = React.useState(_ => Dict.make()->Js.Json.object_) @@ -205,7 +207,7 @@ module SelectPaymentMethods = { payment_methods_enabled: paymentMethodsEnabled, metadata: metaData, } - let body = ConnectorUtils.constructConnectorRequestBody(obj, initialValues) + let body = constructConnectorRequestBody(obj, initialValues) let connectorUrl = APIUtils.getURL(~entityName=CONNECTOR, ~methodType=Post, ~id=None, ()) let response = await updateAPIHook(connectorUrl, body, Post) @@ -229,7 +231,7 @@ module SelectPaymentMethods = { React.useEffect1(() => { initialValues - ->ConnectorUtils.getConnectorPaymentMethodDetails( + ->getConnectorPaymentMethodDetails( setPaymentMethods, setMetaData, _ => (), diff --git a/src/screens/HyperSwitch/Home/QuickStart/QuickStartUIUtils.res b/src/screens/HyperSwitch/Home/QuickStart/QuickStartUIUtils.res index fdeb48537..fffa1464c 100644 --- a/src/screens/HyperSwitch/Home/QuickStart/QuickStartUIUtils.res +++ b/src/screens/HyperSwitch/Home/QuickStart/QuickStartUIUtils.res @@ -219,7 +219,7 @@ module SelectConnectorGrid = { HyperswitchAtom.connectorListAtom ->Recoil.useRecoilValueFromAtom ->LogicUtils.safeParse - ->HSwitchUtils.getProcessorsListFromJson() + ->ConnectorUtils.getProcessorsListFromJson() ->Array.map(connectorDict => connectorDict ->LogicUtils.getString("connector_name", "") diff --git a/src/screens/HyperSwitch/Home/QuickStart/QuickStartUtils.res b/src/screens/HyperSwitch/Home/QuickStart/QuickStartUtils.res index ecb4eb918..032278ef1 100644 --- a/src/screens/HyperSwitch/Home/QuickStart/QuickStartUtils.res +++ b/src/screens/HyperSwitch/Home/QuickStart/QuickStartUtils.res @@ -44,12 +44,6 @@ let connectorChoiceVariantToString = variantValue => | _ => "" } -let defaultChoiceStateValue: landingChoiceType = { - displayText: "Not Selected", - description: "Not Selected", - variantType: #NotSelected, -} - let connectorChoiceArray: array = [ { displayText: "Single Payment Processor", diff --git a/src/screens/HyperSwitch/Routing/PriorityRouting.res b/src/screens/HyperSwitch/Routing/PriorityRouting.res index 616597357..9b94723a5 100644 --- a/src/screens/HyperSwitch/Routing/PriorityRouting.res +++ b/src/screens/HyperSwitch/Routing/PriorityRouting.res @@ -266,7 +266,7 @@ let make = (~routingRuleId, ~isActive) => { let getConnectorsList = () => { let arr = connectorListJson - ->HSwitchUtils.getProcessorsListFromJson() + ->ConnectorUtils.getProcessorsListFromJson() ->Array.map(connectorDict => connectorDict->getString("connector_name", "")) ->Array.filter(x => x !== "applepay") ->getUniqueArray diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res index 64bdfb09b..05cd5109e 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res @@ -31,7 +31,7 @@ module ConnectorDetailsForm = { connectorVariant->getConnectorInfo }, [connectorName]) - let (suggestedAction, suggestedActionExists) = ConnectorUtils.getSuggestedAction( + let (suggestedAction, suggestedActionExists) = getSuggestedAction( ~verifyErrorMessage, ~connector={connectorName}, ) @@ -84,7 +84,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { open APIUtils let showToast = ToastState.useShowToast() let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom - let connectorName = selectedConnector->ConnectorUtils.getConnectorNameString + let connectorName = selectedConnector->getConnectorNameString let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading) let (isCheckboxSelected, setIsCheckboxSelected) = React.useState(_ => false) let connectorVariant = connectorName->getConnectorNameTypeFromString @@ -135,7 +135,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { let prevJsonDict = prevJson->LogicUtils.getDictFromJsonObject prevJsonDict->Dict.set( "connector_label", - `${selectedConnector->ConnectorUtils.getConnectorNameString}_${defaultBusinessProfile.profile_name}`->Js.Json.string, + `${selectedConnector->getConnectorNameString}_${defaultBusinessProfile.profile_name}`->Js.Json.string, ) prevJsonDict->Dict.set("profile_id", defaultBusinessProfile.profile_id->Js.Json.string) prevJsonDict->Js.Json.object_ @@ -203,7 +203,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { (), ) - let body = requestPayload->ConnectorUtils.constructConnectorRequestBody(payload) + let body = requestPayload->constructConnectorRequestBody(payload) let res = await updateDetails(url, body, Post) let connectorId = res->getDictFromJsonObject->getString("merchant_connector_id", "") @@ -342,7 +342,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { let dict = values->getDictFromJsonObject dict->Dict.set("profile_id", profile_id->Js.Json.string) - ConnectorUtils.onSubmit( + onSubmit( ~values={dict->Js.Json.object_}, ~onSubmitVerify, ~onSubmitMain, diff --git a/src/screens/HyperSwitch/SetupAccount/HSwitchSetupAccountUtils.res b/src/screens/HyperSwitch/SetupAccount/HSwitchSetupAccountUtils.res index d08a0ceff..4489cdf61 100644 --- a/src/screens/HyperSwitch/SetupAccount/HSwitchSetupAccountUtils.res +++ b/src/screens/HyperSwitch/SetupAccount/HSwitchSetupAccountUtils.res @@ -28,7 +28,7 @@ let constructBody = (~connectorName, ~json, ~profileId) => { ->Dict.fromArray ->Js.Json.object_ - let initialValueForPayload = ConnectorUtils.generateInitialValuesDict( + let initialValueForPayload = generateInitialValuesDict( ~values=[ ("profile_id", profileId->Js.Json.string), ("connector_account_details", connectorAccountDetails), @@ -100,8 +100,7 @@ let constructBody = (~connectorName, ~json, ~profileId) => { metadata: Dict.make()->Js.Json.object_, } - let requestPayloadDict = - requestPayload->ConnectorUtils.constructConnectorRequestBody(initialValueForPayload) + let requestPayloadDict = requestPayload->constructConnectorRequestBody(initialValueForPayload) requestPayloadDict } diff --git a/src/screens/HyperSwitch/HSwitchUtils.res b/src/screens/HyperSwitch/Utils/HSwitchUtils.res similarity index 83% rename from src/screens/HyperSwitch/HSwitchUtils.res rename to src/screens/HyperSwitch/Utils/HSwitchUtils.res index b36cc13d9..84eb0ba0f 100644 --- a/src/screens/HyperSwitch/HSwitchUtils.res +++ b/src/screens/HyperSwitch/Utils/HSwitchUtils.res @@ -1,34 +1,8 @@ open LogicUtils open HSLocalStorage open HyperswitchAtom +open UtilsTypes -type browserDetailsObject = { - userAgent: string, - browserVersion: string, - platform: string, - browserName: string, - browserLanguage: string, - screenHeight: string, - screenWidth: string, - timeZoneOffset: string, - clientCountry: Country.timezoneType, -} - -let feedbackModalOpenCountForConnectors = 4 - -let errorClass = "text-sm leading-4 font-medium text-start ml-1 mt-2" - -type pageLevelVariant = - | HOME - | PAYMENTS - | REFUNDS - | DISPUTES - | CONNECTOR - | ROUTING - | ANALYTICS_PAYMENTS - | ANALYTICS_REFUNDS - | SETTINGS - | DEVELOPERS module TextFieldRow = { @react.component let make = (~label, ~children, ~isRequired=true, ~labelWidth="w-72") => { @@ -36,17 +10,56 @@ module TextFieldRow = {
{label->React.string} - {if isRequired { + {"*"->React.string} - } else { - React.null - }} +
children
} } +module ConnectorCustomCell = { + @react.component + let make = (~connectorName) => { + if connectorName->String.length > 0 { +
+ String.toUpperCase} className="w-6 h-6 mr-2" /> +
{connectorName->React.string}
+
+ } else { + "NA"->React.string + } + } +} + +module BackgroundImageWrapper = { + @react.component + let make = ( + ~children=?, + ~backgroundImageUrl="/images/hyperswitchImages/PostLoginBackground.svg", + ~customPageCss="", + ~isBackgroundFullScreen=true, + ) => { + let heightWidthCss = isBackgroundFullScreen ? "h-screen w-screen" : "h-full w-full" + Option.isSome}> +
+ {children->Option.getWithDefault(React.null)} +
+
+ } +} + +let feedbackModalOpenCountForConnectors = 4 + +let errorClass = "text-sm leading-4 font-medium text-start ml-1 mt-2" + let setMerchantDetails = (key, value) => { let localStorageData = getInfoFromLocalStorage(~lStorageKey="merchant") localStorageData->Dict.set(key, value) @@ -71,20 +84,6 @@ let getSearchOptionsForProcessors = (~processorList, ~getNameFromString) => { searchOptionsForProcessors } -module ConnectorCustomCell = { - @react.component - let make = (~connectorName) => { - if connectorName->String.length > 0 { -
- String.toUpperCase} className="w-6 h-6 mr-2" /> -
{connectorName->React.string}
-
- } else { - "NA"->React.string - } - } -} - let isValidEmail = value => !Js.Re.test_( %re(`/^(([^<>()[\]\.,;:\s@"]+(\.[^<>()[\]\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/`), @@ -119,53 +118,6 @@ let getBrowswerDetails = () => { } } -module BackgroundImageWrapper = { - @react.component - let make = ( - ~children=?, - ~backgroundImageUrl="/images/hyperswitchImages/PostLoginBackground.svg", - ~customPageCss="", - ~isBackgroundFullScreen=true, - ) => { - let heightWidthCss = isBackgroundFullScreen ? "h-screen w-screen" : "h-full w-full" - Option.isSome}> -
- {children->Option.getWithDefault(React.null)} -
-
- } -} - -type processors = FRMPlayer | Connector | PayoutConnector - -let filterList = (items, ~removeFromList) => { - items->Array.filter(dict => { - let connectorType = dict->getString("connector_type", "") - let isPayoutConnector = connectorType == "payout_processor" - let isConnector = connectorType !== "payment_vas" && !isPayoutConnector - - switch removeFromList { - | Connector => !isConnector - | FRMPlayer => isConnector - | PayoutConnector => isPayoutConnector - } - }) -} - -let getProcessorsListFromJson = (json, ~removeFromList=FRMPlayer, ()) => { - json->getArrayFromJson([])->Array.map(getDictFromJsonObject)->filterList(~removeFromList) -} - -let getPageNameFromUrl = url => { - url->LogicUtils.getListHead -} - let getBodyForFeedBack = (values, ~modalType=HSwitchFeedBackModalUtils.FeedBackModal, ()) => { open HSwitchFeedBackModalUtils let email = getFromMerchantDetails("email") @@ -209,10 +161,10 @@ let getMetaData = (newMetadata, metaData) => { } let returnIntegrationJson = (integrationData: ProviderTypes.integration): Js.Json.t => { - Dict.fromArray([ + [ ("is_done", integrationData.is_done->Js.Json.boolean), ("metadata", integrationData.metadata), - ])->Js.Json.object_ + ]->getJsonFromArrayOfJson } let constructOnboardingBody = ( @@ -256,7 +208,7 @@ let constructOnboardingBody = ( | _ => () } - Dict.fromArray([ + [ ( "integration_checklist", copyOfIntegrationDetails.integration_checklist->returnIntegrationJson, @@ -267,19 +219,9 @@ let constructOnboardingBody = ( ), ("pricing_plan", copyOfIntegrationDetails.pricing_plan->returnIntegrationJson), ("account_activation", copyOfIntegrationDetails.account_activation->returnIntegrationJson), - ])->Js.Json.object_ + ]->getJsonFromArrayOfJson } -type textVariantType = - | H1 - | H2 - | H3 - | P1 - | P2 - | P3 -type paragraphTextType = Regular | Medium -type h3TextType = Leading_1 | Leading_2 - let getTextClass = (~textVariant, ~h3TextVariant=Leading_1, ~paragraphTextVariant=Regular, ()) => { switch (textVariant, h3TextVariant, paragraphTextVariant) { | (H1, _, _) => "text-fs-28 font-semibold leading-10" @@ -302,13 +244,9 @@ let checkStripePlusPayPal = (enumDetails: QuickStartTypes.responseType) => { enumDetails.stripeConnected.processorID->String.length > 0 && enumDetails.paypalConnected.processorID->String.length > 0 && enumDetails.sPTestPayment - ? true - : false } let checkWooCommerce = (enumDetails: QuickStartTypes.responseType) => { enumDetails.setupWoocomWebhook && enumDetails.firstProcessorConnected.processorID->String.length > 0 - ? true - : false } diff --git a/src/screens/HyperSwitch/Utils/UtilsTypes.res b/src/screens/HyperSwitch/Utils/UtilsTypes.res new file mode 100644 index 000000000..b234961e2 --- /dev/null +++ b/src/screens/HyperSwitch/Utils/UtilsTypes.res @@ -0,0 +1,34 @@ +type browserDetailsObject = { + userAgent: string, + browserVersion: string, + platform: string, + browserName: string, + browserLanguage: string, + screenHeight: string, + screenWidth: string, + timeZoneOffset: string, + clientCountry: Country.timezoneType, +} + +type pageLevelVariant = + | HOME + | PAYMENTS + | REFUNDS + | DISPUTES + | CONNECTOR + | ROUTING + | ANALYTICS_PAYMENTS + | ANALYTICS_REFUNDS + | SETTINGS + | DEVELOPERS + +type textVariantType = + | H1 + | H2 + | H3 + | P1 + | P2 + | P3 +type paragraphTextType = Regular | Medium + +type h3TextType = Leading_1 | Leading_2 diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res index 4734d8235..044bb3f72 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res @@ -2,7 +2,6 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, ~setAuthType) => { open HyperSwitchAuthUtils open APIUtils - open HSwitchUtils open HyperSwitchAuthForm open HSwitchGlobalVars open LogicUtils