Skip to content

Commit

Permalink
Merge branch 'main' of github.com:juspay/hyperswitch-control-center
Browse files Browse the repository at this point in the history
  • Loading branch information
JeevaRamu0104 committed Nov 30, 2023
2 parents 8498e71 + d5c65c7 commit 3c61ffd
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr-title-spell-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:

- name: Store PR title in a file
shell: bash
env:
TITLE: ${{ github.event.pull_request.title }}
env:
TITLE: ${{ github.event.pull_request.title }}
run: echo $TITLE > pr_title.txt

- name: Spell check
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release-new-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ name: Release a new hyperswitch version
# group: ${{ github.workflow }}-${{ github.ref }}
# cancel-in-progress: true


on:
pull_request_target:
types:
Expand Down
4 changes: 2 additions & 2 deletions src/entryPoints/hyperswitch/FeatureFlagUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type featureFlag = {
openSDK: bool,
homePage: bool,
switchMerchant: bool,
testLiveMode: bool,
testLiveMode: option<bool>,
auditTrail: bool,
systemMetrics: bool,
sampleData: bool,
Expand Down Expand Up @@ -38,7 +38,7 @@ let featureFlagType = (featureFlags: Js.Json.t) => {
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 Down
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 @@ -339,7 +339,7 @@ let make = (
~connector,
~bodyType,
~isPayoutFlow,
~isLiveMode={featureFlagDetails.testLiveMode},
~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)},
(),
)
setScreenState(_ => Loading)
Expand Down Expand Up @@ -392,7 +392,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: 8 additions & 3 deletions src/screens/HyperSwitch/Connectors/ConnectorList.res
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ module NewProcessorCards = {
->Recoil.useRecoilValueFromAtom
->LogicUtils.safeParse
->FeatureFlagUtils.featureFlagType
let connectorsAvailableForIntegration = 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 =>
configuredConnectors->Js.Array2.find(item => item === total)->Belt.Option.isNone
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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit) => {
}, [isMagicLinkEnabled])

React.useEffect1(() => {
if testLiveMode {
if testLiveMode->Belt.Option.getWithDefault(false) {
setMode(_ => LiveButtonMode)
} else {
setMode(_ => TestButtonMode)
Expand Down
17 changes: 10 additions & 7 deletions src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ module Header = {
@react.component
let make = (~authType, ~setAuthType, ~email) => {
let form = ReactFinalForm.useForm()
let {magicLink: isMagicLinkEnabled} =
let {magicLink: isMagicLinkEnabled, testLiveMode} =
HyperswitchAtom.featureFlagAtom
->Recoil.useRecoilValueFromAtom
->LogicUtils.safeParse
Expand Down Expand Up @@ -429,12 +429,15 @@ module Header = {
<h1 className="font-semibold text-xl md:text-2xl"> {cardHeaderText->React.string} </h1>
{switch authType {
| LoginWithPassword | LoginWithEmail =>
getHeaderLink(
~prefix="New to Hyperswitch?",
~authType=SignUP,
~path="/register",
~sufix="Sign up",
)
!(testLiveMode->Belt.Option.getWithDefault(false))
? getHeaderLink(
~prefix="New to Hyperswitch?",
~authType=SignUP,
~path="/register",
~sufix="Sign up",
)
: React.null

| SignUP =>
getHeaderLink(
~prefix="Already using Hyperswitch?",
Expand Down

0 comments on commit 3c61ffd

Please sign in to comment.