Skip to content

Commit

Permalink
Merge branch 'main' into page-heading-addition
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Dec 1, 2023
2 parents 62939c9 + 4863a54 commit 9f0c2a4
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 21 deletions.
4 changes: 1 addition & 3 deletions src/components/Paginator.res
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ let make = (
setOffset(_ => newOffset)
}, (setOffset, resultsPerPage, currrentFetchCount, url.search, totalResults))

let borderClass = !isMobileView ? "border-b border-x border-jp-2-light-gray-300 rounded-b-lg" : ""
let marginClass = "mt-4 md:mr-0"

if totalResults >= resultsPerPage {
<div
className={`flex ${flexDirection} justify-between ${marginClass} ${paginationClass} ${borderClass}`}>
<div className={`flex ${flexDirection} justify-between ${marginClass} ${paginationClass} `}>
<div className={`flex flex-row w-full ${justify}`}>
<UIUtils.RenderIf condition={!isMobileView && showResultsPerPageSelector}>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ let make = (~connectProcessorValue: connectProcessor) => {
onClick={_ => updateTestPaymentEnum(~paymentId="pay_default")->ignore}
/>}>
<TestPayment
initialValues={activeBusinessProfile.profile_id->SDKPaymentUtils.initialValueForForm}
initialValues={activeBusinessProfile->SDKPaymentUtils.initialValueForForm}
returnUrl={`${HSwitchGlobalVars.hyperSwitchFEPrefix}/quick-start`}
onProceed={updateTestPaymentEnum}
keyValue=key
Expand Down
3 changes: 2 additions & 1 deletion src/screens/HyperSwitch/Routing/RoutingTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ type operator =
| EQUAL_TO
| CONTAINS
| NOT_CONTAINS
| NOT_EQUAL_TO
| UnknownOperator(string)
type variantType = Number | Enum_variant | Metadata_value | UnknownVariant(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 = {
Expand Down
6 changes: 6 additions & 0 deletions src/screens/HyperSwitch/Routing/RoutingUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ let operatorMapper = value => {
| "GREATER THAN" => GREATER_THAN
| "LESS THAN" => LESS_THAN
| "EQUAL TO" => EQUAL_TO
| "NOT EQUAL_TO" => NOT_EQUAL_TO
| _ => UnknownOperator("")
}
}
Expand All @@ -47,6 +48,7 @@ let variantTypeMapper = variantType => {
| "number" => Number
| "enum_variant" => Enum_variant
| "metadata_value" => Metadata_value
| "str_value" => String_value
| _ => UnknownVariant("")
}
}
Expand Down Expand Up @@ -99,6 +101,7 @@ let operatorTypeToStringMapper = operator => {
| GREATER_THAN => "GREATER THAN"
| LESS_THAN => "LESS THAN"
| EQUAL_TO => "EQUAL TO"
| NOT_EQUAL_TO => "NOT EQUAL_TO"
| UnknownOperator(str) => str
}
}
Expand Down Expand Up @@ -210,6 +213,7 @@ let advanceRoutingConditionMapper = (dict, wasm) => {
| EQUAL_TO => "equal"
| GREATER_THAN => "greater_than"
| LESS_THAN => "less_than"
| NOT_EQUAL_TO => "not_equal"
| UnknownOperator(str) => str
},
value: {
Expand All @@ -224,6 +228,7 @@ let advanceRoutingConditionMapper = (dict, wasm) => {
| _ => ""
}
| Metadata_value => "metadata_variant"
| String_value => "str_value"
| _ => ""
}->Js.Json.string,
"value": switch variantType->variantTypeMapper {
Expand All @@ -243,6 +248,7 @@ let advanceRoutingConditionMapper = (dict, wasm) => {
let value = dict->getString("value", "")->Js.String2.trim->Js.Json.string
Js.Dict.fromArray([("key", key), ("value", value)])->Js.Json.object_
}
| String_value => dict->getString("value", "")->Js.Json.string
| _ => ""->Js.Json.string
},
},
Expand Down
3 changes: 2 additions & 1 deletion src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@ let make = (~routingRuleId, ~isActive, ~setCurrentRouting) => {
| EQUAL_TO
| CONTAINS => "equal"
| IS_NOT
| NOT_CONTAINS => "not_equal"
| NOT_CONTAINS
| NOT_EQUAL_TO => "not_equal"
| GREATER_THAN => "greater_than"
| LESS_THAN => "less_than"
| UnknownOperator(str) => str
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type routing = SINGLE | PRIORITY | VOLUME_SPLIT | ADVANCED | COST | DEFAULTFALLBACK | NO_ROUTING
type variantType = Number | Enum_variant | Metadata_value | UnknownVariant(string)
type variantType = Number | Enum_variant | Metadata_value | String_value | UnknownVariant(string)
type pageState = Preview | Create | Edit
type formState = CreateConfig | EditConfig | EditReplica | ViewConfig

Expand All @@ -11,6 +11,7 @@ type operator =
| EQUAL_TO
| CONTAINS
| NOT_CONTAINS
| NOT_EQUAL_TO
| UnknownOperator(string)

type connector = {
Expand Down
12 changes: 11 additions & 1 deletion src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module OperatorInp = {
| Enum_variant => ["IS", "CONTAINS", "IS_NOT", "NOT_CONTAINS"]
| Number => ["EQUAL TO", "GREATER THAN", "LESS THAN"]
| Metadata_value => ["EQUAL TO"]
| String_value => ["EQUAL TO", "NOT EQUAL_TO"]
| _ => []
}

Expand Down Expand Up @@ -128,6 +129,8 @@ module ValueInp = {
typeField.onChange(
if keyType->variantTypeMapper === Metadata_value {
"metadata_variant"
} else if keyType->variantTypeMapper === String_value {
"str_value"
} else {
switch opField.value->LogicUtils.getStringFromJson("")->operatorMapper {
| IS
Expand Down Expand Up @@ -174,8 +177,15 @@ module ValueInp = {
fixedDropDownDirection=SelectBox.TopRight
/>
}
| EQUAL_TO =>
switch keyType->variantTypeMapper {
| String_value => <TextInput input placeholder="Enter value" />
| _ => <NumericTextInput placeholder={"Enter value"} input />
}

| NOT_EQUAL_TO => <TextInput input placeholder="Enter value" />
| LESS_THAN | GREATER_THAN => <NumericTextInput placeholder={"Enter value"} input />

| EQUAL_TO | LESS_THAN | GREATER_THAN => <NumericTextInput placeholder={"Enter Value"} input />
| _ => React.null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let operatorMapper: string => AdvancedRoutingTypes.operator = value => {
| "GREATER THAN" => GREATER_THAN
| "LESS THAN" => LESS_THAN
| "EQUAL TO" => EQUAL_TO
| "NOT EQUAL_TO" => NOT_EQUAL_TO
| _ => UnknownOperator("")
}
}
Expand Down Expand Up @@ -91,6 +92,7 @@ let variantTypeMapper: string => AdvancedRoutingTypes.variantType = variantType
| "number" => Number
| "enum_variant" => Enum_variant
| "metadata_value" => Metadata_value
| "str_value" => String_value
| _ => UnknownVariant("")
}
}
Expand Down Expand Up @@ -228,12 +230,14 @@ let getOperatorFromComparisonType = (comparison, variantType) => {
switch variantType {
| "enum_variant" => "IS"
| "enum_variant_array" => "CONTAINS"
| "str_value" => "EQUAL_TO"
| _ => "IS"
}
| "not_equal" =>
switch variantType {
| "enum_variant_array" => "NOT_CONTAINS"
| "enum_variant" => "IS_NOT"
| "str_value" => "NOT EQUAL_TO"
| _ => "IS_NOT"
}
| "greater_than" => "GREATER_THAN"
Expand Down
17 changes: 12 additions & 5 deletions src/screens/HyperSwitch/SDKPayment/SDKPage.res
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
let h3Leading2Style = HSwitchUtils.getTextClass(~textVariant=H3, ~h3TextVariant=Leading_2, ())
external toJson: 'a => Js.Json.t = "%identity"

module SDKConfifiguarationFields = {
module SDKConfiguarationFields = {
open HSwitchMerchantAccountUtils
@react.component
let make = () => {
let make = (~initialValues: SDKPaymentTypes.paymentType) => {
let businessProfiles = Recoil.useRecoilValueFromAtom(HyperswitchAtom.businessProfilesAtom)
let arrayOfBusinessProfile = businessProfiles->getArrayOfBusinessProfile
let disableSelectionForProfile = arrayOfBusinessProfile->HomeUtils.isDefaultBusinessProfile
Expand Down Expand Up @@ -70,7 +70,9 @@ module SDKConfifiguarationFields = {
<FormRenderer.FieldRenderer field=selectProfileId fieldWrapperClass="!w-full" />
<FormRenderer.FieldRenderer field=selectCurrencyField fieldWrapperClass="!w-full" />
<FormRenderer.FieldRenderer field=enterAmountField fieldWrapperClass="!w-full" />
<FormRenderer.SubmitButton text="Show preview" />
<FormRenderer.SubmitButton
text="Show preview" disabledParamter={!(initialValues.profile_id->Js.String2.length > 0)}
/>
</>
}
}
Expand All @@ -86,7 +88,7 @@ let make = () => {
let businessProfiles = Recoil.useRecoilValueFromAtom(HyperswitchAtom.businessProfilesAtom)
let defaultBusinessProfile = businessProfiles->getValueFromBusinessProfile
let (initialValues, setInitialValues) = React.useState(_ =>
defaultBusinessProfile.profile_id->SDKPaymentUtils.initialValueForForm
defaultBusinessProfile->SDKPaymentUtils.initialValueForForm
)
React.useEffect1(() => {
let paymentIntentOptional = filtersFromUrl->Js.Dict.get("payment_intent_client_secret")
Expand All @@ -96,6 +98,11 @@ let make = () => {
None
}, [filtersFromUrl])

React.useEffect1(() => {
setInitialValues(_ => defaultBusinessProfile->SDKPaymentUtils.initialValueForForm)
None
}, [defaultBusinessProfile.profile_id->Js.String2.length])

let onProceed = async (~paymentId as _) => {
let paymentId =
filtersFromUrl
Expand Down Expand Up @@ -138,7 +145,7 @@ let make = () => {
initialValues={initialValues->toJson}
formClass="grid grid-cols-2 gap-x-8 gap-y-4"
onSubmit>
<SDKConfifiguarationFields />
<SDKConfiguarationFields initialValues />
</Form>
<TestCredentials />
</div>
Expand Down
1 change: 1 addition & 0 deletions src/screens/HyperSwitch/SDKPayment/SDKPaymentTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ type paymentType = {
currency: string,
profile_id: string,
customer_id: string,
description: string,
}
14 changes: 9 additions & 5 deletions src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
let initialValueForForm: string => SDKPaymentTypes.paymentType = profileId => {
amount: 100,
currency: "United States-USD",
profile_id: profileId,
customer_id: "hyperswitch_sdk_demo_id",
let initialValueForForm: HSwitchSettingTypes.profileEntity => SDKPaymentTypes.paymentType = defaultBusinessProfile => {
{
amount: 100,
currency: "United States-USD",
profile_id: defaultBusinessProfile.profile_id,
description: "Default value",
customer_id: "hyperswitch_sdk_demo_id",
}
}

let getTypedValueForPayment: Js.Json.t => SDKPaymentTypes.paymentType = values => {
Expand All @@ -13,6 +16,7 @@ let getTypedValueForPayment: Js.Json.t => SDKPaymentTypes.paymentType = values =
currency: dictOfValues->getString("currency", "United States-USD"),
profile_id: dictOfValues->getString("profile_id", ""),
customer_id: dictOfValues->getString("customer_id", ""),
description: dictOfValues->getString("description", "Default value"),
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/screens/HyperSwitch/SDKPayment/TestPayment.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
external toJson: 'a => Js.Json.t = "%identity"
let headerTextStyle = "text-xl font-semibold text-grey-700"
let subTextStyle = "text-base font-normal text-grey-700 opacity-50"
let dividerColor = "bg-grey-700 bg-opacity-20 h-px w-full"
Expand Down Expand Up @@ -46,6 +47,7 @@ let make = (
),
("profile_id", initialValues.profile_id->Js.Json.string),
("customer_id", "hyperswitch_sdk_demo_id"->Js.Json.string),
("description", initialValues.description->Js.Json.string),
])->Js.Json.object_
let response = await updateDetails(url, body, Post)
let clientSecret = response->getDictFromJsonObject->getOptionString("client_secret")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ module TestPayment = {
}}
/>}>
<TestPayment
initialValues={defaultBusinessProfile.profile_id->SDKPaymentUtils.initialValueForForm}
initialValues={defaultBusinessProfile->SDKPaymentUtils.initialValueForForm}
returnUrl={`${HSwitchGlobalVars.hyperSwitchFEPrefix}/stripe-plus-paypal`}
onProceed={sptestPaymentProceed}
keyValue={key}
Expand Down
3 changes: 1 addition & 2 deletions src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,8 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType,
className={`flex flex-col justify-evenly gap-5 h-full w-full !overflow-visible text-grey-600`}>
{switch authType {
| LoginWithPassword => <EmailPasswordForm setAuthType forgetPassword />
| ForgetPassword => forgetPassword ? <EmailForm /> : React.null
| LoginWithEmail
| ForgetPassword =>
forgetPassword ? <EmailForm /> : React.null
| ResendVerifyEmail
| SignUP =>
isMagicLinkEnabled ? <EmailForm /> : <EmailPasswordForm setAuthType forgetPassword />
Expand Down

0 comments on commit 9f0c2a4

Please sign in to comment.