Skip to content

Commit

Permalink
fix: Quick start connector selection bug and connector list bug fixes (
Browse files Browse the repository at this point in the history
…#482)

Co-authored-by: Pritish Budhiraja <[email protected]>
  • Loading branch information
Riddhiagrawal001 and Pritish Budhiraja authored Mar 7, 2024
1 parent 180a40a commit 2dfb70f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/screens/Connectors/ConnectorUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
57 changes: 36 additions & 21 deletions src/screens/Home/QuickStart/QuickStartUIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

<div className="flex flex-col gap-12">
<UIUtils.RenderIf condition={popularConnectorList->Array.length > 0}>
Expand All @@ -258,9 +275,7 @@ module SelectConnectorGrid = {
</p>
</div>
<Icon
name={connector === selectedConnector ? "selected" : "nonselected"}
size=20
className="cursor-pointer !text-blue-800"
name={connector->iconColor} size=20 className="cursor-pointer !text-blue-800"
/>
</div>
})
Expand Down
10 changes: 10 additions & 0 deletions src/screens/Home/QuickStart/QuickStartUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -705,3 +705,13 @@ let getCurrentStep = dict => {
#GoLive
}
}

let existsInArray = (element, connectorList) => {
open ConnectorTypes
connectorList->Array.some(e =>
switch (e, element) {
| (Processors(p1), Processors(p2)) => p1 == p2
| (_, _) => false
}
)
}
5 changes: 3 additions & 2 deletions src/screens/Processors/ProcessorCards.res
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ let make = (
let connectorInfo = connector->getConnectorInfo
let size = "w-14 h-14 rounded-sm"
<AddDataAttributes attributes=[("data-testid", connectorName->String.toLowerCase)]>
<div
<ACLDiv
permission={userPermissionJson.connectorsManage}
onClick={_ => handleClick(connectorName)}
key={i->string_of_int}
className="border p-6 gap-4 bg-white rounded flex flex-col justify-between">
Expand All @@ -129,7 +130,7 @@ let make = (
buttonSize={Small}
textStyle="text-jp-gray-900"
/>
</div>
</ACLDiv>
</AddDataAttributes>
})
->React.array}
Expand Down

0 comments on commit 2dfb70f

Please sign in to comment.