Skip to content

Commit

Permalink
Merge branch 'main' into add-webhooks-events
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarnaikjuspay committed Jan 24, 2024
2 parents 90559ba + 0ce1d05 commit 5e2c877
Show file tree
Hide file tree
Showing 23 changed files with 255 additions and 213 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [conven

- - -

## 1.28.1 (2024-01-23)

### Bug Fixes

- Use apifetcher function update ([#283](https://github.com/juspay/hyperswitch-control-center/pull/283)) ([`d587598`](https://github.com/juspay/hyperswitch-control-center/commit/d587598a1f13a234b68b5bc204780fda3c773e0e))
- Changes for supporting form data type in api ([#257](https://github.com/juspay/hyperswitch-control-center/pull/257)) ([`84c283b`](https://github.com/juspay/hyperswitch-control-center/commit/84c283b8092e3296dc97c87725966d540f490d5b))
- Access Control Issue ([#284](https://github.com/juspay/hyperswitch-control-center/pull/284)) ([`f35bcc5`](https://github.com/juspay/hyperswitch-control-center/commit/f35bcc524184c0c1bcc84a41198e81424bef7cc4))

**Full Changelog:** [`v1.28.0...v1.28.1`](https://github.com/juspay/hyperswitch-control-center/compare/v1.28.0...v1.28.1)

- - -


## 1.28.0 (2024-01-22)

### Features
Expand Down
1 change: 1 addition & 0 deletions src/hooks/AuthHooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let getHeaders = (~uri, ~headers, ()) => {
let res = switch hyperSwitchToken {
| Some(token) => {
headers->Dict.set("authorization", `Bearer ${token}`)
headers->Dict.set("api-key", `hyperswitch`)
headers
}

Expand Down
11 changes: 3 additions & 8 deletions src/hooks/ListHooks.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
open APIUtils
let useListCount = (~entityName) => {
open ConnectorUtils
let fetchDetails = useGetMethod()
let (count, setCount) = React.useState(() => 0)

Expand All @@ -11,15 +12,9 @@ let useListCount = (~entityName) => {
let count = switch entityName {
| ROUTING => response->getDictFromJsonObject->getArrayFromDict("records", [])->Array.length
| CONNECTOR =>
response
->getObjectArrayFromJson
->HSwitchUtils.filterList(~removeFromList=FRMPlayer)
->Array.length
response->getObjectArrayFromJson->filterList(~removeFromList=FRMPlayer)->Array.length
| FRAUD_RISK_MANAGEMENT =>
response
->getObjectArrayFromJson
->HSwitchUtils.filterList(~removeFromList=Connector)
->Array.length
response->getObjectArrayFromJson->filterList(~removeFromList=Connector)->Array.length
| _ => response->getArrayFromJson([])->Array.length
}
setCount(_ => count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@ open HomeUtils
module ConnectorOverview = {
@react.component
let make = () => {
open ConnectorUtils
let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading)
let (configuredConnectors, setConfiguredConnectors) = React.useState(_ => [])
let fetchConnectorListResponse = ConnectorUtils.useFetchConnectorList()
let fetchConnectorListResponse = useFetchConnectorList()

let getConnectorList = async () => {
open LogicUtils
try {
let response = await fetchConnectorListResponse()
let connectorsList =
response->HSwitchUtils.getProcessorsListFromJson(
~removeFromList=HSwitchUtils.FRMPlayer,
(),
)
response->getProcessorsListFromJson(~removeFromList=ConnectorTypes.FRMPlayer, ())

let arr =
connectorsList->Array.map(paymentMethod =>
paymentMethod
->getString("connector_name", "")
->ConnectorUtils.getConnectorNameTypeFromString
paymentMethod->getString("connector_name", "")->getConnectorNameTypeFromString
)
setConfiguredConnectors(_ => arr)
setScreenState(_ => Success)
Expand All @@ -42,7 +38,7 @@ module ConnectorOverview = {
->Array.mapWithIndex((connector, index) => {
let iconStyle = `${index === 0 ? "" : "-ml-4"} z-${(30 - index * 10)->Js.Int.toString}`
<GatewayIcon
gateway={connector->ConnectorUtils.getConnectorNameString->String.toUpperCase}
gateway={connector->getConnectorNameString->String.toUpperCase}
className={`w-12 h-12 rounded-full border-3 border-white ${iconStyle} bg-white`}
/>
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,13 @@ let make = (~setCurrentStep, ~setInitialValues, ~initialValues, ~isUpdateFlow, ~
| _ => "Loading..."
}

let (suggestedAction, suggestedActionExists) = ConnectorUtils.getSuggestedAction(
~verifyErrorMessage,
~connector,
)
let (suggestedAction, suggestedActionExists) = getSuggestedAction(~verifyErrorMessage, ~connector)

<PageLoaderWrapper screenState>
<Form
initialValues={updatedInitialVal}
onSubmit={(values, _) =>
ConnectorUtils.onSubmit(
onSubmit(
~values,
~onSubmitVerify,
~onSubmitMain,
Expand Down
29 changes: 14 additions & 15 deletions src/screens/HyperSwitch/Connectors/ConnectorList.res
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ module NewProcessorCards = {
~showIcons: bool,
~isPayoutFlow: bool,
) => {
open ConnectorUtils
let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom

let connectorsAvailableForIntegration = featureFlagDetails.isLiveMode
? ConnectorUtils.connectorListForLive
? connectorListForLive
: isPayoutFlow
? ConnectorUtils.payoutConnectorList
: ConnectorUtils.connectorList
? payoutConnectorList
: connectorList

let unConfiguredConnectors =
connectorsAvailableForIntegration->Array.filter(total =>
Expand Down Expand Up @@ -91,8 +92,8 @@ module NewProcessorCards = {
className="grid gap-x-5 gap-y-6 2xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2 grid-cols-1 mb-5">
{connectorList
->Array.mapWithIndex((connector, i) => {
let connectorName = connector->ConnectorUtils.getConnectorNameString
let connectorInfo = connector->ConnectorUtils.getConnectorInfo
let connectorName = connector->getConnectorNameString
let connectorInfo = connector->getConnectorInfo
let size = "w-14 h-14 rounded-sm"

<div
Expand Down Expand Up @@ -158,7 +159,7 @@ module NewProcessorCards = {
<div className="bg-white rounded-md flex gap-2 flex-wrap p-4 border">
{connectorList
->Array.mapWithIndex((connector, i) => {
let connectorName = connector->ConnectorUtils.getConnectorNameString
let connectorName = connector->getConnectorNameString
let size = "w-14 h-14 rounded-sm"
<ToolTip
key={i->string_of_int}
Expand All @@ -181,9 +182,7 @@ module NewProcessorCards = {
let connectorListFiltered = {
if searchedConnector->String.length > 0 {
connectorsAvailableForIntegration->Array.filter(item =>
item
->ConnectorUtils.getConnectorNameString
->String.includes(searchedConnector->String.toLowerCase)
item->getConnectorNameString->String.includes(searchedConnector->String.toLowerCase)
)
} else {
connectorsAvailableForIntegration
Expand All @@ -196,15 +195,15 @@ module NewProcessorCards = {
{connectorListFiltered->iconsConnectors("Connect a new connector", true, ())}
{<UIUtils.RenderIf condition={featureFlagDetails.testProcessors && !isPayoutFlow}>
{featureFlagDetails.testProcessors
->ConnectorUtils.dummyConnectorList
->dummyConnectorList
->iconsConnectors("Connect a test connector", false, ~showSearch=false, ())}
</UIUtils.RenderIf>}
</>
} else {
<>
<UIUtils.RenderIf condition={featureFlagDetails.testProcessors && !isPayoutFlow}>
{featureFlagDetails.testProcessors
->ConnectorUtils.dummyConnectorList
->dummyConnectorList
->descriptedConnectors("Connect a test connector", false, ~showSearch=false, ())}
</UIUtils.RenderIf>
{connectorListFiltered->descriptedConnectors("Connect a new connector", true, ())}
Expand Down Expand Up @@ -234,16 +233,16 @@ let make = (~isPayoutFlow=false) => {
let (filteredConnectorData, setFilteredConnectorData) = React.useState(_ => [])
let (offset, setOffset) = React.useState(_ => 0)
let detailedCardCount = 5
let showConnectorIcons = configuredConnectors->len > detailedCardCount
let showConnectorIcons = configuredConnectors->Array.length > detailedCardCount
let (searchText, setSearchText) = React.useState(_ => "")
let fetchConnectorListResponse = ConnectorUtils.useFetchConnectorList()
let fetchConnectorListResponse = useFetchConnectorList()

let getConnectorListAndUpdateState = async () => {
open LogicUtils
try {
let response = await fetchConnectorListResponse()
let removeFromList = isPayoutFlow ? HSwitchUtils.PayoutConnector : HSwitchUtils.FRMPlayer
let connectorsList = response->HSwitchUtils.getProcessorsListFromJson(~removeFromList, ())
let removeFromList = isPayoutFlow ? ConnectorTypes.PayoutConnector : ConnectorTypes.FRMPlayer
let connectorsList = response->getProcessorsListFromJson(~removeFromList, ())
let previousData = connectorsList->Array.map(ConnectorTableUtils.getProcessorPayloadType)

setFilteredConnectorData(_ => previousData->Array.map(Js.Nullable.return))
Expand Down
4 changes: 2 additions & 2 deletions src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let make = (
React.useEffect1(() => {
setScreenState(_ => Loading)
initialValues
->ConnectorUtils.getConnectorPaymentMethodDetails(
->getConnectorPaymentMethodDetails(
setPaymentMethods,
setMetaData,
setScreenState,
Expand All @@ -52,7 +52,7 @@ let make = (
let body =
constructConnectorRequestBody(obj, initialValues)->ignoreFields(
connectorID->Option.getWithDefault(""),
ConnectorUtils.connectorIgnoredField,
connectorIgnoredField,
)
let connectorUrl = getURL(~entityName=CONNECTOR, ~methodType=Post, ~id=connectorID, ())
let response = await updateAPIHook(connectorUrl, body, Post, ())
Expand Down
4 changes: 1 addition & 3 deletions src/screens/HyperSwitch/Connectors/ConnectorTableUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,9 @@ let getCell = (connector: connectorPayload, colType): Table.cell => {
}
}

let connectorsTableDefaultColumns = Recoil.atom(. "connectorsTableDefaultColumns", defaultColumns)

let getArrayDataFromJson = (json, itemToObjMapper: Js.Dict.t<Js.Json.t> => connectorPayload) => {
json
->HSwitchUtils.getProcessorsListFromJson()
->ConnectorUtils.getProcessorsListFromJson()
->Array.map(itemToObjMapper)
->Array.filter(item => !(item.connector_name->String.includes("apple")))
}
Expand Down
2 changes: 2 additions & 0 deletions src/screens/HyperSwitch/Connectors/ConnectorTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,5 @@ type connectorPayload = {
frm_configs?: array<frm_config>,
status: string,
}

type processors = FRMPlayer | Connector | PayoutConnector
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ let isSelectedAll = (
open ConnectorUtils
let paymentMethodObj = selectedPaymentMethod->getSelectedPaymentObj(paymentMethod)
switch paymentMethod->getPaymentMethodFromString {
| Card => paymentMethodObj.card_provider->Option.getWithDefault([])->len == allPaymentMethods->len
| _ => paymentMethodObj.provider->Option.getWithDefault([])->len == allPaymentMethods->len
| Card =>
paymentMethodObj.card_provider->Option.getWithDefault([])->Array.length ==
allPaymentMethods->Array.length
| _ =>
paymentMethodObj.provider->Option.getWithDefault([])->Array.length ==
allPaymentMethods->Array.length
}
}

Expand Down Expand Up @@ -76,13 +80,13 @@ module CardRenderer = {
if val.payment_method_type === paymentMethod {
switch paymentMethod->getPaymentMethodTypeFromString {
| Credit | Debit =>
let length = val.card_provider->Option.getWithDefault([])->len
let length = val.card_provider->Option.getWithDefault([])->Array.length
val.card_provider
->Option.getWithDefault([])
->Array.splice(~start=0, ~remove=length, ~insert=arr)
->ignore
| _ =>
let length = val.provider->Option.getWithDefault([])->len
let length = val.provider->Option.getWithDefault([])->Array.length

val.provider
->Option.getWithDefault([])
Expand Down
Loading

0 comments on commit 5e2c877

Please sign in to comment.