Skip to content

Commit

Permalink
Merge branch 'main' of github.com:juspay/hyperswitch-control-center i…
Browse files Browse the repository at this point in the history
…nto group-drop-down-component
  • Loading branch information
Pritish Budhiraja committed Dec 15, 2023
2 parents 28d32c1 + 1ddbe68 commit eb765b7
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 77 deletions.
4 changes: 3 additions & 1 deletion src/components/ButtonGroupIp.res
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ let make = (

let buttons =
options
->Js.Array2.map(op => {
->Array.mapWithIndex((op, i) => {
let active = input.value->LogicUtils.getStringFromJson("") === op.value
if isSeparate {
<Button
key={i->string_of_int}
text={op.label}
onClick={_ => onChange(op.value)}
buttonType={active ? Primary : SecondaryFilled}
Expand All @@ -26,6 +27,7 @@ let make = (
/>
} else {
<Button
key={i->string_of_int}
text={op.label}
onClick={_ => onChange(op.value)}
textStyle={active ? "text-blue-800" : ""}
Expand Down
46 changes: 20 additions & 26 deletions src/components/Chip.res
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
@react.component
let make = (~values=[], ~showButton=false, ~onButtonClick=_ => (), ~converterFn=str => str) => {
<div>
{if values->Js.Array2.length !== 0 {
<div className="flex flex-wrap flex-row">
{values
->Js.Array2.map(value => {
let onClick = _evt => {
onButtonClick(value)
}
<div
className="px-4 py-2 m-2 mr-0.5 rounded-full border border-gray-300 bg-gradient-to-b from-jp-gray-200 to-jp-gray-300 dark:from-jp-gray-950 dark:to-jp-gray-950 text-gray-500 hover:shadow dark:text-jp-gray-text_darktheme dark:text-opacity-50 flex align-center w-max cursor-pointer transition duration-300 ease">
{React.string(value->converterFn)}
{if showButton {
<div className="float-right cursor-pointer mt-0.5 ml-0.5 opacity-50">
<Icon className="align-middle" size=14 name="times" onClick />
</div>
} else {
React.null
}}
</div>
})
->React.array}
</div>
} else {
React.null
}}
</div>
<UIUtils.RenderIf condition={values->Js.Array2.length !== 0}>
<div className="flex flex-wrap flex-row">
{values
->Js.Array2.map(value => {
let onClick = _evt => {
onButtonClick(value)
}
<div
className="px-4 py-2 m-2 mr-0.5 rounded-full border border-gray-300 bg-gradient-to-b from-jp-gray-200 to-jp-gray-300 dark:from-jp-gray-950 dark:to-jp-gray-950 text-gray-500 hover:shadow dark:text-jp-gray-text_darktheme dark:text-opacity-50 flex align-center w-max cursor-pointer transition duration-300 ease">
{React.string(value->converterFn)}
<UIUtils.RenderIf condition={showButton}>
<div className="float-right cursor-pointer mt-0.5 ml-0.5 opacity-50">
<Icon className="align-middle" size=14 name="times" onClick />
</div>
</UIUtils.RenderIf>
</div>
})
->React.array}
</div>
</UIUtils.RenderIf>
}
5 changes: 3 additions & 2 deletions src/components/CollapsableTableRow.res
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ let make = (
let cursorI = cellIndex == 0 ? "cursor-pointer" : ""
let location = `${title}_tr${(rowIndex + 1)->Belt.Int.toString}_td${(cellIndex + 1)
->Belt.Int.toString}`
<AddDataAttributes attributes=[("data-table-location", location)]>
<AddDataAttributes
key={cellIndex->string_of_int} attributes=[("data-table-location", location)]>
<td
key={string_of_int(cellIndex)}
className={`h-full p-0 align-top ${borderClass} ${hCell} ${cursorI}`}
Expand Down Expand Up @@ -81,7 +82,7 @@ let make = (
{item
->Js.Array2.mapi((obj, index) => {
let heading = headingArray->Belt.Array.get(index)->Belt.Option.getWithDefault("")
<UIUtils.RenderIf condition={index !== 0}>
<UIUtils.RenderIf condition={index !== 0} key={index->string_of_int}>
<div className="flex mb-5 justify-between">
<div className="text-jp-gray-900 opacity-50 font-medium">
{React.string(heading)}
Expand Down
5 changes: 3 additions & 2 deletions src/components/CustomExpandableTable.res
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ let make = (
let fontWeight = "font-bold"
let fontSize = "text-sm"
let paddingClass = "px-4 py-3"
<AddDataAttributes attributes=[("data-table-heading", item.title)]>
<th key={string_of_int(i)} className="p-0">
<AddDataAttributes
attributes=[("data-table-heading", item.title)] key={i->string_of_int}>
<th className="p-0">
<div
className={`flex flex-row ${borderClass} justify-between items-center ${paddingClass} ${bgColor} ${headerTextClass} whitespace-pre ${roundedClass}`}>
<div className={`${fontWeight} ${fontSize}`}>
Expand Down
19 changes: 9 additions & 10 deletions src/components/DynamicSingleStat.res
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ let make = (
)

<HSwitchSingleStatWidget
key={singleStatArrIndex->string_of_int}
title=info.title
tooltipText=info.tooltipText
deltaTooltipComponent={info.deltaTooltipComponent(info.statType)}
Expand All @@ -485,6 +486,7 @@ let make = (

| None =>
<HSwitchSingleStatWidget
key={singleStatArrIndex->string_of_int}
title=""
tooltipText=""
deltaTooltipComponent=React.null
Expand Down Expand Up @@ -520,16 +522,15 @@ let make = (
}
})

<AddDataAttributes attributes=[("data-dynamic-single-stats", "dynamic stats")]>
<div key={index->Belt.Int.toString}>
{if sectionName === "" {
React.null
} else {
<AddDataAttributes
attributes=[("data-dynamic-single-stats", "dynamic stats")] key={index->string_of_int}>
<div>
<UIUtils.RenderIf condition={sectionName !== ""}>
<div
className="mb-5 block pl-5 pt-5 not-italic font-bold text-fs-18 text-black dark:text-white">
{sectionName->React.string}
</div>
}}
</UIUtils.RenderIf>
{switch urlConfig.sectionInfo {
| Some(info) =>
<div
Expand All @@ -549,11 +550,9 @@ let make = (
<div className="flex flex-wrap w-full">
{singleStateArr
->Array.mapWithIndex((element, index) => {
if index < 4 || showStats {
<UIUtils.RenderIf condition={index < 4 || showStats} key={index->string_of_int}>
<div className="w-full md:w-1/2"> element </div>
} else {
React.null
}
</UIUtils.RenderIf>
})
->React.array}
</div>
Expand Down
7 changes: 5 additions & 2 deletions src/components/SelectBox.res
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ module ListItem = {
Js.String2.toLowerCase("_" ++ searchString)) &&
Js.String2.length(searchString) > 0
) {
<AddDataAttributes attributes=[("data-searched-text", item)]>
<AddDataAttributes
key={i->string_of_int} attributes=[("data-searched-text", item)]>
<mark
key={i->string_of_int} className={`${searchMatchTextColor} bg-transparent`}>
{item->React.string}
Expand All @@ -268,7 +269,8 @@ module ListItem = {
}

let selectOptions =
<AddDataAttributes attributes=[("data-text", labelText)]>
<AddDataAttributes
attributes=[("data-text", labelText)] key={i->string_of_int}>
<span key={i->string_of_int} className=textClass value=labelText>
{item->React.string}
</span>
Expand All @@ -277,6 +279,7 @@ module ListItem = {
{
if showToolTipOptions {
<ToolTip
key={i->string_of_int}
description=item
toolTipFor=selectOptions
contentAlign=Default
Expand Down
3 changes: 2 additions & 1 deletion src/components/Table.res
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ module TableRow = {
}
let location = `${title}_tr${(rowIndex + 1)->Belt.Int.toString}_td${(cellIndex + 1)
->Belt.Int.toString}`
<AddDataAttributes attributes=[("data-table-location", location)]>
<AddDataAttributes
key={cellIndex->string_of_int} attributes=[("data-table-location", location)]>
<td
key={string_of_int(cellIndex)}
className={`${tableRowBorderClass} ${customColorCell}`}
Expand Down
4 changes: 2 additions & 2 deletions src/components/tooltip/ToolTip.res
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ module DescriptionSection = {
{description
->Js.String2.split("\n")
->Js.Array2.filter(str => str !== "")
->Js.Array2.map(item => {
<AddDataAttributes attributes=[("data-text", item)]>
->Js.Array2.mapi((item, i) => {
<AddDataAttributes attributes=[("data-text", item)] key={i->string_of_int}>
<div key={item} className="flex flex-col gap-1"> {React.string(item)} </div>
</AddDataAttributes>
})
Expand Down
6 changes: 2 additions & 4 deletions src/genericUtils/BreadCrumbNavigation.res
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ let make = (
},
})
}
<UIUtils.RenderIf condition=showCrumb>
<div
key={Belt.Int.toString(index)}
className={`flex ${flexDirection} ${childGapClass} items-center`}>
<UIUtils.RenderIf key={Belt.Int.toString(index)} condition=showCrumb>
<div className={`flex ${flexDirection} ${childGapClass} items-center`}>
{if collapse {
<div
className="flex flex-row gap-1 text-jp-2-gray-100 font-medium items-center justify-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ module RenderConnectorInputFields = {
let keys =
details->Js.Dict.keys->Js.Array2.filter(ele => !Js.Array2.includes(keysToIgnore, ele))
keys
->Array.map(field => {
->Array.mapWithIndex((field, i) => {
let label = details->getString(field, "")
let formName = isLabelNested ? `${name}.${field}` : name
<UIUtils.RenderIf condition={label->Js.String2.length > 0}>
<UIUtils.RenderIf condition={label->Js.String2.length > 0} key={i->string_of_int}>
<div key={label}>
<FormRenderer.FieldRenderer
labelClass="font-semibold !text-hyperswitch_black"
Expand Down
10 changes: 6 additions & 4 deletions src/screens/HyperSwitch/FraudAndRisk/FRMPaymentMethods.res
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,12 @@ module CheckBoxRenderer = {
</div>
</div>
{frmConfigInfo.payment_methods
->Js.Array2.map(paymentMethodInfo => {
<UIUtils.RenderIf condition={isOpen}>
->Js.Array2.mapi((paymentMethodInfo, index) => {
<UIUtils.RenderIf condition={isOpen} key={index->string_of_int}>
{paymentMethodInfo.payment_method_types
->Js.Array2.map(paymentMethodTypeInfo => {
->Js.Array2.mapi((paymentMethodTypeInfo, i) => {
<Accordion
key={i->string_of_int}
initialExpandedArray=[0]
accordion={[
{
Expand Down Expand Up @@ -310,8 +311,9 @@ module PaymentMethodsRenderer = {
<PageLoaderWrapper screenState={pageState}>
<div className="flex flex-col gap-4">
{frmConfigs
->Js.Array2.map(configInfo => {
->Js.Array2.mapi((configInfo, i) => {
<CheckBoxRenderer
key={i->string_of_int}
frmConfigInfo={configInfo}
frmConfigs
connectorPaymentMethods={connectorConfig->Js.Dict.get(configInfo.gateway)}
Expand Down
12 changes: 6 additions & 6 deletions src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ module ConfigInfo = {
@react.component
let make = (~frmConfigs) => {
frmConfigs
->Js.Array2.map(config => {
<div className="grid grid-cols-2 md:w-1/2 ml-12 my-12">
->Js.Array2.mapi((config, i) => {
<div className="grid grid-cols-2 md:w-1/2 ml-12 my-12" key={i->string_of_int}>
<h4 className="text-lg font-semibold"> {config.gateway->snakeToTitle->React.string} </h4>
<div>
{config.payment_methods
->Js.Array2.map(paymentMethod => {
<div>
->Js.Array2.mapi((paymentMethod, ind) => {
<div key={ind->string_of_int}>
{paymentMethod.payment_method_types
->Array.mapWithIndex(
(paymentMethodType, i) => {
(paymentMethodType, index) => {
<InfoField
key={i->string_of_int}
key={index->string_of_int}
label={paymentMethodType.payment_method_type}
flowTypeValue={paymentMethodType.flow}
actionTypeValue={paymentMethodType.action}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open RoutingUtils
module SimplePreview = {
@react.component
let make = (~gateways) => {
if gateways->Js.Array2.length > 0 {
<UIUtils.RenderIf condition={gateways->Js.Array2.length > 0}>
<div
className="w-full mb-6 p-4 px-6 bg-white dark:bg-jp-gray-lightgray_background rounded-md border border-jp-gray-600 dark:border-jp-gray-850">
<div
Expand All @@ -23,9 +23,7 @@ module SimplePreview = {
->React.array}
</div>
</div>
} else {
React.null
}
</UIUtils.RenderIf>
}
}
module GatewayView = {
Expand Down Expand Up @@ -189,16 +187,15 @@ module RulePreviewer = {
{React.string(string_of_int(index + 1))}
</div>
<div> {gateway->React.string} </div>
{if index !== ruleInfo.default_gateways->Js.Array2.length - 1 {
<UIUtils.RenderIf
condition={index !== ruleInfo.default_gateways->Js.Array2.length - 1}>
<Icon
name="chevron-right"
size=14
className="cursor-pointer text-jp-gray-700"
onClick={ev => ()}
/>
} else {
React.null
}}
</UIUtils.RenderIf>
</div>
})
->React.array}
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/RoutingRevamp/AddRuleGateway.res
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ let make = (~id, ~gatewayOptions, ~isFirst=false, ~isExpanded=false) => {
{selectedOptions
->Array.mapWithIndex((item, i) => {
let key = string_of_int(i + 1)
<div className="flex flex-row">
<div key className="flex flex-row">
<div
className="w-min flex flex-row items-center justify-around gap-2 h-10 rounded-md border border-jp-gray-500 dark:border-jp-gray-960
text-jp-gray-900 text-opacity-75 hover:text-opacity-100 dark:text-jp-gray-text_darktheme dark:hover:text-jp-gray-text_darktheme
Expand Down
1 change: 1 addition & 0 deletions src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ For example: If card_type = credit && amount > 100, route 60% to Stripe and 40%
let id = {`${rulesJsonPath}[${string_of_int(index)}]`}

<Wrapper
key={index->string_of_int}
id
heading={`Rule ${string_of_int(index + 1)}`}
onClickAdd={_ => addRule(index, false)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ module LogicalOps = {

<ButtonGroup wrapperClass="flex flex-row mr-2 ml-1">
{["AND", "OR"]
->Js.Array2.map(text => {
->Array.mapWithIndex((text, i) => {
let active = logicalOpsInput.value->LogicUtils.getStringFromJson("") === text
<Button
key={i->string_of_int}
text
onClick={_ => onChange(text)}
textStyle={active ? "text-blue-800" : ""}
Expand Down Expand Up @@ -417,6 +418,7 @@ module MakeRuleField = {
<div className="flex flex-wrap items-center">
{Array.mapWithIndex(fields, (_, i) =>
<RuleFieldBase
key={i->string_of_int}
onClick={_ => onCrossClick(i)}
isFirst={i === 0}
id={`${ruleJsonPath}[${i->Belt.Int.toString}]`}
Expand Down
4 changes: 3 additions & 1 deletion src/screens/HyperSwitch/Settings/BusinessDetails.res
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ let make = () => {
className="flex flex-col md:flex-row justify-between bg-white p-7 gap-8 rounded-sm border border-jp-gray-border_gray">
<div className="w-full flex flex-col gap-5 md:gap-10">
{renderingArray
->Js.Array2.map(details => <DetailsSection details formState merchantInfo />)
->Js.Array2.mapi((details, i) =>
<DetailsSection key={i->string_of_int} details formState merchantInfo />
)
->React.array}
</div>
{switch formState {
Expand Down
4 changes: 2 additions & 2 deletions src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ module ExternalUser = {
{props => <>
<div className="px-1 py-1 ">
{options
->Js.Array2.map(option =>
<Menu.Item>
->Js.Array2.mapi((option, i) =>
<Menu.Item key={i->string_of_int}>
{props =>
<div className="relative">
<button
Expand Down
1 change: 1 addition & 0 deletions src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ module Configure3DSRule = {
let id = {`algorithm.rules[${string_of_int(index)}]`}
let i = 1
<AdvancedRouting.Wrapper
key={index->string_of_int}
id
heading={`Rule ${string_of_int(index + i)}`}
onClickAdd={_ => addRule(index, false)}
Expand Down
Loading

0 comments on commit eb765b7

Please sign in to comment.