Skip to content

Commit

Permalink
Merge branch 'main' into multi-filters-support
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarnaikjuspay committed Jan 2, 2024
2 parents a311bfe + ad40573 commit 3704f20
Show file tree
Hide file tree
Showing 12 changed files with 220 additions and 108 deletions.
Binary file modified public/hyperswitch/wasm/euclid_bg.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion public/hyperswitch/wasm/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "euclid_wasm",
"name": "euclid_wasm_vas",
"description": "WASM bindings for Euclid DSL",
"version": "0.1.0",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/components/TableUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ module TableCell = {
| Text(x) | DropDown(x) => {
let x = x === "" ? "NA" : x
<AddDataAttributes attributes=[("data-desc", x)]>
<div className={"whitespace-nowrap"}> {highlightedText(x, highlightText)} </div>
<div> {highlightedText(x, highlightText)} </div>
</AddDataAttributes>
}

Expand Down
15 changes: 14 additions & 1 deletion src/screens/HyperSwitch/Connectors/ConnectorPreview.res
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,20 @@ module ConnectorSummaryGrid = {
connectorDetails,
)

let connectorStatusStyle = connectorStatus =>
switch connectorStatus {
| "active" => "border bg-green-600 bg-opacity-40 border-green-700"
| _ => "border bg-red-600 bg-opacity-40 border-red-400"
}

<div className="p-2 md:px-10">
<div className="grid grid-cols-4 my-12">
<h4 className="text-lg font-semibold"> {"Integration status"->React.string} </h4>
<div
className={`px-4 py-2 rounded-full w-fit text-black font-medium text-sm ${connectorInfo.status->connectorStatusStyle}`}>
{connectorInfo.status->Js.String2.toUpperCase->React.string}
</div>
</div>
<div className="grid grid-cols-4 my-12">
<div className="flex items-start">
<h4 className="text-lg font-semibold"> {"Webhook Endpoint"->React.string} </h4>
Expand Down Expand Up @@ -291,7 +304,7 @@ let make = (
className={`text-fs-13 font-bold ${isConnectorDisabled
? "text-red-800"
: "text-green-700"}`}>
{(isConnectorDisabled ? "INACTIVE" : "ACTIVE")->React.string}
{(isConnectorDisabled ? "DISABLED" : "ENABLED")->React.string}
</p>
<UIUtils.RenderIf condition={showMenuOption}>
<MenuOption setCurrentStep disableConnector isConnectorDisabled connectorInfo />
Expand Down
27 changes: 9 additions & 18 deletions src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,17 @@ let convertFRMConfigJsonToObj = json => {

let getPaymentMethodTypes = dict => {
open LogicUtils
open ConnectorUtils
{
payment_method_type: dict->getString("payment_method_type", ""),
payment_experience: dict->getString("payment_method_type", ""),
payment_experience: dict->getOptionString("payment_method_type"),
card_networks: dict->getStrArrayFromDict("card_networks", []),
accepted_countries: {
options: {
type_: "",
list: [],
},
},
accepted_currencies: {
options: {
type_: "",
list: [],
},
},
minimum_amount: dict->getInt("minimum_amount", 0),
maximum_amount: dict->getInt("maximum_amount", 0),
recurring_enabled: dict->getBool("recurring_enabled", false),
installment_payment_enabled: dict->getBool("installment_payment_enabled", false),
accepted_countries: dict->getDictfromDict("accepted_countries")->acceptedValues,
accepted_currencies: dict->getDictfromDict("accepted_countries")->acceptedValues,
minimum_amount: dict->getOptionInt("minimum_amount"),
maximum_amount: dict->getOptionInt("maximum_amount"),
recurring_enabled: dict->getOptionBool("recurring_enabled"),
installment_payment_enabled: dict->getOptionBool("installment_payment_enabled"),
}
}

Expand Down Expand Up @@ -161,7 +152,7 @@ let getHeading = colType => {
switch colType {
| Name => Table.makeHeaderInfo(~key="connector_name", ~title="Processor", ~showSort=false, ())
| TestMode => Table.makeHeaderInfo(~key="test_mode", ~title="Test Mode", ~showSort=false, ())
| Status => Table.makeHeaderInfo(~key="status", ~title="Status", ~showSort=false, ())
| Status => Table.makeHeaderInfo(~key="status", ~title="Integration status", ~showSort=false, ())
| Disabled => Table.makeHeaderInfo(~key="disabled", ~title="Disabled", ~showSort=false, ())
| Actions => Table.makeHeaderInfo(~key="actions", ~title="", ~showSort=false, ())
| ProfileId => Table.makeHeaderInfo(~key="profile_id", ~title="Profile Id", ~showSort=false, ())
Expand Down
42 changes: 21 additions & 21 deletions src/screens/HyperSwitch/Connectors/ConnectorTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,30 @@ type paymentMethodTypes =
| ApplePay
| UnknownPaymentMethodType(string)

type advancedConfigurationList = {
@as("type") type_: string,
list: array<string>,
}

type advancedConfiguration = {options: advancedConfigurationList}

type paymentMethodConfigType = {
payment_method_type: string,
card_networks: array<string>,
accepted_currencies: option<advancedConfigurationList>,
accepted_countries: option<advancedConfigurationList>,
minimum_amount: option<int>,
maximum_amount: option<int>,
recurring_enabled: option<bool>,
installment_payment_enabled: option<bool>,
payment_experience: option<string>,
}

type paymentMethodEnabled = {
payment_method: string,
payment_method_type: string,
provider?: array<string>,
card_provider?: array<string>,
provider?: array<paymentMethodConfigType>,
card_provider?: array<paymentMethodConfigType>,
}

type applePay = {
Expand Down Expand Up @@ -154,25 +173,6 @@ type connectorAccountDetails = {
key2?: string,
}

type advancedConfigurationList = {
@as("type") type_: string,
list: array<string>,
}

type advancedConfiguration = {options: advancedConfigurationList}

type paymentMethodConfigType = {
payment_method_type: string,
card_networks?: array<string>,
accepted_currencies?: advancedConfiguration,
accepted_countries?: advancedConfiguration,
minimum_amount: int,
maximum_amount: int,
recurring_enabled: bool,
installment_payment_enabled: bool,
payment_experience?: string,
}

type paymentMethodEnabledType = {
payment_method: string,
payment_method_types: array<paymentMethodConfigType>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,44 @@ module CardRenderer = {
~updateDetails,
~paymentMethodsEnabled: array<paymentMethodEnabled>,
~paymentMethod,
~provider,
~provider: array<paymentMethodConfigType>,
~_showAdvancedConfiguration,
~metaData,
~setMetaData,
~connector,
) => {
let (showWalletConfigurationModal, setShowWalletConfigurationModal) = React.useState(_ => false)
let (selectedWallet, setSelectedWallet) = React.useState(_ => "")
let (selectedWallet, setSelectedWallet) = React.useState(_ =>
Js.Dict.empty()->itemProviderMapper
)
let selectedAll = isSelectedAll(paymentMethodsEnabled, provider, paymentMethod)

let paymentObj = paymentMethodsEnabled->getSelectedPaymentObj(paymentMethod)
let standardProviders = paymentObj.provider->Belt.Option.getWithDefault([])
let cardProviders = paymentObj.card_provider->Belt.Option.getWithDefault([])
let standardProviders =
paymentObj.provider->Belt.Option.getWithDefault([]->Js.Json.array->getPaymentMethodMapper)
let cardProviders =
paymentObj.card_provider->Belt.Option.getWithDefault(
[]->Js.Json.array->getPaymentMethodMapper,
)

let removeOrAddMethods = method => {
let checkPaymentMethodType = (
obj: paymentMethodConfigType,
selectedMethod: paymentMethodConfigType,
) => obj.payment_method_type == selectedMethod.payment_method_type

let removeOrAddMethods = (method: paymentMethodConfigType) => {
switch paymentMethod->getPaymentMethodFromString {
| Card =>
if cardProviders->Js.Array2.includes(method) {
if cardProviders->Js.Array2.some(obj => checkPaymentMethodType(obj, method)) {
paymentMethodsEnabled->removeMethod(paymentMethod, method)->updateDetails
} else {
paymentMethodsEnabled->addMethod(paymentMethod, method)->updateDetails
}

| _ =>
if standardProviders->Js.Array2.includes(method) {
if standardProviders->Js.Array2.some(obj => checkPaymentMethodType(obj, method)) {
paymentMethodsEnabled->removeMethod(paymentMethod, method)->updateDetails
} else {
let methodVariant = method->getPaymentMethodTypeFromString
let methodVariant = method.payment_method_type->getPaymentMethodTypeFromString
if (
(methodVariant === GooglePay || methodVariant === ApplePay) &&
(connector->getConnectorNameTypeFromString !== TRUSTPAY &&
Expand All @@ -66,7 +76,7 @@ module CardRenderer = {
}

let updateSelectAll = (paymentMethod, isSelectedAll) => {
let arr = isSelectedAll ? [] : provider->LogicUtils.getUniqueArray
let arr = isSelectedAll ? [] : provider
paymentMethodsEnabled->Js.Array2.forEach(val => {
if val.payment_method_type === paymentMethod {
switch paymentMethod->getPaymentMethodTypeFromString {
Expand All @@ -89,8 +99,9 @@ module CardRenderer = {
updateDetails(paymentMethodsEnabled)
}

let isSelected = value => {
standardProviders->Js.Array2.includes(value) || cardProviders->Js.Array2.includes(value)
let isSelected = selectedMethod => {
standardProviders->Js.Array2.some(obj => checkPaymentMethodType(obj, selectedMethod)) ||
cardProviders->Js.Array2.some(obj => checkPaymentMethodType(obj, selectedMethod))
? true
: false
}
Expand Down Expand Up @@ -145,16 +156,19 @@ module CardRenderer = {
<div onClick={_e => removeOrAddMethods(value)}>
<CheckBoxIcon isSelected={isSelected(value)} />
</div>
<p className=p2RegularTextStyle> {React.string(value->snakeToTitle)} </p>
<p className=p2RegularTextStyle>
{React.string(value.payment_method_type->snakeToTitle)}
</p>
</div>
</div>
})
->React.array}
<UIUtils.RenderIf
condition={selectedWallet->getPaymentMethodTypeFromString === ApplePay ||
selectedWallet->getPaymentMethodTypeFromString === GooglePay}>
condition={selectedWallet.payment_method_type->getPaymentMethodTypeFromString ===
ApplePay ||
selectedWallet.payment_method_type->getPaymentMethodTypeFromString === GooglePay}>
<Modal
modalHeading={`Additional Details to enable ${selectedWallet->LogicUtils.snakeToTitle}`}
modalHeading={`Additional Details to enable ${selectedWallet.payment_method_type->LogicUtils.snakeToTitle}`}
headerTextClass="text-blue-800 font-bold text-xl"
showModal={showWalletConfigurationModal}
setShowModal={setShowWalletConfigurationModal}
Expand Down Expand Up @@ -205,7 +219,8 @@ module PaymentMethodsRender = {
<div className="flex flex-col gap-12">
{keys
->Array.mapWithIndex((value, i) => {
let provider = pmts->getStrArray(value)
let provider = pmts->getArrayFromDict(value, [])->Js.Json.array->getPaymentMethodMapper

switch value->getPaymentMethodTypeFromString {
| Credit | Debit =>
<div key={i->string_of_int}>
Expand All @@ -226,7 +241,7 @@ module PaymentMethodsRender = {
updateDetails
paymentMethodsEnabled
paymentMethod={value}
provider={pmts->getStrArray(value)}
provider
_showAdvancedConfiguration=false
metaData
setMetaData
Expand Down
Loading

0 comments on commit 3704f20

Please sign in to comment.