Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Refactoring key errors (#98) #99

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 @@ -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
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: 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
8 changes: 6 additions & 2 deletions src/screens/HyperSwitch/Utils/HSSelfServeSidebar.res
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ let make = (~heading, ~sidebarOptions: array<sidebarOption>=[]) => {
}
let subOptionsArray = sidebarOption.subOptions->Belt.Option.getWithDefault([])

<div className={`p-6 border-y border-gray-200 cursor-pointer ${background}`} onClick>
<div
key={i->string_of_int}
className={`p-6 border-y border-gray-200 cursor-pointer ${background}`}
onClick>
<div
key={i->Belt.Int.toString}
className={`grid grid-cols-12 items-center ${textColor} font-medium gap-5`}>
Expand All @@ -79,14 +82,15 @@ let make = (~heading, ~sidebarOptions: array<sidebarOption>=[]) => {
condition={sidebarOption.status === ONGOING && subOptionsArray->Array.length > 0}>
<div className="my-4">
{subOptionsArray
->Js.Array2.map(subOption => {
->Js.Array2.mapi((subOption, i) => {
let (subIcon, subIconColor, subBackground, subFont) = switch subOption.status {
| COMPLETED => ("check", "green", "", "text-gray-600")
| PENDING => ("nonselected", "text-gray-100", "", "text-gray-400")
| ONGOING => ("nonselected", "", "bg-gray-100", "font-semibold")
}

<div
key={i->string_of_int}
className={`flex gap-1 items-center pl-6 py-2 rounded-md my-1 ${subBackground} ${subFont}`}>
<Icon name=subIcon customIconColor=subIconColor customHeight="14" />
<span className="flex-1"> {subOption.title->React.string} </span>
Expand Down
Loading