Skip to content

Commit

Permalink
Merge branch 'main' of github.com:juspay/hyperswitch-control-center i…
Browse files Browse the repository at this point in the history
…nto page-heading-addition
  • Loading branch information
Pritish Budhiraja committed Dec 1, 2023
2 parents cc9372a + 74e6908 commit ca6dca0
Show file tree
Hide file tree
Showing 22 changed files with 112 additions and 84 deletions.
4 changes: 2 additions & 2 deletions config/FeatureFlag.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"stripe_plus_paypal": false,
"woocommerce": false,
"open_sdk": false,
"home_page": false,
"switch_merchant": false,
"audit_trail": false,
"system_metrics": false,
Expand All @@ -22,5 +21,6 @@
"mixpanel": false,
"business_profile": false,
"generate_report": false,
"business_details": true
"business_details": true,
"forgot_password": false
}
12 changes: 6 additions & 6 deletions src/entryPoints/hyperswitch/FeatureFlagUtils.res
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
type featureFlag = {
default: bool,
productionAccess: bool,
testLiveToggle: bool,
magicLink: bool,
quickStart: bool,
stripePlusPayPal: bool,
wooCommerce: bool,
openSDK: bool,
homePage: bool,
switchMerchant: bool,
testLiveMode: bool,
testLiveMode: option<bool>,
auditTrail: bool,
systemMetrics: bool,
sampleData: bool,
Expand All @@ -23,23 +23,23 @@ type featureFlag = {
mixPanel: bool,
verifyConnector: bool,
businessDetails: bool,
default: bool,
forgetPassword: bool,
}

let featureFlagType = (featureFlags: Js.Json.t) => {
open LogicUtils
let dict = featureFlags->getDictFromJsonObject
let typedFeatureFlag: featureFlag = {
default: dict->getBool("default", true),
productionAccess: dict->getBool("production_access", false),
testLiveToggle: dict->getBool("test_live_toggle", false),
magicLink: dict->getBool("magic_link", false),
quickStart: dict->getBool("quick_start", false),
stripePlusPayPal: dict->getBool("stripe_plus_paypal", false),
wooCommerce: dict->getBool("woocommerce", false),
openSDK: dict->getBool("open_sdk", false),
homePage: dict->getBool("home_page", false),
switchMerchant: dict->getBool("switch_merchant", false),
testLiveMode: dict->getBool("test_live_mode", false),
testLiveMode: dict->getOptionBool("test_live_mode"),
auditTrail: dict->getBool("audit_trail", false),
systemMetrics: dict->getBool("system_metrics", false),
sampleData: dict->getBool("sample_data", false),
Expand All @@ -54,7 +54,7 @@ let featureFlagType = (featureFlags: Js.Json.t) => {
businessDetails: dict->getBool("business_details", false),
mixPanel: dict->getBool("mixpanel", false),
verifyConnector: dict->getBool("verify_connector", false),
default: dict->getBool("default", true),
forgetPassword: dict->getBool("forgot_password", false),
}
typedFeatureFlag
}
32 changes: 20 additions & 12 deletions src/entryPoints/hyperswitch/HyperSwitchApp.res
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ let make = () => {
let getEnumDetails = EnumVariantHook.useFetchEnumDetails()
let verificationDays = getFromMerchantDetails("verification")->LogicUtils.getIntFromString(-1)
let userRole = getFromUserDetails("user_role")
let modeText = featureFlagDetails.testLiveMode ? "Live Mode" : "Test Mode"
let modeText =
featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false) ? "Live Mode" : "Test Mode"
let titleComingSoonMessage = "Coming Soon!"
let subtitleComingSoonMessage = "We are currently working on this page."
let modeStyles = featureFlagDetails.testLiveMode
? "bg-hyperswitch_green_trans border-hyperswitch_green_trans text-hyperswitch_green"
: "bg-orange-600/80 border-orange-500 text-grey-700"
let modeStyles =
featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)
? "bg-hyperswitch_green_trans border-hyperswitch_green_trans text-hyperswitch_green"
: "bg-orange-600/80 border-orange-500 text-grey-700"

let merchantDetailsValue = HSwitchUtils.useMerchantDetailsValue()
let isReconEnabled =
Expand Down Expand Up @@ -121,17 +123,9 @@ let make = () => {
let _profileDetails = await fetchBusinessProfiles()
let _connectorList = await fetchConnectorListResponse()
let _merchantDetails = await fetchMerchantAccountDetails()

if featureFlagDetails.testLiveMode {
getAgreementEnum()->ignore
} else {
setDashboardPageState(_ => #HOME)
setScreenState(_ => PageLoaderWrapper.Success)
}
} catch {
| _ =>
setDashboardPageState(_ => #HOME)

setScreenState(_ => PageLoaderWrapper.Error(""))
}
}
Expand All @@ -141,6 +135,20 @@ let make = () => {
None
})

React.useEffect1(() => {
switch featureFlagDetails.testLiveMode {
| Some(val) =>
if val {
getAgreementEnum()->ignore
} else {
setDashboardPageState(_ => #HOME)
setScreenState(_ => PageLoaderWrapper.Success)
}
| None => ()
}
None
}, [featureFlagDetails.testLiveMode])

React.useEffect1(() => {
if featureFlagDetails.quickStart {
fetchInitialEnums()->ignore
Expand Down
7 changes: 4 additions & 3 deletions src/entryPoints/hyperswitch/HyperSwitchEntry.res
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ module HyperSwitchEntryComponent = {

let setPageName = pageTitle => {
let page = pageTitle->LogicUtils.snakeToTitle
let title = featureFlagDetails.testLiveMode
? `${page} - Dashboard`
: `${page} - Dashboard [Test]`
let title =
featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)
? `${page} - Dashboard`
: `${page} - Dashboard [Test]`
DOMUtils.document.title = title
GoogleAnalytics.send({hitType: "pageview", page})
hyperswitchMixPanel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ let make = (
~connector,
~bodyType,
~isPayoutFlow,
~isLiveMode={featureFlagDetails.testLiveMode},
~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)},
(),
)
setScreenState(_ => Loading)
Expand Down Expand Up @@ -396,7 +396,7 @@ let make = (
~connector,
~bodyType,
~isPayoutFlow,
~isLiveMode={featureFlagDetails.testLiveMode},
~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)},
(),
)->ignoreFields(connectorID, verifyConnectorIgnoreField)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ module RenderConnectorInputFields = {
~selectedConnector,
~dict=details,
~fieldName=formName,
~isLiveMode={featureFlagDetails.testLiveMode},
~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)},
)}
/>
</div>
Expand Down
11 changes: 6 additions & 5 deletions src/screens/HyperSwitch/Connectors/ConnectorList.res
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ module NewProcessorCards = {
->LogicUtils.safeParse
->FeatureFlagUtils.featureFlagType

let connectorsAvailableForIntegration = featureFlagDetails.testLiveMode
? ConnectorUtils.connectorListForLive
: isPayoutFlow
? ConnectorUtils.payoutConnectorList
: ConnectorUtils.connectorList
let connectorsAvailableForIntegration =
featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)
? ConnectorUtils.connectorListForLive
: isPayoutFlow
? ConnectorUtils.payoutConnectorList
: ConnectorUtils.connectorList

let unConfiguredConnectors =
connectorsAvailableForIntegration->Js.Array2.filter(total =>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let make = () => {
setInitialValues(_ => {
generateInitialValuesDict(
~selectedFRMInfo=frmInfo,
~isLiveMode=featureFlagDetails.testLiveMode,
~isLiveMode=featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false),
(),
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ let make = (
}

| None =>
generateInitialValuesDict(~selectedFRMInfo, ~isLiveMode={featureFlagDetails.testLiveMode}, ())
generateInitialValuesDict(
~selectedFRMInfo,
~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)},
(),
)
}
}, [retrivedValues])

Expand Down
3 changes: 2 additions & 1 deletion src/screens/HyperSwitch/HSwitchUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ module CardLoader = {

let checkStripePlusPayPal = (enumDetails: QuickStartTypes.responseType) => {
enumDetails.stripeConnected.processorID->Js.String2.length > 0 &&
enumDetails.paypalConnected.processorID->Js.String2.length > 0
enumDetails.paypalConnected.processorID->Js.String2.length > 0 &&
enumDetails.sPTestPayment
? true
: false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module ConfigureProcessor = {
~connector=connectorName,
~bodyType,
~isPayoutFlow=false,
~isLiveMode={featureFlagDetails.testLiveMode},
~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)},
(),
)
setInitialValues(_ => body)
Expand Down
17 changes: 11 additions & 6 deletions src/screens/HyperSwitch/Home/HomeUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,16 @@ module ControlCenter = {

let pageName = url.path->getPageNameFromUrl

let isLiveModeEnabledStyles = testLiveMode
? "flex flex-col md:flex-row gap-5 w-full"
: "flex flex-col gap-5 md:w-1/2 w-full"
let isLiveModeEnabledStyles =
testLiveMode->Belt.Option.getWithDefault(false)
? "flex flex-col md:flex-row gap-5 w-full"
: "flex flex-col gap-5 md:w-1/2 w-full"

<div className="flex flex-col gap-5 md:flex-row">
<div className=isLiveModeEnabledStyles>
<CardLayout width="w-full" customStyle={testLiveMode ? "" : "h-3/6"}>
<CardLayout
width="w-full"
customStyle={testLiveMode->Belt.Option.getWithDefault(false) ? "" : "h-3/6"}>
<CardHeader
heading="Integrate a connector"
subHeading="Give a headstart to the control centre by connecting with more than 20+ gateways, payment methods, and networks."
Expand Down Expand Up @@ -313,7 +316,9 @@ module ControlCenter = {
/>
</CardFooter>
</CardLayout>
<CardLayout width="w-full" customStyle={testLiveMode ? "" : "h-4/6"}>
<CardLayout
width="w-full"
customStyle={testLiveMode->Belt.Option.getWithDefault(false) ? "" : "h-4/6"}>
<CardHeader
heading="Credentials and Keys"
subHeading="Your secret credentials to start integrating hyperswitch."
Expand Down Expand Up @@ -342,7 +347,7 @@ module ControlCenter = {
</CardFooter>
</CardLayout>
</div>
<UIUtils.RenderIf condition={!testLiveMode}>
<UIUtils.RenderIf condition={!(testLiveMode->Belt.Option.getWithDefault(false))}>
<CheckoutCard />
</UIUtils.RenderIf>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/screens/HyperSwitch/Order/OrderUIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ module NoData = {
->FeatureFlagUtils.featureFlagType
<HelperComponents.BluredTableComponent
infoText={isConfigureConnector
? testLiveMode
? testLiveMode->Belt.Option.getWithDefault(false)
? "There are no payments as of now."
: "There are no payments as of now. Try making a test payment and visualise the checkout experience."
: "Connect to a connector like Stripe, Adyen or Hyperswitch provided test connector to make your first payment."}
buttonText={isConfigureConnector ? "Make a payment" : "Connect a connector"}
moduleName=""
paymentModal
setPaymentModal
showRedirectCTA={!testLiveMode}
showRedirectCTA={!(testLiveMode->Belt.Option.getWithDefault(false))}
mixPanelEventName={isConfigureConnector
? "paymentops_makeapayment"
: "payemntops_connectaconnector"}
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 @@ -2,4 +2,5 @@ type paymentType = {
amount: int,
currency: string,
profile_id: string,
customer_id: string,
}
2 changes: 2 additions & 0 deletions src/screens/HyperSwitch/SDKPayment/SDKPaymentUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ let initialValueForForm: string => SDKPaymentTypes.paymentType = profileId => {
amount: 100,
currency: "United States-USD",
profile_id: profileId,
customer_id: "hyperswitch_sdk_demo_id",
}

let getTypedValueForPayment: Js.Json.t => SDKPaymentTypes.paymentType = values => {
Expand All @@ -11,6 +12,7 @@ let getTypedValueForPayment: Js.Json.t => SDKPaymentTypes.paymentType = values =
amount: dictOfValues->getInt("amount", 100),
currency: dictOfValues->getString("currency", "United States-USD"),
profile_id: dictOfValues->getString("profile_id", ""),
customer_id: dictOfValues->getString("customer_id", ""),
}
}

Expand Down
1 change: 1 addition & 0 deletions src/screens/HyperSwitch/SDKPayment/TestPayment.res
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ let make = (
->Js.Json.number,
),
("profile_id", initialValues.profile_id->Js.Json.string),
("customer_id", "hyperswitch_sdk_demo_id"->Js.Json.string),
])->Js.Json.object_
let response = await updateDetails(url, body, Post)
let clientSecret = response->getDictFromJsonObject->getOptionString("client_secret")
Expand Down
15 changes: 5 additions & 10 deletions src/screens/HyperSwitch/SDKPayment/WebSDK.res
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,11 @@ module CheckoutForm = {
->ignore
}
React.useEffect1(() => {
let id = Js.String2.split(clientSecret, "_secret_")[0]->Belt.Option.getWithDefault("")
switch Some(id) {
| None | Some("") => ()
| Some(id) =>
hyper.retrievePaymentIntent(id)
->then(_ => {
resolve()
})
->ignore
}
hyper.retrievePaymentIntent(clientSecret)
->then(_ => {
resolve()
})
->ignore

None
}, [hyper])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => {
~values,
~connector=connectorName,
~bodyType,
~isLiveMode={featureFlagDetails.testLiveMode},
~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)},
(),
)

Expand Down Expand Up @@ -238,7 +238,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => {
~connector={connectorName},
~bodyType,
~isPayoutFlow=false,
~isLiveMode={featureFlagDetails.testLiveMode},
~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)},
(),
)->ignoreFields(connectorID, verifyConnectorIgnoreField)

Expand Down
Loading

0 comments on commit ca6dca0

Please sign in to comment.