Skip to content

Commit

Permalink
chore: refactor connector metadata (#854)
Browse files Browse the repository at this point in the history
Co-authored-by: Riddhiagrawal001 <[email protected]>
  • Loading branch information
JeevaRamu0104 and Riddhiagrawal001 authored Jul 12, 2024
1 parent 31e5637 commit 604b028
Show file tree
Hide file tree
Showing 32 changed files with 1,822 additions and 1,259 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@monaco-editor/react": "^4.4.5",
"@rescript/core": "^0.6.0",
"@rescript/react": "^0.12.0",
"apexcharts": "^3.28.3",
"bs-fetch": "^0.6.2",
"csvjson-csv2json": "^5.0.6",
"csvjson-json2csv": "^1.0.3",
Expand All @@ -84,7 +85,6 @@
"monaco-editor": "^0.34.1",
"nprogress": "^0.2.0",
"react": "^18.2.0",
"apexcharts": "^3.28.3",
"react-apexcharts": "^1.4.1",
"react-beautiful-dnd": "^13.1.0",
"react-color": "^2.19.3",
Expand Down
Binary file modified public/.DS_Store
Binary file not shown.
14 changes: 7 additions & 7 deletions public/hyperswitch/wasm/euclid.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,13 @@ function __wbg_get_imports() {
const ret = new Object();
return addHeapObject(ret);
};
imports.wbg.__wbg_new_16b304a2cfa7ff4a = function() {
const ret = new Array();
return addHeapObject(ret);
};
imports.wbg.__wbg_set_d4638f722068f043 = function(arg0, arg1, arg2) {
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
};
imports.wbg.__wbindgen_is_object = function(arg0) {
const val = getObject(arg0);
const ret = typeof(val) === 'object' && val !== null;
Expand Down Expand Up @@ -866,13 +873,6 @@ function __wbg_get_imports() {
const ret = arg0;
return addHeapObject(ret);
};
imports.wbg.__wbg_new_16b304a2cfa7ff4a = function() {
const ret = new Array();
return addHeapObject(ret);
};
imports.wbg.__wbg_set_d4638f722068f043 = function(arg0, arg1, arg2) {
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
};
imports.wbg.__wbg_new_d9bc3a0147634640 = function() {
const ret = new Map();
return addHeapObject(ret);
Expand Down
Binary file modified public/hyperswitch/wasm/euclid_bg.wasm
Binary file not shown.
2 changes: 0 additions & 2 deletions src/screens/Connectors/ConnectPayPalFlow/ConnectPayPal.res
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,6 @@ let make = (
<ConnectorAccountDetailsHelper.RenderConnectorInputFields
details={ConnectorUtils.connectorLabelDetailField}
name={"connector_label"}
keysToIgnore=ConnectorAccountDetailsHelper.metaDataInputKeysToIgnore
checkRequiredFields={ConnectorUtils.getMetaDataRequiredFields}
connector={connector->ConnectorUtils.getConnectorNameTypeFromString()}
selectedConnector
isLabelNested=false
Expand Down
108 changes: 4 additions & 104 deletions src/screens/Connectors/ConnectorAccountDetailsHelper.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
let metaDataInputKeysToIgnore = ["google_pay", "apple_pay", "zen_apple_pay"]

let connectorsWithIntegrationSteps: array<ConnectorTypes.connectorTypes> = [
Processors(ADYEN),
Processors(CHECKOUT),
Expand Down Expand Up @@ -46,77 +44,6 @@ let multiValueInput = (~label, ~fieldName1, ~fieldName2) => {
)
}

let getCurrencyOption: CurrencyUtils.currencyCode => SelectBox.dropdownOption = currencyType => {
open CurrencyUtils
{
label: currencyType->getCurrencyCodeStringFromVariant,
value: currencyType->getCurrencyCodeStringFromVariant,
}
}

let currencyField = (
~name,
~options=CurrencyUtils.currencyList,
~disableSelect=false,
~toolTipText="",
(),
) =>
FormRenderer.makeFieldInfo(
~label="Currency",
~isRequired=true,
~name,
~description=toolTipText,
~customInput=InputFields.selectInput(
~deselectDisable=true,
~disableSelect,
~customStyle="max-h-48",
~options=options->Array.map(getCurrencyOption),
~buttonText="Select Currency",
(),
),
(),
)

let dropDownfield = (
~name,
~label,
~buttonText="Select",
~disableSelect=false,
~toolTipText="",
~options=[],
(),
) => {
FormRenderer.makeFieldInfo(
~label,
~isRequired=true,
~name,
~description=toolTipText,
~customInput=InputFields.selectInput(
~deselectDisable=true,
~disableSelect,
~customStyle="max-h-48",
~options=options->Array.map((item): SelectBox.dropdownOption => {
{
label: item,
value: item,
}
}),
~buttonText,
(),
),
(),
)
}

let toggleField = (~name) => {
FormRenderer.makeFieldInfo(
~name,
~label="Pull Mechanism Enabled",
~customInput=InputFields.boolInput(~isDisabled=false, ~boolCustomClass="rounded-lg", ()),
(),
)
}

let inputField = (
~name,
~field,
Expand Down Expand Up @@ -192,12 +119,7 @@ module RenderConnectorInputFields = {

keys
->Array.mapWithIndex((field, i) => {
let label = switch field {
| "pull_mechanism_for_external_3ds_enabled" => "Pull Mechanism Enabled"
| "klarna_region" => "Region of your Klarna Merchant Account"

| _ => details->getString(field, "")
}
let label = details->getString(field, "")

let formName = isLabelNested ? `${name}.${field}` : name
<UIUtils.RenderIf condition={label->isNonEmptyString} key={i->Int.toString}>
Expand All @@ -206,19 +128,6 @@ module RenderConnectorInputFields = {
<FormRenderer.FieldRenderer
labelClass="font-semibold !text-hyperswitch_black"
field={switch (connector, field) {
| (Processors(BRAINTREE), "merchant_config_currency") =>
currencyField(~name=formName, ())

| (ThreeDsAuthenticator(THREEDSECUREIO), "pull_mechanism_for_external_3ds_enabled") =>
toggleField(~name=formName)
| (Processors(KLARNA), "klarna_region") =>
dropDownfield(
~name=formName,
~label,
~buttonText="Select Region",
~options=details->getStrArrayFromDict(field, []),
(),
)
| (Processors(PAYPAL), "key1") =>
multiValueInput(
~label,
Expand Down Expand Up @@ -300,8 +209,8 @@ module CashToCodeSelectBox = {

<div>
{opts
->Array.map(country => {
<div className="flex items-center gap-2 break-words p-2">
->Array.mapWithIndex((country, index) => {
<div key={index->Int.toString} className="flex items-center gap-2 break-words p-2">
<div onClick={_e => selectedCountry(country)}>
<CheckBoxIcon isSelected={country->isSelected} />
</div>
Expand Down Expand Up @@ -408,21 +317,12 @@ module ConnectorConfigurationFields = {
<RenderConnectorInputFields
details={connectorLabelDetailField}
name={"connector_label"}
keysToIgnore=metaDataInputKeysToIgnore
checkRequiredFields={ConnectorUtils.getMetaDataRequiredFields}
connector
selectedConnector
isLabelNested=false
description="This is an unique label you can generate and pass in order to identify this connector account on your Hyperswitch dashboard and reports. Eg: if your profile label is 'default', connector label can be 'stripe_default'"
/>
<RenderConnectorInputFields
details={connectorMetaDataFields}
name={"metadata"}
keysToIgnore=metaDataInputKeysToIgnore
checkRequiredFields={ConnectorUtils.getMetaDataRequiredFields}
connector
selectedConnector
/>
<ConnectorMetaData connectorMetaDataFields />
<RenderConnectorInputFields
details={connectorWebHookDetails}
name={"connector_webhook_details"}
Expand Down
Loading

0 comments on commit 604b028

Please sign in to comment.