Skip to content

Commit

Permalink
Merge branch 'main' into button-component-access
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja authored Jan 18, 2024
2 parents 5b2d162 + b8b5034 commit cca3320
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 668 deletions.
7 changes: 0 additions & 7 deletions src/components/priority-logics/PriorityLogicUtils.res

This file was deleted.

125 changes: 1 addition & 124 deletions src/screens/HyperSwitch/Routing/AdvancedRouting/RoutingPreviewer.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
open RoutingTypes
open RoutingUtils

module SimplePreview = {
@react.component
Expand All @@ -26,6 +25,7 @@ module SimplePreview = {
</UIUtils.RenderIf>
}
}

module GatewayView = {
@react.component
let make = (~gateways, ~connectorList=?) => {
Expand Down Expand Up @@ -56,126 +56,3 @@ module GatewayView = {
</div>
}
}
module RulePreviewer = {
@react.component
let make = (~ruleInfo: ruleInfoType, ~isFrom3ds=false) => {
open LogicUtils
<div
className=" bg-white border border-jp-gray-600 flex flex-col divide-y divide-jp-gray-600 border-jp-gray-600 ">
<div>
<div className="flex flex-col divide-y divide-jp-gray-600 border-t border-b">
{ruleInfo.rules
->Array.mapWithIndex((rule, index) => {
let headingText = `Rule ${string_of_int(index + 1)}`
let marginStyle = index === ruleInfo.rules->Array.length - 1 ? "mt-2" : "my-2"
let threeDsType =
rule.routingOutput->Belt.Option.getWithDefault(defaultThreeDsObjectValue)
<div
key={Belt.Int.toString(index)}
className="flex flex-col items-center w-full px-4 pb-6">
<div
style={ReactDOMStyle.make(~marginTop="-1.2rem", ())}
className="text-jp-gray-700 dark:text-jp-gray-700 text-base font-semibold p-1 px-3 bg-jp-gray-50 dark:bg-jp-gray-950 rounded-full border border-jp-gray-600 dark:border-jp-gray-850">
{headingText->React.string}
</div>
<div className={`w-full flex flex-wrap items-center ${marginStyle}`}>
<div className="flex flex-wrap gap-2">
{rule.conditions
->RoutingUtils.filterEmptyValues
->Array.mapWithIndex((condition, index) => {
let logical = logicalOperatorTypeToStringMapper(condition.logicalOperator)
let operator = operatorTypeToStringMapper(condition.operator)
let field = condition.field->String.length > 0 ? condition.field : ""

let value = switch condition.value {
| StringArray(arr) => arr->Array.joinWith(", ")
| String(str) => str
| Int(int) => int->Belt.Int.toString
}
let metadataKey = switch condition.metadata {
| Some(json) => json->getDictFromJsonObject->getOptionString("key")
| _ => None
}

<div
key={Belt.Int.toString(index)} className="flex flex-wrap items-center gap-2">
<UIUtils.RenderIf condition={index !== 0}>
<MakeRuleFieldComponent.TextView
str=logical fontColor="text-blue-800" fontWeight="font-semibold"
/>
</UIUtils.RenderIf>
<MakeRuleFieldComponent.TextView str=field />
{switch metadataKey {
| Some(key) => <MakeRuleFieldComponent.TextView str=key />
| None => React.null
}}
<MakeRuleFieldComponent.TextView
str=operator fontColor="text-red-500" fontWeight="font-semibold"
/>
<MakeRuleFieldComponent.TextView str=value />
</div>
})
->React.array}
</div>
<UIUtils.RenderIf condition={rule.conditions->Array.length > 0}>
<Icon size=14 name="arrow-right" className="mx-4 text-jp-gray-700" />
</UIUtils.RenderIf>
<UIUtils.RenderIf condition={isFrom3ds}>
<div
className="my-2 h-6 md:h-8 flex items-center rounded-md border border-jp-gray-500 font-medium text-blue-800 hover:text-blue-900 bg-gradient-to-b from-jp-gray-250 to-jp-gray-200 focus:outline-none px-2 gap-1">
{threeDsType.override_3ds->LogicUtils.capitalizeString->React.string}
</div>
</UIUtils.RenderIf>
<UIUtils.RenderIf condition={!isFrom3ds}>
<GatewayView gateways=rule.gateways />
</UIUtils.RenderIf>
</div>
</div>
})
->React.array}
</div>
<UIUtils.RenderIf condition={!isFrom3ds}>
<div
className="flex flex-col md:flex-row md:items-center gap-2 md:gap-6 mx-6 my-2 text-jp-gray-700">
<div className="flex flex-row items-center gap-2 mt-4 md:mt-0">
<Icon
name="arrow-rotate"
size=14
className="cursor-pointer text-jp-gray-700"
onClick={ev => ()}
/>
<div>
{React.string("Default Processors")}
<span className="text-red-500"> {React.string(" *")} </span>
</div>
</div>
<div className="flex flex-wrap items-center gap-4">
{ruleInfo.default_gateways
->Array.mapWithIndex((gateway, index) => {
<div
key={Belt.Int.toString(index)}
className="flex flex-row items-center gap-2 my-2 md:my-4 text-jp-gray-700">
<div
className="px-1.5 md:px-2 rounded-full bg-jp-gray-300 dark:bg-jp-gray-900 text-jp-gray-700 dark:text-jp-gray-600 font-semibold text-sm md:text-md">
{React.string(string_of_int(index + 1))}
</div>
<div> {gateway->React.string} </div>
<UIUtils.RenderIf
condition={index !== ruleInfo.default_gateways->Array.length - 1}>
<Icon
name="chevron-right"
size=14
className="cursor-pointer text-jp-gray-700"
onClick={ev => ()}
/>
</UIUtils.RenderIf>
</div>
})
->React.array}
</div>
</div>
</UIUtils.RenderIf>
</div>
</div>
}
}
26 changes: 22 additions & 4 deletions src/screens/HyperSwitch/Routing/HistoryEntity.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ open LogicUtils
open RoutingUtils
open RoutingTypes

let allColumns = [Name, Type, ProfileId, ProfileName, Description, Created, LastUpdated, Status]
let allColumns: array<historyColType> = [
Name,
Type,
ProfileId,
ProfileName,
Description,
Created,
LastUpdated,
Status,
]

let itemToObjMapper = dict => {
{
id: getString(dict, "id", ""),
Expand All @@ -14,9 +24,17 @@ let itemToObjMapper = dict => {
created_at: getString(dict, "created_at", ""),
}
}
let defaultColumns = [Name, ProfileId, ProfileName, Type, Description, Status]

let getHeading = colType => {
let defaultColumns: array<historyColType> = [
Name,
ProfileId,
ProfileName,
Type,
Description,
Status,
]

let getHeading: historyColType => Table.header = colType => {
switch colType {
| Name => Table.makeHeaderInfo(~key="name", ~title="Name of Control", ~showSort=true, ())
| Type => Table.makeHeaderInfo(~key="kind", ~title="Type of Control", ~showSort=true, ())
Expand All @@ -32,7 +50,7 @@ let getHeading = colType => {
}
}
let getTableCell = activeRoutingIds => {
let getCell = (historyData, colType): Table.cell => {
let getCell = (historyData, colType: historyColType): Table.cell => {
switch colType {
| Name => Text(historyData.name)
| Type =>
Expand Down
1 change: 0 additions & 1 deletion src/screens/HyperSwitch/Routing/PriorityRouting.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
open RoutingUtils
open APIUtils
open RoutingTypes
open PriorityLogicUtils
open RoutingPreviewer
module SimpleRoutingView = {
@react.component
Expand Down
89 changes: 25 additions & 64 deletions src/screens/HyperSwitch/Routing/RoutingTypes.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
type routingType = SINGLE | PRIORITY | VOLUME_SPLIT | ADVANCED | COST | DEFAULTFALLBACK | NO_ROUTING
type modalValue = {conType: string, conText: React.element}
type routingValueType = {heading: string, subHeading: string}
type modalObj = (routingType, string) => modalValue
type formState = CreateConfig | EditConfig | ViewConfig
type status = ACTIVE | APPROVED | PENDING | REJECTED
type pageState = Preview | Create | Edit
type variantType = Number | Enum_variant | Metadata_value | String_value | UnknownVariant(string)
type logicalOperator = AND | OR | UnknownLogicalOperator(string)
type val = StringArray(array<string>) | String(string) | Int(int)

type historyColType =
| Name
| Type
| ProfileId
| ProfileName
| Description
| Created
| LastUpdated
| Status

type colType =
| Name
| Description
Expand All @@ -10,8 +24,6 @@ type colType =
| DateCreated
| LastUpdated

type status = ACTIVE | APPROVED | PENDING | REJECTED
type configType = RuleBased | CodeBased
type operator =
| IS
| IS_NOT
Expand All @@ -22,75 +34,30 @@ type operator =
| NOT_CONTAINS
| NOT_EQUAL_TO
| UnknownOperator(string)
type variantType = Number | Enum_variant | Metadata_value | String_value | UnknownVariant(string)
type logicalOperator = AND | OR | UnknownLogicalOperator(string)
type val = StringArray(array<string>) | String(string) | Int(int)
type logic = {
id: string,
name: string,
description: string,
isActiveLogic: bool,
status: status,
configType: configType,
version: string,
priorityLogic: string,
priorityLogicRules: string,
dateCreated: string,
lastUpdated: string,
}
type response = {
useCode: bool,
gatewayPriority: string,
gatewayPriorityLogic: string,
logics: array<logic>,
}

type modalValue = {conType: string, conText: React.element}
type routingValueType = {heading: string, subHeading: string}
type modalObj = (routingType, string) => modalValue

type wasmModule = {
getAllKeys: unit => array<string>,
getKeyType: string => string,
getAllConnectors: unit => array<string>,
getVariantValues: string => array<string>,
}

type gateway = {
distribution: int,
disableFallback: bool,
gateway_name: string,
}

type volumeDistribution = {
connector: string,
split: int,
}
type pageState = Preview | Create | Edit
type condition = {
field: string,
metadata?: Js.Json.t,
operator: operator,
value: val,
logicalOperator: logicalOperator,
}
type routingOutputType = {override_3ds: string}
type rule = {
gateways: array<gateway>,
conditions: array<condition>,
routingOutput?: routingOutputType,
}
type ruleInfoType = {
rules: array<rule>,
default_gateways: array<string>,
}

type gateWAY = {gateways: array<gateway>}
type volumeDistributionType = {volumeBasedDistribution: gateWAY}
type ruleDict = {json: volumeDistributionType}

type historyColType =
| Name
| Type
| ProfileId
| ProfileName
| Description
| Created
| LastUpdated
| Status
type routingOutputType = {override_3ds: string}

type historyData = {
id: string,
Expand All @@ -103,9 +70,3 @@ type historyData = {
}

type value = {"type": Js.Json.t, "value": Js.Json.t}
type payloadCondition = {
lhs: string,
comparison: string,
value: value,
metadata: Js.Json.t,
}
Loading

0 comments on commit cca3320

Please sign in to comment.