diff --git a/CHANGELOG.md b/CHANGELOG.md index 261ce2aa8..227656b1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [conven - - - +## 1.28.1 (2024-01-23) + +### Bug Fixes + +- Use apifetcher function update ([#283](https://github.com/juspay/hyperswitch-control-center/pull/283)) ([`d587598`](https://github.com/juspay/hyperswitch-control-center/commit/d587598a1f13a234b68b5bc204780fda3c773e0e)) +- Changes for supporting form data type in api ([#257](https://github.com/juspay/hyperswitch-control-center/pull/257)) ([`84c283b`](https://github.com/juspay/hyperswitch-control-center/commit/84c283b8092e3296dc97c87725966d540f490d5b)) +- Access Control Issue ([#284](https://github.com/juspay/hyperswitch-control-center/pull/284)) ([`f35bcc5`](https://github.com/juspay/hyperswitch-control-center/commit/f35bcc524184c0c1bcc84a41198e81424bef7cc4)) + +**Full Changelog:** [`v1.28.0...v1.28.1`](https://github.com/juspay/hyperswitch-control-center/compare/v1.28.0...v1.28.1) + +- - - + + ## 1.28.0 (2024-01-22) ### Features diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res index 61ec1c785..fce80749f 100644 --- a/src/hooks/AuthHooks.res +++ b/src/hooks/AuthHooks.res @@ -23,6 +23,7 @@ let getHeaders = (~uri, ~headers, ()) => { let res = switch hyperSwitchToken { | Some(token) => { headers->Dict.set("authorization", `Bearer ${token}`) + headers->Dict.set("api-key", `hyperswitch`) headers } 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 056a0dcfd..eeca86bb1 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 9d577d105..28f247756 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..cb8ad12c5 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, ())} @@ -234,16 +233,16 @@ let make = (~isPayoutFlow=false) => { let (filteredConnectorData, setFilteredConnectorData) = React.useState(_ => []) let (offset, setOffset) = React.useState(_ => 0) let detailedCardCount = 5 - let showConnectorIcons = configuredConnectors->len > detailedCardCount + let showConnectorIcons = configuredConnectors->Array.length > 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 df5e51956..ed85f5ea3 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/ConnectorUIUtils/PaymentMethod.res b/src/screens/HyperSwitch/Connectors/ConnectorUIUtils/PaymentMethod.res index 3a469e1d3..9f7dccdf5 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorUIUtils/PaymentMethod.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorUIUtils/PaymentMethod.res @@ -6,8 +6,12 @@ let isSelectedAll = ( open ConnectorUtils let paymentMethodObj = selectedPaymentMethod->getSelectedPaymentObj(paymentMethod) switch paymentMethod->getPaymentMethodFromString { - | Card => paymentMethodObj.card_provider->Option.getWithDefault([])->len == allPaymentMethods->len - | _ => paymentMethodObj.provider->Option.getWithDefault([])->len == allPaymentMethods->len + | Card => + paymentMethodObj.card_provider->Option.getWithDefault([])->Array.length == + allPaymentMethods->Array.length + | _ => + paymentMethodObj.provider->Option.getWithDefault([])->Array.length == + allPaymentMethods->Array.length } } @@ -76,13 +80,13 @@ module CardRenderer = { if val.payment_method_type === paymentMethod { switch paymentMethod->getPaymentMethodTypeFromString { | Credit | Debit => - let length = val.card_provider->Option.getWithDefault([])->len + let length = val.card_provider->Option.getWithDefault([])->Array.length val.card_provider ->Option.getWithDefault([]) ->Array.splice(~start=0, ~remove=length, ~insert=arr) ->ignore | _ => - let length = val.provider->Option.getWithDefault([])->len + let length = val.provider->Option.getWithDefault([])->Array.length val.provider ->Option.getWithDefault([]) diff --git a/src/screens/HyperSwitch/Connectors/ConnectorUtils.res b/src/screens/HyperSwitch/Connectors/ConnectorUtils.res index ef6983e16..470b5aa2d 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorUtils.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorUtils.res @@ -17,9 +17,6 @@ let getStepName = step => { } } -let toLCase = str => str->String.toLowerCase -let len = arr => arr->Array.length - let payoutConnectorList: array = [ADYEN, WISE] let connectorList: array = [ @@ -88,7 +85,7 @@ let connectorListForLive: array = [ ] let getPaymentMethodFromString = paymentMethod => { - switch paymentMethod->toLCase { + switch paymentMethod->String.toLowerCase { | "card" => Card | "debit" | "credit" => Card | "paylater" => PayLater @@ -102,7 +99,7 @@ let getPaymentMethodFromString = paymentMethod => { } let getPaymentMethodTypeFromString = paymentMethodType => { - switch paymentMethodType->toLCase { + switch paymentMethodType->String.toLowerCase { | "credit" => Credit | "debit" => Debit | "google_pay" => GooglePay @@ -613,7 +610,7 @@ let ignoreFields = (json, id, fields) => { } let mapAuthType = (authType: string) => { - switch authType->toLCase { + switch authType->String.toLowerCase { | "bodykey" => #BodyKey | "headerkey" => #HeaderKey | "signaturekey" => #SignatureKey @@ -634,7 +631,9 @@ let getConnectorType = (connector, ~isPayoutFlow, ()) => { let getSelectedPaymentObj = (paymentMethodsEnabled: array, paymentMethod) => { paymentMethodsEnabled - ->Array.find(item => item.payment_method_type->toLCase == paymentMethod->toLCase) + ->Array.find(item => + item.payment_method_type->String.toLowerCase == paymentMethod->String.toLowerCase + ) ->Option.getWithDefault({ payment_method: "unknown", payment_method_type: "unkonwn", @@ -646,7 +645,7 @@ let addMethod = (paymentMethodsEnabled, paymentMethod, method) => { switch paymentMethod->getPaymentMethodFromString { | Card => pmts->Array.forEach((val: paymentMethodEnabled) => { - if val.payment_method_type->toLCase === paymentMethod->toLCase { + if val.payment_method_type->String.toLowerCase === paymentMethod->String.toLowerCase { val.card_provider ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) ->Array.push(method) @@ -654,7 +653,7 @@ let addMethod = (paymentMethodsEnabled, paymentMethod, method) => { }) | _ => pmts->Array.forEach((val: paymentMethodEnabled) => { - if val.payment_method_type->toLCase === paymentMethod->toLCase { + if val.payment_method_type->String.toLowerCase === paymentMethod->String.toLowerCase { val.provider ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) ->Array.push(method) @@ -669,7 +668,7 @@ let removeMethod = (paymentMethodsEnabled, paymentMethod, method: paymentMethodC switch paymentMethod->getPaymentMethodFromString { | Card => pmts->Array.forEach((val: paymentMethodEnabled) => { - if val.payment_method_type->toLCase === paymentMethod->toLCase { + if val.payment_method_type->String.toLowerCase === paymentMethod->String.toLowerCase { let indexOfRemovalItem = val.card_provider ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) @@ -688,7 +687,7 @@ let removeMethod = (paymentMethodsEnabled, paymentMethod, method: paymentMethodC | _ => pmts->Array.forEach((val: paymentMethodEnabled) => { - if val.payment_method_type->toLCase === paymentMethod->toLCase { + if val.payment_method_type->String.toLowerCase === paymentMethod->String.toLowerCase { let indexOfRemovalItem = val.provider ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) @@ -845,8 +844,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 +856,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 +865,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) } @@ -883,7 +881,7 @@ let getPlaceHolder = (connector: connectorName, fieldName, label) => { } } -let getConnectorDetailsValue = (connectorInfo: ConnectorTypes.connectorPayload, str) => { +let getConnectorDetailsValue = (connectorInfo: connectorPayload, str) => { switch str { | "api_key" => connectorInfo.connector_account_details.api_key | "api_secret" => connectorInfo.connector_account_details.api_secret @@ -895,19 +893,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), ]) @@ -1082,7 +1077,7 @@ let useFetchConnectorList = () => { } let defaultSelectAllCards = ( - pmts: array, + pmts: array, isUpdateFlow, isPayoutFlow, connector, @@ -1106,7 +1101,9 @@ let defaultSelectAllCards = ( ->getPaymentMethodMapper let length = - val.card_provider->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper)->len + val.card_provider + ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) + ->Array.length val.card_provider ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) ->Array.splice(~start=0, ~remove=length, ~insert=arr) @@ -1119,7 +1116,9 @@ let defaultSelectAllCards = ( ->getPaymentMethodMapper let length = - val.provider->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper)->len + val.provider + ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) + ->Array.length val.provider ->Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper) ->Array.splice(~start=0, ~remove=length, ~insert=arr) @@ -1167,3 +1166,23 @@ let getConnectorPaymentMethodDetails = async ( } } } + +let filterList = (items, ~removeFromList: 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: processors=FRMPlayer, ()) => { + open LogicUtils + json->getArrayFromJson([])->Array.map(getDictFromJsonObject)->filterList(~removeFromList) +} diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res index f83651a1b..bdc0fe990 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res @@ -48,6 +48,24 @@ let make = (~connectProcessorValue: connectProcessor) => { } } + React.useEffect1(() => { + if choiceState === #NotSelected { + setButtonState(_ => Button.Disabled) + } else { + setButtonState(_ => Button.Normal) + } + None + }, [choiceState]) + + React.useEffect1(() => { + if smartRoutingChoiceState === #NotSelected { + setButtonState(_ => Button.Disabled) + } else { + setButtonState(_ => Button.Normal) + } + None + }, [smartRoutingChoiceState]) + React.useEffect2(() => { setInitialValues(prevJson => { let prevJsonDict = prevJson->LogicUtils.getDictFromJsonObject @@ -185,6 +203,8 @@ let make = (~connectProcessorValue: connectProcessor) => { listChoices={connectorChoiceArray} nextButton={
} } +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 024230023..2da15c7fd 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