Skip to content

Commit

Permalink
fix: code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Riddhiagrawal001 committed Jan 24, 2024
1 parent 7b05196 commit 26120f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,25 @@ let handleConnectorIntegrated = (
handleStateToNextPage()->ignore
}

let handleObjectResponse = (
~dict,
~setSetupAccountStatus,
~setInitialValues,
~connector,
~handleStateToNextPage,
) => {
let dictkey = dict->Dict.keysToArray->LogicUtils.getValueFromArray(0, "")

switch dictkey->stringToVariantMapper {
| Ppcp_custom_denied => setSetupAccountStatus(._ => dictkey->stringToVariantMapper)
| Connector_integrated =>
handleConnectorIntegrated(
~dictValue=dict,
~setInitialValues,
let handleObjectResponse = (~dict, ~setInitialValues, ~connector, ~handleStateToNextPage) => {
open LogicUtils
let dictkey = dict->Dict.keysToArray->getValueFromArray(0, "")
if dictkey->stringToVariantMapper === Connector_integrated {
let values = dict->getJsonObjectFromDict("connector_integrated")
let bodyTypeValue =
values
->getDictFromJsonObject
->getDictfromDict("connector_account_details")
->getString("auth_type", "")
let body = ConnectorUtils.generateInitialValuesDict(
~values,
~connector,
~handleStateToNextPage,
~bodyType=bodyTypeValue,
~isPayoutFlow=false,
(),
)
| _ => setSetupAccountStatus(._ => dictkey->stringToVariantMapper)
setInitialValues(_ => body)
handleStateToNextPage()
}
}

Expand Down
10 changes: 3 additions & 7 deletions src/screens/HyperSwitch/Connectors/ConnectorHome.res
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,16 @@ let make = (~isPayoutFlow=false, ~showStepIndicator=true, ~showBreadCrumb=true)
setCurrentStep(_ => AutomaticFlow)
}
| JSONObject(dict) =>
handleObjectResponse(
~dict,
~setSetupAccountStatus,
~setInitialValues,
~connector,
~handleStateToNextPage={_ => setCurrentStep(_ => PaymentMethods)},
handleObjectResponse(~dict, ~setInitialValues, ~connector, ~handleStateToNextPage=_ =>
setCurrentStep(_ => PaymentMethods)
)
| _ => ()
}
setScreenState(_ => PageLoaderWrapper.Success)
} catch {
| _ => setScreenState(_ => PageLoaderWrapper.Custom)
}
}, (connector, setInitialValues, setSetupAccountStatus))
}, (connector, initialValues, setSetupAccountStatus))

let customUiForPaypal =
<DefaultLandingPage
Expand Down

0 comments on commit 26120f3

Please sign in to comment.