From f62b87ae15437e59d4e294c9bd57da2710d48120 Mon Sep 17 00:00:00 2001
From: Pritish Budhiraja <1805317@kiit.ac.in>
Date: Fri, 22 Dec 2023 15:53:34 +0530
Subject: [PATCH 01/18] feat: x-feature added for hyperswitch-custom
---
src/hooks/AuthHooks.res | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res
index 7768a85be..f1c5e15d6 100644
--- a/src/hooks/AuthHooks.res
+++ b/src/hooks/AuthHooks.res
@@ -38,6 +38,7 @@ let getHeaders = (~uri, ~headers, ()) => {
"Content-Type": "application/json",
"Authorization": `Bearer ${hyperSwitchToken->Belt.Option.getWithDefault("")}`,
"api-key": "hyperswitch",
+ "x-feature": "hyperswitch-custom",
}
Fetch.HeadersInit.make(headerObj)
From f079b965419f2faec0be4d07ccc0f1eb3522a0fb Mon Sep 17 00:00:00 2001
From: Pritish Budhiraja <1805317@kiit.ac.in>
Date: Fri, 22 Dec 2023 15:54:01 +0530
Subject: [PATCH 02/18] fix: formatting
---
.../HyperSwitch/UserManagement/UserRoleEntry.res | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/screens/HyperSwitch/UserManagement/UserRoleEntry.res b/src/screens/HyperSwitch/UserManagement/UserRoleEntry.res
index faebc0ed5..52ba0efb3 100644
--- a/src/screens/HyperSwitch/UserManagement/UserRoleEntry.res
+++ b/src/screens/HyperSwitch/UserManagement/UserRoleEntry.res
@@ -122,14 +122,14 @@ let make = () => {
subTitle="Manage user roles and invite members of your organisation"
/>
- //
- //
+ //
+ //
Date: Fri, 22 Dec 2023 18:29:29 +0530
Subject: [PATCH 03/18] fix: x-feature
---
src/hooks/AuthHooks.res | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res
index f1c5e15d6..7fce63ec5 100644
--- a/src/hooks/AuthHooks.res
+++ b/src/hooks/AuthHooks.res
@@ -14,6 +14,8 @@ let getHeaders = (~uri, ~headers, ()) => {
let hyperSwitchToken = LocalStorage.getItem("login")->Js.Nullable.toOption
let isMixpanel = uri->Js.String2.includes("mixpanel")
+ Js.log2(uri, "uri")
+
if isMixpanel {
let headerObj = {
"Content-Type": "application/x-www-form-urlencoded",
@@ -34,14 +36,26 @@ let getHeaders = (~uri, ~headers, ()) => {
switch hyperSwitchToken {
| Some(token) =>
if token !== "" {
- let headerObj = {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${hyperSwitchToken->Belt.Option.getWithDefault("")}`,
- "api-key": "hyperswitch",
- "x-feature": "hyperswitch-custom",
+ if (
+ uri->Js.String2.includes("lottie-files") ||
+ uri->Js.String2.includes("config/merchant-access")
+ ) {
+ let headerObj = {
+ "Content-Type": "application/json",
+ "Authorization": `Bearer ${hyperSwitchToken->Belt.Option.getWithDefault("")}`,
+ "api-key": "hyperswitch",
+ }
+ Js.log2(headerObj, "headerObjheaderObjheaderObjheaderObj")
+ Fetch.HeadersInit.make(headerObj)
+ } else {
+ let headerObj = {
+ "Content-Type": "application/json",
+ "Authorization": `Bearer ${hyperSwitchToken->Belt.Option.getWithDefault("")}`,
+ "api-key": "hyperswitch",
+ "x-feature": "hyperswitch-custom",
+ }
+ Fetch.HeadersInit.make(headerObj)
}
-
- Fetch.HeadersInit.make(headerObj)
} else {
let headerObj = {
"Content-Type": "application/json",
From a56f7bc76e941b737a2f846a1581bbb56ed23c46 Mon Sep 17 00:00:00 2001
From: Jeeva Ramachandran
Date: Fri, 22 Dec 2023 19:29:31 +0530
Subject: [PATCH 04/18] fix: enums
---
src/entryPoints/hyperswitch/HyperSwitchApp.res | 10 +++++++++-
src/hooks/AuthHooks.res | 2 +-
.../HSwitchProdOnboarding/ProdOnboardingLanding.res | 12 +++++++-----
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/entryPoints/hyperswitch/HyperSwitchApp.res b/src/entryPoints/hyperswitch/HyperSwitchApp.res
index 088b47a1d..7905bc524 100644
--- a/src/entryPoints/hyperswitch/HyperSwitchApp.res
+++ b/src/entryPoints/hyperswitch/HyperSwitchApp.res
@@ -80,7 +80,15 @@ let make = () => {
let url = #ProductionAgreement->ProdOnboardingUtils.getProdOnboardingUrl
let response = await fetchDetails(url)
- if response->getDictFromJsonObject->getBool("ProductionAgreement", false) {
+ let productionAgreementResponse =
+ response
+ ->getArrayFromJson([])
+ ->Js.Array2.find(ele => {
+ ele->getDictFromJsonObject->getBool("ProductionAgreement", false)
+ })
+ ->Option.getWithDefault(Js.Json.null)
+
+ if productionAgreementResponse->getDictFromJsonObject->getBool("ProductionAgreement", false) {
setDashboardPageState(_ => #PROD_ONBOARDING)
} else {
setDashboardPageState(_ => #AGREEMENT_SIGNATURE)
diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res
index 7fce63ec5..64b4e25b7 100644
--- a/src/hooks/AuthHooks.res
+++ b/src/hooks/AuthHooks.res
@@ -45,7 +45,6 @@ let getHeaders = (~uri, ~headers, ()) => {
"Authorization": `Bearer ${hyperSwitchToken->Belt.Option.getWithDefault("")}`,
"api-key": "hyperswitch",
}
- Js.log2(headerObj, "headerObjheaderObjheaderObjheaderObj")
Fetch.HeadersInit.make(headerObj)
} else {
let headerObj = {
@@ -66,6 +65,7 @@ let getHeaders = (~uri, ~headers, ()) => {
| None =>
let headerObj = {
"Content-Type": "application/json",
+ "x-feature": "hyperswitch-custom",
}
Fetch.HeadersInit.make(headerObj)
}
diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/ProdOnboardingLanding.res b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/ProdOnboardingLanding.res
index 92629c41c..fc4bfb257 100644
--- a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/ProdOnboardingLanding.res
+++ b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/ProdOnboardingLanding.res
@@ -205,12 +205,14 @@ let make = () => {
try {
let url = #SetupProcessor->ProdOnboardingUtils.getProdOnboardingUrl
let response = await fetchDetails(url)
- let connectorId =
+ let setupProcessorEnum =
response
- ->getDictFromJsonObject
- ->getJsonObjectFromDict("SetupProcessor")
- ->getDictFromJsonObject
- ->getString("connector_id", "")
+ ->getArrayFromJson([])
+ ->Js.Array2.find(ele => {
+ ele->getDictFromJsonObject->getBool("SetupProcessor", false)
+ })
+ ->Option.getWithDefault(Js.Json.null)
+ let connectorId = setupProcessorEnum->getDictFromJsonObject->getString("connector_id", "")
if connectorId->Js.String2.length > 0 {
setConnectorID(_ => connectorId)
getConfigureEndpointEnum()->ignore
From 1d0d68bf9d2fe6f2e01ae138d2bda8e4db94f37c Mon Sep 17 00:00:00 2001
From: Pritish Budhiraja <1805317@kiit.ac.in>
Date: Fri, 22 Dec 2023 19:57:42 +0530
Subject: [PATCH 05/18] fix: Prod Enum Changes
---
.../ProdOnboardingLanding.res | 35 +++++++++++++++----
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/ProdOnboardingLanding.res b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/ProdOnboardingLanding.res
index fc4bfb257..14ae8b800 100644
--- a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/ProdOnboardingLanding.res
+++ b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/ProdOnboardingLanding.res
@@ -161,10 +161,18 @@ let make = () => {
let urlPush = `${HSwitchGlobalVars.hyperSwitchFEPrefix}/prod-onboarding?${routerUrl.search}`
let getSetupCompleteEnum = async () => {
+ open LogicUtils
try {
let url = #SetupComplete->ProdOnboardingUtils.getProdOnboardingUrl
let response = await fetchDetails(url)
- if response->LogicUtils.getDictFromJsonObject->LogicUtils.getBool("SetupComplete", false) {
+ let setupCompleteResponse =
+ response
+ ->getArrayFromJson([])
+ ->Array.find(ele => {
+ ele->getDictFromJsonObject->getBool("SetupComplete", false)
+ })
+ ->Option.getWithDefault(Js.Json.null)
+ if setupCompleteResponse->getDictFromJsonObject->getBool("SetupComplete", false) {
setDashboardPageState(_ => #HOME)
let baseUrlPath = `${HSwitchGlobalVars.hyperSwitchFEPrefix}/${routerUrl.path
->Belt.List.toArray
@@ -183,12 +191,19 @@ let make = () => {
}
let getConfigureEndpointEnum = async () => {
+ open LogicUtils
try {
let url = #ConfigureEndpoint->ProdOnboardingUtils.getProdOnboardingUrl
let response = await fetchDetails(url)
- if (
- response->LogicUtils.getDictFromJsonObject->LogicUtils.getBool("ConfigureEndpoint", false)
- ) {
+ let configureEndpointResponse =
+ response
+ ->getArrayFromJson([])
+ ->Array.find(ele => {
+ ele->getDictFromJsonObject->getBool("ConfigureEndpoint", false)
+ })
+ ->Option.getWithDefault(Js.Json.null)
+
+ if configureEndpointResponse->getDictFromJsonObject->getBool("ConfigureEndpoint", false) {
getSetupCompleteEnum()->ignore
} else {
RescriptReactRouter.push(urlPush)
@@ -208,11 +223,17 @@ let make = () => {
let setupProcessorEnum =
response
->getArrayFromJson([])
- ->Js.Array2.find(ele => {
- ele->getDictFromJsonObject->getBool("SetupProcessor", false)
+ ->Array.find(ele => {
+ ele->getDictFromJsonObject->getDictfromDict("SetupProcessor") != Js.Dict.empty()
})
->Option.getWithDefault(Js.Json.null)
- let connectorId = setupProcessorEnum->getDictFromJsonObject->getString("connector_id", "")
+
+ let connectorId =
+ setupProcessorEnum
+ ->getDictFromJsonObject
+ ->getDictfromDict("SetupProcessor")
+ ->getString("connector_id", "")
+
if connectorId->Js.String2.length > 0 {
setConnectorID(_ => connectorId)
getConfigureEndpointEnum()->ignore
From 2a0ff8556e8d421f5111c54c06c7c18f393f727d Mon Sep 17 00:00:00 2001
From: Pritish Budhiraja <1805317@kiit.ac.in>
Date: Fri, 22 Dec 2023 21:57:55 +0530
Subject: [PATCH 06/18] fix: Log removal
---
src/hooks/AuthHooks.res | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res
index 64b4e25b7..d0176f7eb 100644
--- a/src/hooks/AuthHooks.res
+++ b/src/hooks/AuthHooks.res
@@ -14,8 +14,6 @@ let getHeaders = (~uri, ~headers, ()) => {
let hyperSwitchToken = LocalStorage.getItem("login")->Js.Nullable.toOption
let isMixpanel = uri->Js.String2.includes("mixpanel")
- Js.log2(uri, "uri")
-
if isMixpanel {
let headerObj = {
"Content-Type": "application/x-www-form-urlencoded",
From a64ec0518ac82b413df54eaba9f1469747926ad1 Mon Sep 17 00:00:00 2001
From: Pritish Budhiraja <1805317@kiit.ac.in>
Date: Fri, 22 Dec 2023 22:18:19 +0530
Subject: [PATCH 07/18] fix: x-feature for None case
---
src/hooks/AuthHooks.res | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res
index d0176f7eb..e1324d77d 100644
--- a/src/hooks/AuthHooks.res
+++ b/src/hooks/AuthHooks.res
@@ -61,11 +61,21 @@ let getHeaders = (~uri, ~headers, ()) => {
}
| None =>
- let headerObj = {
- "Content-Type": "application/json",
- "x-feature": "hyperswitch-custom",
+ if (
+ uri->Js.String2.includes("lottie-files") ||
+ uri->Js.String2.includes("config/merchant-access")
+ ) {
+ let headerObj = {
+ "Content-Type": "application/json",
+ }
+ Fetch.HeadersInit.make(headerObj)
+ } else {
+ let headerObj = {
+ "Content-Type": "application/json",
+ "x-feature": "hyperswitch-custom",
+ }
+ Fetch.HeadersInit.make(headerObj)
}
- Fetch.HeadersInit.make(headerObj)
}
}
}
From 822b34edccabff1bff996b999803eabacff162aa Mon Sep 17 00:00:00 2001
From: Pritish Budhiraja <1805317@kiit.ac.in>
Date: Fri, 22 Dec 2023 22:40:28 +0530
Subject: [PATCH 08/18] fix: handlelogout changes
---
src/screens/HyperSwitch/APIUtils/APIUtils.res | 2 +-
src/screens/HyperSwitch/Sidebar/Sidebar.res | 4 ----
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/src/screens/HyperSwitch/APIUtils/APIUtils.res b/src/screens/HyperSwitch/APIUtils/APIUtils.res
index c4ed16b9f..55bdecf34 100644
--- a/src/screens/HyperSwitch/APIUtils/APIUtils.res
+++ b/src/screens/HyperSwitch/APIUtils/APIUtils.res
@@ -256,7 +256,7 @@ let handleLogout = async (
setAuthStatus(HyperSwitchAuthTypes.LoggedOut)
setIsSidebarExpanded(_ => false)
LocalStorage.clear()
- RescriptReactRouter.push("/register")
+ RescriptReactRouter.push("/login")
}
let responseHandler = async (
diff --git a/src/screens/HyperSwitch/Sidebar/Sidebar.res b/src/screens/HyperSwitch/Sidebar/Sidebar.res
index cf2ae62b5..09a44b3ea 100644
--- a/src/screens/HyperSwitch/Sidebar/Sidebar.res
+++ b/src/screens/HyperSwitch/Sidebar/Sidebar.res
@@ -670,10 +670,6 @@ let make = (
text="Profile"
/>
-
-
- {HSwitchGlobalVars.hyperSwitchversion->React.string}
-
}}
From 95f9f0f30a55fe6537ae195e8935c0fdc7d1d40c Mon Sep 17 00:00:00 2001
From: Pritish Budhiraja <1805317@kiit.ac.in>
Date: Tue, 9 Jan 2024 18:20:41 +0530
Subject: [PATCH 09/18] chore: change data type response for switch merchant
---
.../SwitchMerchant/SwitchMerchant.res | 60 ++++++++++++++++---
1 file changed, 51 insertions(+), 9 deletions(-)
diff --git a/src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res b/src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res
index 5a5bd3c5b..aea02372d 100644
--- a/src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res
+++ b/src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res
@@ -1,3 +1,26 @@
+type switchMerchantListResponse = {
+ merchant_id: string,
+ merchant_name: option,
+}
+
+let convertListResponseToTypedResponse = json => {
+ open LogicUtils
+ json
+ ->getArrayFromJson([])
+ ->Array.map(ele => {
+ let dictOfElement = ele->getDictFromJsonObject
+ let merchantId = dictOfElement->getString("merchant_id", "")
+ let merchantName = dictOfElement->getString("merchant_name", "")
+
+ {
+ merchant_id: merchantId,
+ merchant_name: {
+ Some(merchantName->String.length > 0 ? merchantName : merchantId)
+ },
+ }
+ })
+}
+
module NewAccountCreationModal = {
@react.component
let make = (~setShowModal, ~showModal, ~fetchMerchantIDs) => {
@@ -118,7 +141,10 @@ module ExternalUser = {
let make = (~switchMerchant, ~isAddMerchantEnabled) => {
open APIUtils
let fetchDetails = useGetMethod()
- let (selectedMerchantID, setSelectedMerchantID) = React.useState(_ => "")
+ let (selectedMerchantObject, setSelectedMerchantObject) = React.useState(_ => {
+ merchant_id: "",
+ merchant_name: None,
+ })
let (showModal, setShowModal) = React.useState(_ => false)
let (options, setOptions) = React.useState(_ => [])
@@ -126,16 +152,24 @@ module ExternalUser = {
let url = getURL(~entityName=USERS, ~userType=#SWITCH_MERCHANT, ~methodType=Get, ())
try {
let res = await fetchDetails(url)
- let merchantIdsArray = res->LogicUtils.getStrArryFromJson
- setOptions(_ => merchantIdsArray)
+ let typedValueOfResponse = res->convertListResponseToTypedResponse
+ setOptions(_ => typedValueOfResponse)
+ let extractMerchantObject =
+ typedValueOfResponse
+ ->Array.find(ele => {
+ ele.merchant_id === HSLocalStorage.getFromMerchantDetails("merchant_id")
+ })
+ ->Option.getWithDefault({
+ merchant_id: "",
+ merchant_name: None,
+ })
+ setSelectedMerchantObject(_ => extractMerchantObject)
} catch {
| _ => ()
}
}
React.useEffect0(() => {
- open HSLocalStorage
- setSelectedMerchantID(_ => getFromMerchantDetails("merchant_id"))
fetchMerchantIDs()->ignore
None
})
@@ -149,7 +183,9 @@ module ExternalUser = {
className="inline-flex whitespace-pre leading-5 justify-center text-sm font-medium px-4 py-2 font-medium rounded-md hover:bg-opacity-80 bg-white border">
{buttonProps => {
<>
- {selectedMerchantID->React.string}
+ {selectedMerchantObject.merchant_name
+ ->Option.getWithDefault(selectedMerchantObject.merchant_id)
+ ->React.string}
>
}}
@@ -172,7 +208,7 @@ module ExternalUser = {
{props =>
-
+
Date: Tue, 9 Jan 2024 20:24:43 +0530
Subject: [PATCH 10/18] fix: type changes
---
.../SwitchMerchant/SwitchMerchant.res | 31 +++++++------------
1 file changed, 11 insertions(+), 20 deletions(-)
diff --git a/src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res b/src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res
index 6410ac9b4..8df3da6ad 100644
--- a/src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res
+++ b/src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res
@@ -1,6 +1,6 @@
type switchMerchantListResponse = {
merchant_id: string,
- merchant_name: option,
+ merchant_name: string,
}
let convertListResponseToTypedResponse = json => {
@@ -10,13 +10,11 @@ let convertListResponseToTypedResponse = json => {
->Array.map(ele => {
let dictOfElement = ele->getDictFromJsonObject
let merchantId = dictOfElement->getString("merchant_id", "")
- let merchantName = dictOfElement->getString("merchant_name", "")
+ let merchantName = dictOfElement->getString("merchant_name", merchantId)
{
merchant_id: merchantId,
- merchant_name: {
- Some(merchantName->String.length > 0 ? merchantName : merchantId)
- },
+ merchant_name: merchantName->String.length > 0 ? merchantName : merchantId,
}
})
}
@@ -141,9 +139,10 @@ module ExternalUser = {
let make = (~switchMerchant, ~isAddMerchantEnabled) => {
open APIUtils
let fetchDetails = useGetMethod()
+ let defaultMerchantId = HSLocalStorage.getFromMerchantDetails("merchant_id")
let (selectedMerchantObject, setSelectedMerchantObject) = React.useState(_ => {
- merchant_id: "",
- merchant_name: None,
+ merchant_id: defaultMerchantId,
+ merchant_name: defaultMerchantId,
})
let (showModal, setShowModal) = React.useState(_ => false)
let (options, setOptions) = React.useState(_ => [])
@@ -156,12 +155,10 @@ module ExternalUser = {
setOptions(_ => typedValueOfResponse)
let extractMerchantObject =
typedValueOfResponse
- ->Array.find(ele => {
- ele.merchant_id === HSLocalStorage.getFromMerchantDetails("merchant_id")
- })
+ ->Array.find(ele => ele.merchant_id === defaultMerchantId)
->Option.getWithDefault({
- merchant_id: "",
- merchant_name: None,
+ merchant_id: defaultMerchantId,
+ merchant_name: defaultMerchantId,
})
setSelectedMerchantObject(_ => extractMerchantObject)
} catch {
@@ -183,9 +180,7 @@ module ExternalUser = {
className="inline-flex whitespace-pre leading-5 justify-center text-sm font-medium px-4 py-2 font-medium rounded-md hover:bg-opacity-80 bg-white border">
{buttonProps => {
<>
- {selectedMerchantObject.merchant_name
- ->Option.getWithDefault(selectedMerchantObject.merchant_id)
- ->React.string}
+ {selectedMerchantObject.merchant_name->React.string}
>
}}
@@ -217,11 +212,7 @@ module ExternalUser = {
}
`${activeClasses} font-medium`
}>
-
- {option.merchant_name
- ->Option.getWithDefault(option.merchant_id)
- ->React.string}
-
+ {option.merchant_name->React.string}
Date: Tue, 9 Jan 2024 23:33:42 +0530
Subject: [PATCH 11/18] feat: Feature flag for customer_module added
---
config/FeatureFlag.json | 3 ++-
src/entryPoints/hyperswitch/FeatureFlagUtils.res | 2 ++
src/entryPoints/hyperswitch/HyperSwitchApp.res | 16 +++++++++-------
src/entryPoints/hyperswitch/SidebarValues.res | 9 ++++++---
4 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/config/FeatureFlag.json b/config/FeatureFlag.json
index ac79d7b7b..3e92b2b8f 100644
--- a/config/FeatureFlag.json
+++ b/config/FeatureFlag.json
@@ -21,5 +21,6 @@
"generate_report": false,
"forgot_password": false,
"user_journey_analytics": false,
- "surcharge": false
+ "surcharge": false,
+ "customer_module": false
}
diff --git a/src/entryPoints/hyperswitch/FeatureFlagUtils.res b/src/entryPoints/hyperswitch/FeatureFlagUtils.res
index 6d79cd346..265b9b032 100644
--- a/src/entryPoints/hyperswitch/FeatureFlagUtils.res
+++ b/src/entryPoints/hyperswitch/FeatureFlagUtils.res
@@ -23,6 +23,7 @@ type featureFlag = {
forgetPassword: bool,
userJourneyAnalytics: bool,
surcharge: bool,
+ customerModule: bool,
}
let featureFlagType = (featureFlags: Js.Json.t) => {
@@ -53,6 +54,7 @@ let featureFlagType = (featureFlags: Js.Json.t) => {
forgetPassword: dict->getBool("forgot_password", false),
userJourneyAnalytics: dict->getBool("user_journey_analytics", false),
surcharge: dict->getBool("surcharge", false),
+ customerModule: dict->getBool("customer_module", false),
}
typedFeatureFlag
}
diff --git a/src/entryPoints/hyperswitch/HyperSwitchApp.res b/src/entryPoints/hyperswitch/HyperSwitchApp.res
index 00f98babe..4049ee46b 100644
--- a/src/entryPoints/hyperswitch/HyperSwitchApp.res
+++ b/src/entryPoints/hyperswitch/HyperSwitchApp.res
@@ -283,13 +283,15 @@ let make = () => {
renderShow={id => }
/>
| list{"customers", ...remainingPath} =>
- }
- renderShow={id => }
- />
+
+ }
+ renderShow={id => }
+ />
+
| list{"routing", ...remainingPath} =>
{
+let operations = (isOperationsEnabled, customerModule) => {
isOperationsEnabled
? Section({
name: "Operations",
icon: "hswitch-operations",
showSection: true,
- links: [payments, refunds, disputes, customers],
+ links: customerModule
+ ? [payments, refunds, disputes, customers]
+ : [payments, refunds, disputes],
})
: emptyComponent
}
@@ -337,11 +339,12 @@ let getHyperSwitchAppSidebars = (
userJourneyAnalytics: userJourneyAnalyticsFlag,
surcharge: isSurchargeEnabled,
isLiveMode,
+ customerModule,
} = featureFlagDetails
let sidebar = [
productionAccess->productionAccessComponent,
default->home,
- default->operations,
+ default->operations(customerModule),
default->analytics(userJourneyAnalyticsFlag),
default->connectors(isLiveMode),
default->workflow(isSurchargeEnabled),
From 867f305abc66aa7ba7b0ca8083e024be1e9754c4 Mon Sep 17 00:00:00 2001
From: Pritish Budhiraja <1805317@kiit.ac.in>
Date: Wed, 24 Jan 2024 13:21:56 +0530
Subject: [PATCH 12/18] feat: x-feature addition
---
config/FeatureFlag.json | 3 +-
.../hyperswitch/FeatureFlagUtils.res | 2 +
src/hooks/AuthHooks.res | 59 +++++++++----------
3 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/config/FeatureFlag.json b/config/FeatureFlag.json
index 2a0addeb4..c100caa50 100644
--- a/config/FeatureFlag.json
+++ b/config/FeatureFlag.json
@@ -23,5 +23,6 @@
"user_journey_analytics": false,
"surcharge": false,
"customers_module": false,
- "permission_based_module": false
+ "permission_based_module": false,
+ "x_feature_route": false
}
diff --git a/src/entryPoints/hyperswitch/FeatureFlagUtils.res b/src/entryPoints/hyperswitch/FeatureFlagUtils.res
index dda0429d9..081955173 100644
--- a/src/entryPoints/hyperswitch/FeatureFlagUtils.res
+++ b/src/entryPoints/hyperswitch/FeatureFlagUtils.res
@@ -25,6 +25,7 @@ type featureFlag = {
surcharge: bool,
customersModule: bool,
permissionBasedModule: bool,
+ xFeatureRoute: bool,
}
let featureFlagType = (featureFlags: Js.Json.t) => {
@@ -57,6 +58,7 @@ let featureFlagType = (featureFlags: Js.Json.t) => {
surcharge: dict->getBool("surcharge", false),
customersModule: dict->getBool("customers_module", false),
permissionBasedModule: dict->getBool("permission_based_module", false),
+ xFeatureRoute: dict->getBool("x_feature_route", false),
}
typedFeatureFlag
}
diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res
index 5e7615dc4..8c1266d9d 100644
--- a/src/hooks/AuthHooks.res
+++ b/src/hooks/AuthHooks.res
@@ -10,48 +10,44 @@ type sessionStorage = {
external dictToObj: Js.Dict.t<'a> => {..} = "%identity"
@val external atob: string => string = "atob"
-let getHeaders = (~uri, ~headers, ()) => {
+let getHeaders = (~uri, ~headers, ~xFeatureRoute, ()) => {
let hyperSwitchToken = LocalStorage.getItem("login")->Js.Nullable.toOption
let isMixpanel = uri->String.includes("mixpanel")
+ let headersForXFeature = (~token) =>
+ if (
+ uri->Js.String2.includes("lottie-files") || uri->Js.String2.includes("config/merchant-access")
+ ) {
+ headers->Dict.set("Content-Type", `application/json`)
+ headers->Dict.set("authorization", `Bearer ${token}`)
+ headers->Dict.set("api-key", `hyperswitch`)
+ headers
+ } else {
+ headers->Dict.set("authorization", `Bearer ${token}`)
+ headers->Dict.set("api-key", `hyperswitch`)
+ headers->Dict.set("x-feature", "hyperswitch-custom")
+ headers
+ }
+
let headerObj = if isMixpanel {
[
("Content-Type", "application/x-www-form-urlencoded"),
("accept", "application/json"),
]->Dict.fromArray
} else {
- let res = switch hyperSwitchToken {
+ let headersDict = switch hyperSwitchToken {
| Some(token) =>
- if (
- uri->Js.String2.includes("lottie-files") ||
- uri->Js.String2.includes("config/merchant-access")
- ) {
- [
- ("Content-Type", "application/json"),
- ("Authorization", `Bearer ${hyperSwitchToken->Belt.Option.getWithDefault("")}`),
- ("api-key", "hyperswitch"),
- ]->Dict.fromArray
- } else {
- headers->Dict.set("authorization", `Bearer ${token}`)
- headers->Dict.set("api-key", `hyperswitch`)
- headers
- }
+ xFeatureRoute
+ ? headersForXFeature(~token)
+ : {
+ headers->Dict.set("authorization", `Bearer ${token}`)
+ headers->Dict.set("api-key", `hyperswitch`)
+ headers
+ }
- | None =>
- if (
- uri->Js.String2.includes("lottie-files") ||
- uri->Js.String2.includes("config/merchant-access")
- ) {
- [
- ("Content-Type", "application/json"),
- ("Authorization", `Bearer ${hyperSwitchToken->Belt.Option.getWithDefault("")}`),
- ("api-key", "hyperswitch"),
- ]->Dict.fromArray
- } else {
- headers
- }
+ | None => xFeatureRoute ? headersForXFeature(~token="") : headers
}
- res
+ headersDict
}
Fetch.HeadersInit.make(headerObj->dictToObj)
}
@@ -67,6 +63,7 @@ type betaEndpoint = {
let useApiFetcher = () => {
let (authStatus, setAuthStatus) = React.useContext(AuthInfoProvider.authStatusContext)
+ let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
let token = React.useMemo1(() => {
switch authStatus {
@@ -113,7 +110,7 @@ let useApiFetcher = () => {
~method_,
~body?,
~credentials=SameOrigin,
- ~headers=getHeaders(~headers, ~uri, ()),
+ ~headers=getHeaders(~headers, ~uri, ~xFeatureRoute, ()),
(),
),
)
From f19bc243c535dbc1f964ba02b6ec665bf126178e Mon Sep 17 00:00:00 2001
From: Pritish Budhiraja <1805317@kiit.ac.in>
Date: Wed, 24 Jan 2024 14:48:58 +0530
Subject: [PATCH 13/18] fix: comments addresssed
---
src/hooks/AuthHooks.res | 45 +++++++++++++++++------------------------
1 file changed, 18 insertions(+), 27 deletions(-)
diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res
index 8c1266d9d..29995a58a 100644
--- a/src/hooks/AuthHooks.res
+++ b/src/hooks/AuthHooks.res
@@ -10,44 +10,35 @@ type sessionStorage = {
external dictToObj: Js.Dict.t<'a> => {..} = "%identity"
@val external atob: string => string = "atob"
+let headersForXFeature = (~uri, ~headers) => {
+ if uri->String.includes("lottie-files") || uri->String.includes("config/merchant-access") {
+ headers->Dict.set("Content-Type", `application/json`)
+ } else {
+ headers->Dict.set("x-feature", "hyperswitch-custom")
+ }
+}
+
let getHeaders = (~uri, ~headers, ~xFeatureRoute, ()) => {
let hyperSwitchToken = LocalStorage.getItem("login")->Js.Nullable.toOption
let isMixpanel = uri->String.includes("mixpanel")
- let headersForXFeature = (~token) =>
- if (
- uri->Js.String2.includes("lottie-files") || uri->Js.String2.includes("config/merchant-access")
- ) {
- headers->Dict.set("Content-Type", `application/json`)
- headers->Dict.set("authorization", `Bearer ${token}`)
- headers->Dict.set("api-key", `hyperswitch`)
- headers
- } else {
- headers->Dict.set("authorization", `Bearer ${token}`)
- headers->Dict.set("api-key", `hyperswitch`)
- headers->Dict.set("x-feature", "hyperswitch-custom")
- headers
- }
-
let headerObj = if isMixpanel {
[
("Content-Type", "application/x-www-form-urlencoded"),
("accept", "application/json"),
]->Dict.fromArray
} else {
- let headersDict = switch hyperSwitchToken {
- | Some(token) =>
- xFeatureRoute
- ? headersForXFeature(~token)
- : {
- headers->Dict.set("authorization", `Bearer ${token}`)
- headers->Dict.set("api-key", `hyperswitch`)
- headers
- }
-
- | None => xFeatureRoute ? headersForXFeature(~token="") : headers
+ if xFeatureRoute {
+ headersForXFeature(~headers, ~uri)
+ }
+ switch hyperSwitchToken {
+ | Some(token) => {
+ headers->Dict.set("authorization", `Bearer ${token}`)
+ headers->Dict.set("api-key", `hyperswitch`)
+ }
+ | None => ()
}
- headersDict
+ headers
}
Fetch.HeadersInit.make(headerObj->dictToObj)
}
From 1b8f2595c5be2ccf65b00c52ae548bd9e2caaa81 Mon Sep 17 00:00:00 2001
From: Riddhi Agrawal
Date: Thu, 1 Feb 2024 12:47:58 +0530
Subject: [PATCH 14/18] fix: changes for x-feature
---
src/hooks/AuthHooks.res | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res
index cc04b13cc..4c4640728 100644
--- a/src/hooks/AuthHooks.res
+++ b/src/hooks/AuthHooks.res
@@ -28,14 +28,13 @@ let getHeaders = (~uri, ~headers, ~xFeatureRoute, ()) => {
("accept", "application/json"),
]->Dict.fromArray
} else {
- if xFeatureRoute {
- headersForXFeature(~headers, ~uri)
- }
switch hyperSwitchToken {
| Some(token) => {
headers->Dict.set("authorization", `Bearer ${token}`)
headers->Dict.set("api-key", `hyperswitch`)
- headers->Dict.set("Content-Type", `application/json`)
+ if xFeatureRoute {
+ headersForXFeature(~headers, ~uri)
+ }
}
| None => ()
}
From 032b7a78f8fded92be45ea8fc731bdba963ed090 Mon Sep 17 00:00:00 2001
From: Jeeva Ramachandran
Date: Fri, 4 Oct 2024 13:08:29 +0530
Subject: [PATCH 15/18] chore: resolve conflict
---
src/entryPoints/FeatureFlagUtils.res | 8 --------
1 file changed, 8 deletions(-)
diff --git a/src/entryPoints/FeatureFlagUtils.res b/src/entryPoints/FeatureFlagUtils.res
index 17733186d..4b0cb2677 100644
--- a/src/entryPoints/FeatureFlagUtils.res
+++ b/src/entryPoints/FeatureFlagUtils.res
@@ -32,13 +32,9 @@ type featureFlag = {
pmAuthenticationProcessor: bool,
performanceMonitor: bool,
newAnalytics: bool,
-<<<<<<< HEAD
- xFeatureRoute: bool,
-=======
downTime: bool,
taxProcessor: bool,
transactionView: bool,
->>>>>>> fcca1025d61e2032df48051e97626d4572ab3476
}
let featureFlagType = (featureFlags: JSON.t) => {
@@ -78,13 +74,9 @@ let featureFlagType = (featureFlags: JSON.t) => {
pmAuthenticationProcessor: dict->getBool("pm_authentication_processor", false),
performanceMonitor: dict->getBool("performance_monitor", false),
newAnalytics: dict->getBool("new_analytics", false),
-<<<<<<< HEAD
- xFeatureRoute: dict->getBool("x_feature_route", false),
-=======
downTime: dict->getBool("down_time", false),
taxProcessor: dict->getBool("tax_processor", false),
transactionView: dict->getBool("transaction_view", false),
->>>>>>> fcca1025d61e2032df48051e97626d4572ab3476
}
typedFeatureFlag
}
From 0a053300d0f8a310d9f871acdb3b783aa52f5a06 Mon Sep 17 00:00:00 2001
From: Jeeva Ramachandran
Date: Fri, 4 Oct 2024 17:46:04 +0530
Subject: [PATCH 16/18] chore: update x feature route
---
config/config.toml | 5 +++--
src/hooks/AuthHooks.res | 3 +--
.../PaymentsLifeCycle/PaymentsLifeCycleUtils.res | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/config/config.toml b/config/config.toml
index 64f06e13b..6a23bd3d5 100644
--- a/config/config.toml
+++ b/config/config.toml
@@ -3,7 +3,7 @@ primary_color="#006DF9"
primary_hover_color="#005ED6"
sidebar_color="#242F48"
[default.endpoints]
-api_url="https://sandbox.hyperswitch.io"
+api_url="http://localhost:8080"
sdk_url=""
logo_url=""
favicon_url=""
@@ -44,7 +44,8 @@ custom_webhook_headers=false
compliance_certificate=false
pm_authentication_processor=true
performance_monitor=false
-new_analytics=false
+new_analytics=true
down_time=false
tax_processor=true
transaction_view=false
+x_feature_route=true
diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res
index 0262f982c..f2a6fffd9 100644
--- a/src/hooks/AuthHooks.res
+++ b/src/hooks/AuthHooks.res
@@ -3,7 +3,7 @@ let headersForXFeature = (~uri, ~headers) => {
if uri->String.includes("lottie-files") || uri->String.includes("config/merchant-access") {
headers->Dict.set("Content-Type", `application/json`)
} else {
- headers->Dict.set("x-feature", "hyperswitch-custom")
+ headers->Dict.set("x-feature", "router-custom")
}
}
@@ -52,7 +52,6 @@ let useApiFetcher = () => {
let {authStatus, setAuthStateToLogout} = React.useContext(AuthInfoProvider.authStatusContext)
let setReqProgress = Recoil.useSetRecoilState(ApiProgressHooks.pendingRequestCount)
- // let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
React.useCallback(
(
uri,
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycleUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycleUtils.res
index 610419c1a..1da581b6c 100644
--- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycleUtils.res
+++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycleUtils.res
@@ -39,7 +39,7 @@ let paymentsLifeCycleMapper = (
let disputed = data.disputed
let processedData = [
- ("Payments Initiated", "Success", totalPayment, "#E4EFFF"),
+ ("Payments Initiated", "Success", success, "#E4EFFF"),
("Payments Initiated", "Non-terminal state", customerAwaited, "#E4EFFF"),
("Success", "Dispute Raised", disputed, "#F7E0E0"),
("Success", "Refunds Issued", refunded, "#E4EFFF"),
From 263abe9327794fb2a54fa3d5ec3b5d84b8145aff Mon Sep 17 00:00:00 2001
From: Jeeva Ramachandran
Date: Fri, 4 Oct 2024 17:48:11 +0530
Subject: [PATCH 17/18] chore: update x feature route
---
config/config.toml | 2 +-
src/components/custom-icons/LottieFiles.res | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/config/config.toml b/config/config.toml
index 6a23bd3d5..60f722101 100644
--- a/config/config.toml
+++ b/config/config.toml
@@ -44,7 +44,7 @@ custom_webhook_headers=false
compliance_certificate=false
pm_authentication_processor=true
performance_monitor=false
-new_analytics=true
+new_analytics=false
down_time=false
tax_processor=true
transaction_view=false
diff --git a/src/components/custom-icons/LottieFiles.res b/src/components/custom-icons/LottieFiles.res
index 4626b2395..f833d2681 100644
--- a/src/components/custom-icons/LottieFiles.res
+++ b/src/components/custom-icons/LottieFiles.res
@@ -16,7 +16,6 @@ let useLottieJson = lottieFileName => {
let uriPrefix = LogicUtils.useUrlPrefix()
let showToast = ToastState.useShowToast()
let prefix = `${Window.Location.origin}${uriPrefix}`
- // let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
React.useEffect(() => {
switch lottieDict->Dict.get(lottieFileName) {
| Some(val) =>
From 808423335b65f55e022b6976f9fa737cb0e82a25 Mon Sep 17 00:00:00 2001
From: Jeeva Ramachandran
Date: Fri, 4 Oct 2024 17:55:09 +0530
Subject: [PATCH 18/18] chore: update x feature route
---
config/config.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/config.toml b/config/config.toml
index 60f722101..80696aa4f 100644
--- a/config/config.toml
+++ b/config/config.toml
@@ -48,4 +48,4 @@ new_analytics=false
down_time=false
tax_processor=true
transaction_view=false
-x_feature_route=true
+x_feature_route=false