Skip to content

Commit

Permalink
fix: sync branch from main
Browse files Browse the repository at this point in the history
  • Loading branch information
Riddhiagrawal001 committed Dec 20, 2023
2 parents b0bb130 + 74f327c commit f925e09
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 58 deletions.
5 changes: 2 additions & 3 deletions public/hyperswitch/wasm/euclid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ export function getRequestPayload(input: any, response: any): any;
*/
export function getResponsePayload(input: any): any;
/**
* @param {string} key
* @returns {any}
*/
export function getDescriptionCategory(key: string): any;
export function getDescriptionCategory(): any;
/**
*
* Function exposed as `wasm` function in js `parse`. Allowing use to extend the functionality and
Expand Down Expand Up @@ -138,7 +137,7 @@ export interface InitOutput {
readonly getPayoutConnectorConfig: (a: number, b: number, c: number) => void;
readonly getRequestPayload: (a: number, b: number, c: number) => void;
readonly getResponsePayload: (a: number, b: number) => void;
readonly getDescriptionCategory: (a: number, b: number, c: number) => void;
readonly getDescriptionCategory: (a: number) => void;
readonly parse: (a: number, b: number, c: number) => void;
readonly parseToString: (a: number, b: number, c: number) => void;
readonly __wbindgen_export_0: (a: number, b: number) => number;
Expand Down
7 changes: 2 additions & 5 deletions public/hyperswitch/wasm/euclid.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,15 +580,12 @@ export function getResponsePayload(input) {
}

/**
* @param {string} key
* @returns {any}
*/
export function getDescriptionCategory(key) {
export function getDescriptionCategory() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
const len0 = WASM_VECTOR_LEN;
wasm.getDescriptionCategory(retptr, ptr0, len0);
wasm.getDescriptionCategory(retptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
Expand Down
Binary file modified public/hyperswitch/wasm/euclid_bg.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion public/hyperswitch/wasm/euclid_bg.wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function getConnectorConfig(a: number, b: number, c: number): void;
export function getPayoutConnectorConfig(a: number, b: number, c: number): void;
export function getRequestPayload(a: number, b: number, c: number): void;
export function getResponsePayload(a: number, b: number): void;
export function getDescriptionCategory(a: number, b: number, c: number): void;
export function getDescriptionCategory(a: number): void;
export function parse(a: number, b: number, c: number): void;
export function parseToString(a: number, b: number, c: number): void;
export function __wbindgen_export_0(a: number, b: number): number;
Expand Down
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_vas",
"name": "euclid_wasm",
"description": "WASM bindings for Euclid DSL",
"version": "0.1.0",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/entryPoints/hyperswitch/HyperSwitchApp.res
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ let make = () => {
className="w-full h-screen overflow-x-scroll xl:overflow-x-hidden overflow-y-scroll">
<div
className="w-full h-full p-6 md:px-16 md:pb-16 pt-[3rem] overflow-scroll md:overflow-y-scroll md:overflow-x-hidden flex flex-col gap-10 show-scrollbar">
<div className="w-full h-full max-w-fixedPageWidth">
<div className="h-full w-full max-w-fixedPageWidth">
<ErrorBoundary>
{switch url.path {
| list{"home"} =>
Expand Down
14 changes: 9 additions & 5 deletions src/screens/HyperSwitch/APIUtils/APIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ let getURL = (
let sessionExpired = ref(false)

let handleLogout = async (
~fetchApi: (
~fetchApi as _: (
Js.String2.t,
~bodyStr: string=?,
~headers: Js.Dict.t<Js.String2.t>=?,
Expand All @@ -248,10 +248,12 @@ let handleLogout = async (
unit,
) => Promise.t<Fetch.Response.t>,
~setAuthStatus,
~setIsSidebarExpanded,
) => {
let logoutUrl = getURL(~entityName=USERS, ~methodType=Post, ~userType=#SIGNOUT, ())
let _ = await fetchApi(logoutUrl, ~method_=Fetch.Post, ())
// let logoutUrl = getURL(~entityName=USERS, ~methodType=Post, ~userType=#SIGNOUT, ())
// let _ = await fetchApi(logoutUrl, ~method_=Fetch.Post, ())
setAuthStatus(HyperSwitchAuthTypes.LoggedOut)
setIsSidebarExpanded(_ => false)
LocalStorage.clear()
RescriptReactRouter.push("/register")
}
Expand Down Expand Up @@ -376,6 +378,7 @@ let useGetMethod = (~showErrorToast=true, ()) => {
let showToast = ToastState.useShowToast()
let showPopUp = PopUpState.useShowPopUp()
let (_authStatus, setAuthStatus) = React.useContext(AuthInfoProvider.authStatusContext)
let {setIsSidebarExpanded} = React.useContext(SidebarProvider.defaultContext)
let isPlayground = HSLocalStorage.getIsPlaygroundFromLocalStorage()
let url = RescriptReactRouter.useUrl()
let urlPath = url.path->Belt.List.toArray->Js.Array2.joinWith("_")
Expand All @@ -393,7 +396,7 @@ let useGetMethod = (~showErrorToast=true, ()) => {
_ => {
hyperswitchMixPanel(~eventName=Some(`${urlPath}_tryplayground_register`), ())
hyperswitchMixPanel(~eventName=Some(`global_tryplayground_register`), ())
let _ = handleLogout(~fetchApi, ~setAuthStatus)
let _ = handleLogout(~fetchApi, ~setAuthStatus, ~setIsSidebarExpanded)
}
},
},
Expand Down Expand Up @@ -440,6 +443,7 @@ let useUpdateMethod = (~showErrorToast=true, ()) => {
let isPlayground = HSLocalStorage.getIsPlaygroundFromLocalStorage()
let url = RescriptReactRouter.useUrl()
let urlPath = url.path->Belt.List.toArray->Js.Array2.joinWith("_")
let {setIsSidebarExpanded} = React.useContext(SidebarProvider.defaultContext)

let popUpCallBack = () =>
showPopUp({
Expand All @@ -454,7 +458,7 @@ let useUpdateMethod = (~showErrorToast=true, ()) => {
_ => {
hyperswitchMixPanel(~eventName=Some(`${urlPath}_tryplayground_register`), ())
hyperswitchMixPanel(~eventName=Some(`global_tryplayground_register`), ())
let _ = handleLogout(~fetchApi, ~setAuthStatus)
let _ = handleLogout(~fetchApi, ~setAuthStatus, ~setIsSidebarExpanded)
}
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ let make = (
</div>
<FormValuesSpy />
</ConnectorAccountDetailsHelper.ConnectorHeaderWrapper>
<ConnectorAccountDetailsHelper.VerifyConnectoModal
<ConnectorAccountDetailsHelper.VerifyConnectorModal
showVerifyModal
setShowVerifyModal
connector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ let make = (
</div>
<FormValuesSpy />
</ConnectorHeaderWrapper>
<VerifyConnectoModal
<VerifyConnectorModal
showVerifyModal
setShowVerifyModal
connector
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
let metaDataInputKeysToIgnore = ["google_pay", "apple_pay", "zen_apple_pay"]

let connectorsWithIntegrationSteps: array<ConnectorTypes.connectorName> = [
ADYEN,
CHECKOUT,
STRIPE,
PAYPAL,
]

let getCurrencyOption: CurrencyUtils.currencyCode => SelectBox.dropdownOption = currencyType => {
open CurrencyUtils
{
Expand Down Expand Up @@ -330,7 +337,7 @@ module BusinessProfileRender = {
}
}

module VerifyConnectoModal = {
module VerifyConnectorModal = {
@react.component
let make = (
~showVerifyModal,
Expand Down Expand Up @@ -408,13 +415,6 @@ module VerifyConnectoModal = {
}
}

let connectorsWithIntegrationSteps: array<ConnectorTypes.connectorName> = [
ADYEN,
CHECKOUT,
STRIPE,
PAYPAL,
]

// Wraps the component with Connector Icon + ConnectorName + InetgrationSteps
module ConnectorHeaderWrapper = {
@react.component
Expand Down
19 changes: 15 additions & 4 deletions src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
open ConnectorTypes

type colType =
Name | TestMode | Status | Actions | ProfileId | ProfileName | ConnectorLabel | PaymentMethods
| Name
| TestMode
| Status
| Disabled
| Actions
| ProfileId
| ProfileName
| ConnectorLabel
| PaymentMethods

let defaultColumns = [
Name,
ProfileId,
ProfileName,
ConnectorLabel,
Status,
Disabled,
TestMode,
Actions,
PaymentMethods,
Expand Down Expand Up @@ -152,7 +161,8 @@ 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="disabled", ~title="Status", ~showSort=false, ())
| Status => Table.makeHeaderInfo(~key="status", ~title="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, ())
| ProfileName =>
Expand All @@ -168,10 +178,11 @@ let getCell = (connector: connectorPayload, colType): Table.cell => {
switch colType {
| Name => Text(connector.connector_name->LogicUtils.getTitle)
| TestMode => Text(connector.test_mode ? "True" : "False")
| Disabled => Text(connector.disabled ? "True" : "False")
| Status =>
Label({
title: (connector.disabled ? "Disabled" : "Enabled")->Js.String2.toUpperCase,
color: connector.disabled ? LabelRed : LabelGreen,
title: connector.status->Js.String2.toUpperCase,
color: connector.status === "inactive" ? LabelRed : LabelGreen,
})
| ProfileId => Text(connector.profile_id)
| ProfileName =>
Expand Down
3 changes: 2 additions & 1 deletion src/screens/HyperSwitch/Home/HomeUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ module CheckoutCard = {
let showPopUp = PopUpState.useShowPopUp()
let hyperswitchMixPanel = HSMixPanel.useSendEvent()
let (_authStatus, setAuthStatus) = React.useContext(AuthInfoProvider.authStatusContext)
let {setIsSidebarExpanded} = React.useContext(SidebarProvider.defaultContext)
let isPlayground = HSLocalStorage.getIsPlaygroundFromLocalStorage()
let isConfigureConnector = ListHooks.useListCount(~entityName=CONNECTOR) > 0
let urlPath = url.path->Belt.List.toArray->Js.Array2.joinWith("_")
Expand All @@ -187,7 +188,7 @@ module CheckoutCard = {
_ => {
hyperswitchMixPanel(~eventName=Some(`${urlPath}_tryplayground_register`), ())
hyperswitchMixPanel(~eventName=Some(`global_tryplayground_register`), ())
let _ = APIUtils.handleLogout(~fetchApi, ~setAuthStatus)
let _ = APIUtils.handleLogout(~fetchApi, ~setAuthStatus, ~setIsSidebarExpanded)
}
},
},
Expand Down
37 changes: 31 additions & 6 deletions src/screens/HyperSwitch/RoutingRevamp/AdvancedRoutingUIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,40 @@ let metaInput = (id, keyType) =>

module FieldInp = {
@react.component
let make = (~ops, ~prefix, ~onChangeMethod) => {
let make = (~methodKeys, ~prefix, ~onChangeMethod) => {
let field = ReactFinalForm.useField(`${prefix}.lhs`).input
let op = ReactFinalForm.useField(`${prefix}.comparison`).input
let val = ReactFinalForm.useField(`${prefix}.value.value`).input

let convertedValue = React.useMemo0(() => {
let keyDescriptionMapper = Window.getDescriptionCategory()->MapTypes.changeType
keyDescriptionMapper->LogicUtils.convertMapObjectToDict
})

let options = React.useMemo0(() =>
convertedValue->Js.Dict.keys->Js.Array2.reduce((acc, ele) => {
open LogicUtils
convertedValue
->getArrayFromDict(ele, [])
->Js.Array2.forEach(
value => {
let dictValue = value->LogicUtils.getDictFromJsonObject
let kindValue = dictValue->getString("kind", "")
if methodKeys->Js.Array2.includes(kindValue) {
let generatedSelectBoxOptionType: SelectBox.dropdownOption = {
label: kindValue,
value: kindValue,
description: dictValue->getString("description", ""),
optGroup: ele,
}
acc->Js.Array2.push(generatedSelectBoxOptionType)->ignore
}
},
)
acc
}, [])
)

let input: ReactFinalForm.fieldRenderPropsInput = {
name: "string",
onBlur: _ev => (),
Expand All @@ -303,10 +332,6 @@ module FieldInp = {
checked: true,
}

let options = ops->Js.Array2.map((op): SelectBox.dropdownOption => {
{value: op, label: op}
})

<SelectBox.BaseDropdown
allowMultiSelect=false buttonText="Select Field" input options hideMultiSelectButtons=true
/>
Expand Down Expand Up @@ -358,7 +383,7 @@ module RuleFieldBase = {
</UIUtils.RenderIf>
<div className="-mt-5 p-1">
<FieldWrapper label="">
<FieldInp ops=methodKeys prefix=id onChangeMethod />
<FieldInp methodKeys prefix=id onChangeMethod />
</FieldWrapper>
</div>
<div className="-mt-5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module ConnectorDetailsForm = {
/>
</>
}}
<ConnectorAccountDetailsHelper.VerifyConnectoModal
<ConnectorAccountDetailsHelper.VerifyConnectorModal
showVerifyModal
setShowVerifyModal
connector={connectorName}
Expand Down Expand Up @@ -445,7 +445,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => {
{getComponentToRender()}
</div>
</div>
<ConnectorAccountDetailsHelper.VerifyConnectoModal
<ConnectorAccountDetailsHelper.VerifyConnectorModal
showVerifyModal
setShowVerifyModal
connector={connectorName}
Expand Down
21 changes: 2 additions & 19 deletions src/screens/HyperSwitch/Sidebar/Sidebar.res
Original file line number Diff line number Diff line change
Expand Up @@ -524,25 +524,8 @@ let make = (

let transformClass = "transform md:translate-x-0 transition"

let handleLogout = _ev => {
open Promise
fetchApi(
APIUtils.getURL(~entityName=USERS, ~methodType=Post, ~userType=#SIGNOUT, ()),
~bodyStr=Js.Json.stringify(Js.Json.object_(Js.Dict.empty())),
~method_=Fetch.Post,
(),
)
->then(Fetch.Response.text)
->then(_ => {
setIsSidebarExpanded(_ => false)
LocalStorage.clear()
setAuthStatus(LoggedOut)
resolve()
})
->catch(_err => {
resolve()
})
->ignore
let handleLogout = _ => {
let _ = APIUtils.handleLogout(~fetchApi, ~setAuthStatus, ~setIsSidebarExpanded)
}

<div className={`bg-sidebar-blue flex group border-r border-jp-gray-500 relative`}>
Expand Down

0 comments on commit f925e09

Please sign in to comment.