From 2dfb70f82d86e240a7d00f57f42e710528e186c3 Mon Sep 17 00:00:00 2001 From: Riddhiagrawal001 <50551695+Riddhiagrawal001@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:20:28 +0530 Subject: [PATCH] fix: Quick start connector selection bug and connector list bug fixes (#482) Co-authored-by: Pritish Budhiraja <1805317@kiit.ac.in> --- src/screens/Connectors/ConnectorUtils.res | 4 +- .../Home/QuickStart/QuickStartUIUtils.res | 57 ++++++++++++------- .../Home/QuickStart/QuickStartUtils.res | 10 ++++ src/screens/Processors/ProcessorCards.res | 5 +- 4 files changed, 51 insertions(+), 25 deletions(-) diff --git a/src/screens/Connectors/ConnectorUtils.res b/src/screens/Connectors/ConnectorUtils.res index e49a1864c..861587538 100644 --- a/src/screens/Connectors/ConnectorUtils.res +++ b/src/screens/Connectors/ConnectorUtils.res @@ -1244,7 +1244,7 @@ let getProcessorsListFromJson = (json, ~removeFromList: processors=FRMPlayer, () json->getArrayFromJson([])->Array.map(getDictFromJsonObject)->filterList(~removeFromList) } -let getDisplayNameForConnector = connector => +let getDisplayNameForProcessor = connector => switch connector { | ADYEN => "Adyen" | CHECKOUT => "Checkout" @@ -1308,7 +1308,7 @@ let getDisplayNameForThreedsAuthenticator = threeDsAuthenticator => let getDisplayNameForConnector = connector => { let connectorType = connector->String.toLowerCase->getConnectorNameTypeFromString() switch connectorType { - | Processors(connector) => connector->getDisplayNameForConnector + | Processors(connector) => connector->getDisplayNameForProcessor | ThreeDsAuthenticator(threeDsAuthenticator) => threeDsAuthenticator->getDisplayNameForThreedsAuthenticator | UnknownConnector(str) => str diff --git a/src/screens/Home/QuickStart/QuickStartUIUtils.res b/src/screens/Home/QuickStart/QuickStartUIUtils.res index 52d0e7d03..c0d320329 100644 --- a/src/screens/Home/QuickStart/QuickStartUIUtils.res +++ b/src/screens/Home/QuickStart/QuickStartUIUtils.res @@ -215,29 +215,46 @@ module SelectConnectorGrid = { ->LogicUtils.getString("connector_name", "") ->ConnectorUtils.getConnectorNameTypeFromString() ) - let popularConnectorList = [ - Processors(STRIPE), - Processors(PAYPAL), - Processors(ADYEN), - Processors(CHECKOUT), - ]->Array.filter(connector => { - !(typedConnectedConnectorList->Array.includes(connector)) - }) - let remainingConnectorList = - connectorList->Array.filter(value => - !( - popularConnectorList->Array.includes(value) || - typedConnectedConnectorList->Array.includes(value) - ) + let popularConnectorList = + [ + Processors(STRIPE), + Processors(PAYPAL), + Processors(ADYEN), + Processors(CHECKOUT), + ]->Array.filter(connector => + !QuickStartUtils.existsInArray(connector, typedConnectedConnectorList) ) + let remainingConnectorList = connectorList->Array.filter(value => { + let existInPopularConnectorList = QuickStartUtils.existsInArray(value, popularConnectorList) + + let existInTypedConnectorList = QuickStartUtils.existsInArray( + value, + typedConnectedConnectorList, + ) + + !(existInPopularConnectorList || existInTypedConnectorList) + }) + let headerClass = HSwitchUtils.getTextClass((P1, Medium)) let subheaderText = "text-base font-semibold text-grey-700" - let getBlockColor = connector => - selectedConnector === connector - ? "border border-blue-700 bg-blue-700 bg-opacity-10 " - : "border" + let getBlockColor = connector => { + switch (selectedConnector, connector) { + | (Processors(selectedConnector), Processors(connectorValue)) + if selectedConnector === + connectorValue => "border border-blue-700 bg-blue-700 bg-opacity-10" + | _ => "border" + } + } + + let iconColor = connector => { + switch (selectedConnector, connector) { + | (Processors(selectedConnector), Processors(connectorValue)) + if selectedConnector === connectorValue => "selected" + | _ => "nonselected" + } + }