diff --git a/.githooks/commit-msg b/.githooks/commit-msg index cfc7fde59..e4b5d138e 100755 --- a/.githooks/commit-msg +++ b/.githooks/commit-msg @@ -1,20 +1,47 @@ #!/bin/sh -echo "~~~~**** Commit hook started ****~~~~" +echo "*****~~~~~ Commit hook initiated ~~~~~~*****" commit_msg_file=$1 commit_msg=$(cat "$commit_msg_file") - # For formatting your code -npx prettier --write . +echo +echo "*****~~~~~ Formatting - Check for unformatted files ~~~~~~*****" + +# Check for unformatted JavaScript, TypeScript, and JSON files using Prettier +unformatted_js_files=$(git ls-files | grep '\.js\|\.jsx\|\.ts\|\.tsx\|\.json' | xargs npx prettier --list-different) + +# If there are unformatted JavaScript, TypeScript, or JSON files, print an error message and exit with a non-zero status code +if [ -n "$unformatted_js_files" ]; then + echo "Error: Unformatted JavaScript, YML or JSON files found. Please run 'npx prettier --write .' for formatting whole repository or 'npx prettier --write' on the following files:" + echo "$unformatted_js_files" + exit 1 +fi + +# Check for unformatted ReScript files npm run re:format +echo +echo "*****~~~~~ All files are formatted. ~~~~~~*****" +echo + +# JS Code Check +echo "*****~~~~~ Checking ReScript Code ~~~~~~*****" +if (! npm run re:build) +then + echo "*****~~~~~ ReScript Code Compilation Failed! ~~~~~*****" + exit 1 +fi + +echo +echo "*****~~~~~ Commit message validation! ~~~~~*****" +echo # Define your commit message convention (e.g., starts with "feat:", "fix:", etc.) commit_regex="^(Merge branch|(feat|fix|chore|refactor|docs|test|style|enhancement):).+" -if git log -1 --show-signature &> /dev/null; then +if git log --show-signature -n 1 | grep -q 'gpg:'; then if ! echo "$commit_msg" | grep -Ei "$commit_regex" ; then echo "Aborting commit. Your commit message does not follow the conventional format." echo "The commit message should begin with one of the following keywords followed by a colon: 'feat', 'fix', 'chore', 'refactor', 'docs', 'test' or 'style'. For example, it should be formatted like this: 'feat: - '" @@ -28,5 +55,5 @@ else fi # If the commit message matches the convention, the script exits successfully. -echo "~~~~**** Commit hook completed ****~~~~" +echo "*****~~~~~ Commit hook completed ~~~~~~*****" exit 0 diff --git a/.gitignore b/.gitignore index c1ebc1891..3fdff3ada 100644 --- a/.gitignore +++ b/.gitignore @@ -18,5 +18,4 @@ env-config.js yarn.lock #package-lock.json user_data.sh -*.pem -.bsb.lock +*.pem \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a4247f0cb..d0436e28f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,18 +3,24 @@ All notable changes to this project will be documented in this file. See [conven - - - -## 1.0.4 (2023-12-04) +## 1.1.0 (2023-12-05) + +### Features + +- Business profile UI changes ([#51](https://github.com/juspay/hyperswitch-control-center/pull/51)) ([`7d2a443`](https://github.com/juspay/hyperswitch-control-center/commit/7d2a4430980539977a8e8ddfd9d959547549258a)) ### Bug Fixes -- Dead code removal ([#52](https://github.com/juspay/hyperswitch-control-center/pull/52)) ([`eebee65`](https://github.com/juspay/hyperswitch-control-center/commit/eebee659a8326aa32ebcbe2d06c21e8487bea377)) -- Remove CHANGELOG.md ([#53](https://github.com/juspay/hyperswitch-control-center/pull/53)) ([`6978bf6`](https://github.com/juspay/hyperswitch-control-center/commit/6978bf6814fb856c67a0fe409638982239c1af80)) +- Warning icon added ([#59](https://github.com/juspay/hyperswitch-control-center/pull/59)) ([`4fbaee4`](https://github.com/juspay/hyperswitch-control-center/commit/4fbaee4bf0b1b65b08513bd9208e49f154911ae0)) +- Optional test live mode removal & typo fix ([#63](https://github.com/juspay/hyperswitch-control-center/pull/63)) ([`9466057`](https://github.com/juspay/hyperswitch-control-center/commit/94660575566729f1b6a8013e9d09e1a4bc8cff20)) ### Miscellaneous Tasks -- Remove dead code ([#50](https://github.com/juspay/hyperswitch-control-center/pull/50)) ([`0133ff1`](https://github.com/juspay/hyperswitch-control-center/commit/0133ff13a7e915c4c796bd98fbaf92400690531a)) +- Signed commit added. ([#62](https://github.com/juspay/hyperswitch-control-center/pull/62)) ([`4f69afe`](https://github.com/juspay/hyperswitch-control-center/commit/4f69afe1946bd431fb6e8a31ee621358ff28ad12)) +- Cleanup Configs ([#48](https://github.com/juspay/hyperswitch-control-center/pull/48)) ([`5bfae97`](https://github.com/juspay/hyperswitch-control-center/commit/5bfae972ac4cd2f367d26317c203b2c9d425535d)) +- Dead code removal ([#55](https://github.com/juspay/hyperswitch-control-center/pull/55)) ([`b220415`](https://github.com/juspay/hyperswitch-control-center/commit/b220415bc390a5129e82e1b59dc6115a35cb6f84)) -**Full Changelog:** [`v1.0.3...v1.0.4`](https://github.com/juspay/hyperswitch-control-center/compare/v1.0.3...v1.0.4) +**Full Changelog:** [`v1.0.5...v1.1.0`](https://github.com/juspay/hyperswitch-control-center/compare/v1.0.5...v1.1.0) - - - diff --git a/src/components/DynamicTable.res b/src/components/DynamicTable.res index f81f988c3..3437daf71 100644 --- a/src/components/DynamicTable.res +++ b/src/components/DynamicTable.res @@ -56,7 +56,7 @@ let make = ( ~mandatoryRemoteKeys=[], ~isSearchKeyArray=false, ~forcePreventConcatData=false, - ~collapseTabelRow=false, + ~collapseTableRow=false, ~showRefreshFilter=true, ~showRemoteOptions=false, ~filterButtonStyle="", @@ -548,7 +548,7 @@ let make = ( ?bottomActions ?defaultSort tableLocalFilter - collapseTabelRow + collapseTableRow getRowDetails ?onMouseEnter ?onMouseLeave @@ -590,7 +590,7 @@ let make = ( ?renderCard ?defaultSort tableLocalFilter - collapseTabelRow + collapseTableRow ?frozenUpto ?heightHeadingClass getRowDetails diff --git a/src/components/DynamicTable.resi b/src/components/DynamicTable.resi index 74296ea60..c300f88e5 100644 --- a/src/components/DynamicTable.resi +++ b/src/components/DynamicTable.resi @@ -42,7 +42,7 @@ let make: ( ~mandatoryRemoteKeys: array=?, ~isSearchKeyArray: bool=?, ~forcePreventConcatData: bool=?, - ~collapseTabelRow: bool=?, + ~collapseTableRow: bool=?, ~showRefreshFilter: bool=?, ~showRemoteOptions: bool=?, ~filterButtonStyle: string=?, diff --git a/src/components/LoadedTable.res b/src/components/LoadedTable.res index 06ba7fd10..85436c29b 100644 --- a/src/components/LoadedTable.res +++ b/src/components/LoadedTable.res @@ -185,7 +185,7 @@ let make = ( ~tableheadingClass="", ~tableBorderClass="", ~tableDataBorderClass="", - ~collapseTabelRow=false, + ~collapseTableRow=false, ~getRowDetails=?, ~onMouseEnter=?, ~onMouseLeave=?, @@ -798,7 +798,7 @@ let make = ( tableBorderClass tableDataBorderClass enableEqualWidthCol - collapseTabelRow + collapseTableRow ?getRowDetails ?onExpandClickData actualData diff --git a/src/components/LoadedTable.resi b/src/components/LoadedTable.resi index 2436b54fc..f43376ddd 100644 --- a/src/components/LoadedTable.resi +++ b/src/components/LoadedTable.resi @@ -66,7 +66,7 @@ let make: ( ~tableheadingClass: string=?, ~tableBorderClass: string=?, ~tableDataBorderClass: string=?, - ~collapseTabelRow: bool=?, + ~collapseTableRow: bool=?, ~getRowDetails: Js.Nullable.t<'t> => React.element=?, ~onMouseEnter: 't => unit=?, ~onMouseLeave: 't => unit=?, diff --git a/src/components/LoadedTableWithCustomColumns.res b/src/components/LoadedTableWithCustomColumns.res index 0c39d55d4..29118421e 100644 --- a/src/components/LoadedTableWithCustomColumns.res +++ b/src/components/LoadedTableWithCustomColumns.res @@ -36,7 +36,7 @@ let make = ( ~tableheadingClass="", ~tableBorderClass="", ~tableDataBorderClass="", - ~collapseTabelRow=false, + ~collapseTableRow=false, ~getRowDetails=_ => React.null, ~onMouseEnter=?, ~onMouseLeave=?, @@ -132,7 +132,7 @@ let make = ( ?renderCard ?defaultSort tableLocalFilter - collapseTabelRow + collapseTableRow ?frozenUpto ?heightHeadingClass getRowDetails diff --git a/src/components/ReactWindowTable.res b/src/components/ReactWindowTable.res index 41973e3fb..1df7d96fc 100644 --- a/src/components/ReactWindowTable.res +++ b/src/components/ReactWindowTable.res @@ -62,7 +62,7 @@ module NewCell = { ~removeVerticalLines, ~highlightEnabledFieldsArray, ~tableDataBorderClass="", - ~collapseTabelRow=false, + ~collapseTableRow=false, ~expandedRow: _ => React.element, ~onMouseEnter, ~onMouseLeave, @@ -171,9 +171,9 @@ module NewCell = { className={`${cellWidth} ${overflowStyle} h-auto align-top ${borderClass} ${highlightCell ? "hover:font-bold" : ""} ${tableDataBorderClass} - ${collapseTabelRow ? cursorI : ""}`} + ${collapseTableRow ? cursorI : ""}`} onClick={_ => { - if collapseTabelRow && cellIndex == 0 { + if collapseTableRow && cellIndex == 0 { handleExpand(rowIndex, true) if !isCurrentRowExpanded { setExpandedIndexArr(prev => { @@ -187,7 +187,7 @@ module NewCell = { } }}>
- {if collapseTabelRow { + {if collapseTableRow {
{if cellIndex === 0 { @@ -228,7 +228,7 @@ module ReactWindowTableComponent = { ~tableheadingClass="", ~tableBorderClass="", ~tableDataBorderClass="", - ~collapseTabelRow=false, + ~collapseTableRow=false, ~getRowDetails=?, ~getIndex=?, ~rowItemHeight=100, @@ -480,7 +480,7 @@ module ReactWindowTableComponent = { removeVerticalLines highlightEnabledFieldsArray tableDataBorderClass - collapseTabelRow + collapseTableRow expandedRow={_ => getRowDetails(rowIndex)} onMouseEnter onMouseLeave @@ -654,7 +654,7 @@ let make = ( ~tableheadingClass="", ~tableBorderClass="", ~tableDataBorderClass="", - ~collapseTabelRow=false, + ~collapseTableRow=false, ~getRowDetails=?, ~getIndex=?, ~rowItemHeight=100, @@ -1156,7 +1156,7 @@ let make = ( tableheadingClass tableBorderClass tableDataBorderClass - collapseTabelRow + collapseTableRow ?getRowDetails ?getIndex rowItemHeight diff --git a/src/components/Table.res b/src/components/Table.res index d31302620..b5bf98613 100644 --- a/src/components/Table.res +++ b/src/components/Table.res @@ -63,7 +63,7 @@ module TableRow = { ~evenVertivalLines, ~highlightEnabledFieldsArray, ~tableDataBorderClass="", - ~collapseTabelRow=false, + ~collapseTableRow=false, ~expandedRow: _ => React.element, ~onMouseEnter, ~onMouseLeave, @@ -178,7 +178,7 @@ module TableRow = { } else { `${borderTop} border-r ${borderColor}` } - let cursorI = cellIndex == 0 && collapseTabelRow ? "cursor-pointer" : "" + let cursorI = cellIndex == 0 && collapseTableRow ? "cursor-pointer" : "" let isLast = cellIndex === colsLen - 1 let lastColProp = isLast && fixLastCol ? "border-l h-full !py-0 flex flex-col justify-center" : "" @@ -203,13 +203,13 @@ module TableRow = { className={`${tableRowBorderClass} ${customColorCell}`} style={ReactDOMStyle.make(~width=fixedWidthClass, ())} onClick={_ => { - if collapseTabelRow && cellIndex == 0 { + if collapseTableRow && cellIndex == 0 { setIsCurrentRowExpanded(prev => !prev) setExpandedData(_ => expandedRow()) } }}>
- {if collapseTabelRow { + {if collapseTableRow {
{if cellIndex === 0 { @@ -622,7 +622,7 @@ let make = ( ~tableheadingClass="", ~tableBorderClass="", ~tableDataBorderClass="", - ~collapseTabelRow=false, + ~collapseTableRow=false, ~getRowDetails=?, ~actualData=?, ~onExpandClickData as _=?, @@ -725,7 +725,7 @@ let make = ( evenVertivalLines highlightEnabledFieldsArray tableDataBorderClass - collapseTabelRow + collapseTableRow expandedRow={_ => getRowDetails(offset + rowIndex)} onMouseEnter onMouseLeave diff --git a/src/components/Table.resi b/src/components/Table.resi index 9db95af34..ea3ffbf8c 100644 --- a/src/components/Table.resi +++ b/src/components/Table.resi @@ -147,7 +147,7 @@ module TableRow: { ~evenVertivalLines: bool, ~highlightEnabledFieldsArray: Js.Array2.t, ~tableDataBorderClass: string=?, - ~collapseTabelRow: bool=?, + ~collapseTableRow: bool=?, ~expandedRow: unit => React.element, ~onMouseEnter: option unit>, ~onMouseLeave: option unit>, @@ -263,7 +263,7 @@ let make: ( ~tableheadingClass: string=?, ~tableBorderClass: string=?, ~tableDataBorderClass: string=?, - ~collapseTabelRow: bool=?, + ~collapseTableRow: bool=?, ~getRowDetails: Js.Nullable.t<'b> => React.element=?, ~actualData: Js.Array2.t>=?, ~onExpandClickData: 'onExpandClickData=?, diff --git a/src/entryPoints/hyperswitch/FeatureFlagUtils.res b/src/entryPoints/hyperswitch/FeatureFlagUtils.res index 30c58f237..fa322ff39 100644 --- a/src/entryPoints/hyperswitch/FeatureFlagUtils.res +++ b/src/entryPoints/hyperswitch/FeatureFlagUtils.res @@ -6,7 +6,7 @@ type featureFlag = { quickStart: bool, openSDK: bool, switchMerchant: bool, - testLiveMode: option, + testLiveMode: bool, auditTrail: bool, systemMetrics: bool, sampleData: bool, @@ -34,7 +34,7 @@ let featureFlagType = (featureFlags: Js.Json.t) => { quickStart: dict->getBool("quick_start", false), openSDK: dict->getBool("open_sdk", false), switchMerchant: dict->getBool("switch_merchant", false), - testLiveMode: dict->getOptionBool("test_live_mode"), + testLiveMode: dict->getBool("test_live_mode", false), auditTrail: dict->getBool("audit_trail", false), systemMetrics: dict->getBool("system_metrics", false), sampleData: dict->getBool("sample_data", false), diff --git a/src/entryPoints/hyperswitch/HyperSwitchApp.res b/src/entryPoints/hyperswitch/HyperSwitchApp.res index ba84d8950..a23eeb93e 100644 --- a/src/entryPoints/hyperswitch/HyperSwitchApp.res +++ b/src/entryPoints/hyperswitch/HyperSwitchApp.res @@ -50,14 +50,12 @@ let make = () => { let getEnumDetails = EnumVariantHook.useFetchEnumDetails() let verificationDays = getFromMerchantDetails("verification")->LogicUtils.getIntFromString(-1) let userRole = getFromUserDetails("user_role") - let modeText = - featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false) ? "Live Mode" : "Test Mode" + let modeText = featureFlagDetails.testLiveMode ? "Live Mode" : "Test Mode" let titleComingSoonMessage = "Coming Soon!" let subtitleComingSoonMessage = "We are currently working on this page." - 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 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 merchantDetailsValue = HSwitchUtils.useMerchantDetailsValue() let isReconEnabled = @@ -93,7 +91,6 @@ let make = () => { } else { setDashboardPageState(_ => #AGREEMENT_SIGNATURE) } - setScreenState(_ => PageLoaderWrapper.Success) } catch { | _ => setDashboardPageState(_ => #HOME) @@ -123,6 +120,18 @@ let make = () => { let _profileDetails = await fetchBusinessProfiles() let _connectorList = await fetchConnectorListResponse() let _merchantDetails = await fetchMerchantAccountDetails() + + if featureFlagDetails.quickStart { + let _featureFlag = await fetchInitialEnums() + } + + if featureFlagDetails.testLiveMode { + getAgreementEnum()->ignore + } else { + setDashboardPageState(_ => #HOME) + } + + setScreenState(_ => PageLoaderWrapper.Success) } catch { | _ => setDashboardPageState(_ => #HOME) @@ -135,27 +144,6 @@ 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 - } - None - }, [featureFlagDetails.quickStart]) - let setPageState = (pageState: ProviderTypes.dashboardPageStateTypes) => { setDashboardPageState(_ => pageState) React.null @@ -192,16 +180,16 @@ let make = () => { } } -
- {switch dashboardPageState { - | #POST_LOGIN_QUES_NOT_DONE => - | #AUTO_CONNECTOR_INTEGRATION => - | #INTEGRATION_DOC => - | #AGREEMENT_SIGNATURE => - | #PROD_ONBOARDING => - | #QUICK_START => - | #HOME => - + +
+ {switch dashboardPageState { + | #POST_LOGIN_QUES_NOT_DONE => + | #AUTO_CONNECTOR_INTEGRATION => + | #INTEGRATION_DOC => + | #AGREEMENT_SIGNATURE => + | #PROD_ONBOARDING => + | #QUICK_START => + | #HOME =>
@@ -334,7 +322,7 @@ let make = () => { } + renderList={() => } renderShow={profileId => } /> @@ -385,13 +373,13 @@ let make = () => {
- - | #WOOCOMMERCE_FLOW => - | #DEFAULT => -
- -
- | #STRIPE_PLUS_PAYPAL => - }} -
+ | #WOOCOMMERCE_FLOW => + | #DEFAULT => +
+ +
+ | #STRIPE_PLUS_PAYPAL => + }} +
+
} diff --git a/src/entryPoints/hyperswitch/HyperSwitchEntry.res b/src/entryPoints/hyperswitch/HyperSwitchEntry.res index 08f76fcd6..c8a4b29cc 100644 --- a/src/entryPoints/hyperswitch/HyperSwitchEntry.res +++ b/src/entryPoints/hyperswitch/HyperSwitchEntry.res @@ -9,6 +9,7 @@ module HyperSwitchEntryComponent = { let url = RescriptReactRouter.useUrl() let (_zone, setZone) = React.useContext(UserTimeZoneProvider.userTimeContext) let setFeatureFlag = HyperswitchAtom.featureFlagAtom->Recoil.useSetRecoilState + let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading) let featureFlagDetails = HyperswitchAtom.featureFlagAtom ->Recoil.useRecoilValueFromAtom @@ -42,10 +43,9 @@ module HyperSwitchEntryComponent = { let setPageName = pageTitle => { let page = pageTitle->LogicUtils.snakeToTitle - let title = - featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false) - ? `${page} - Dashboard` - : `${page} - Dashboard [Test]` + let title = featureFlagDetails.testLiveMode + ? `${page} - Dashboard` + : `${page} - Dashboard [Test]` DOMUtils.document.title = title GoogleAnalytics.send({hitType: "pageview", page}) hyperswitchMixPanel( @@ -74,8 +74,11 @@ module HyperSwitchEntryComponent = { let stringifiedResponse = (await postDetails(url, Js.Dict.empty()->Js.Json.object_, Post))->Js.Json.stringify setFeatureFlag(._ => stringifiedResponse) + setScreenState(_ => PageLoaderWrapper.Success) } catch { - | _ => () + | Js.Exn.Error(e) => + let err = Js.Exn.message(e)->Belt.Option.getWithDefault("Something went wrong!") + setScreenState(_ => PageLoaderWrapper.Error(err)) } } @@ -84,13 +87,15 @@ module HyperSwitchEntryComponent = { None }) -
- - - - - -
+ +
+ + + + + +
+
} } diff --git a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res index 89bb12e5d..95b1456ce 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res @@ -343,7 +343,7 @@ let make = ( ~connector, ~bodyType, ~isPayoutFlow, - ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, + ~isLiveMode={featureFlagDetails.testLiveMode}, (), ) setScreenState(_ => Loading) @@ -396,7 +396,7 @@ let make = ( ~connector, ~bodyType, ~isPayoutFlow, - ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, + ~isLiveMode={featureFlagDetails.testLiveMode}, (), )->ignoreFields(connectorID, verifyConnectorIgnoreField) diff --git a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetailsHelper.res b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetailsHelper.res index 366abf74f..050a1f127 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetailsHelper.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetailsHelper.res @@ -132,7 +132,7 @@ module RenderConnectorInputFields = { ~selectedConnector, ~dict=details, ~fieldName=formName, - ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, + ~isLiveMode={featureFlagDetails.testLiveMode}, )} />
diff --git a/src/screens/HyperSwitch/Connectors/ConnectorList.res b/src/screens/HyperSwitch/Connectors/ConnectorList.res index 65aabb996..9abaa340a 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorList.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorList.res @@ -11,12 +11,11 @@ module NewProcessorCards = { ->LogicUtils.safeParse ->FeatureFlagUtils.featureFlagType - let connectorsAvailableForIntegration = - featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false) - ? ConnectorUtils.connectorListForLive - : isPayoutFlow - ? ConnectorUtils.payoutConnectorList - : ConnectorUtils.connectorList + let connectorsAvailableForIntegration = featureFlagDetails.testLiveMode + ? ConnectorUtils.connectorListForLive + : isPayoutFlow + ? ConnectorUtils.payoutConnectorList + : ConnectorUtils.connectorList let unConfiguredConnectors = connectorsAvailableForIntegration->Js.Array2.filter(total => @@ -257,7 +256,7 @@ let make = (~isPayoutFlow=false) => { setOffset entity={ConnectorTableUtils.connectorEntity(`${entityPrefix}connectors`)} currrentFetchCount={filteredConnectorData->Js.Array2.length} - collapseTabelRow=false + collapseTableRow=false /> diff --git a/src/screens/HyperSwitch/Developer/DeveloperUtils.res b/src/screens/HyperSwitch/Developer/APIKeys/DeveloperUtils.res similarity index 100% rename from src/screens/HyperSwitch/Developer/DeveloperUtils.res rename to src/screens/HyperSwitch/Developer/APIKeys/DeveloperUtils.res diff --git a/src/screens/HyperSwitch/Developer/KeyManagement.res b/src/screens/HyperSwitch/Developer/APIKeys/KeyManagement.res similarity index 100% rename from src/screens/HyperSwitch/Developer/KeyManagement.res rename to src/screens/HyperSwitch/Developer/APIKeys/KeyManagement.res diff --git a/src/screens/HyperSwitch/Developer/PublishableAndHashKeySection.res b/src/screens/HyperSwitch/Developer/APIKeys/PublishableAndHashKeySection.res similarity index 100% rename from src/screens/HyperSwitch/Developer/PublishableAndHashKeySection.res rename to src/screens/HyperSwitch/Developer/APIKeys/PublishableAndHashKeySection.res diff --git a/src/screens/HyperSwitch/Developer/Webhooks/WebhookList.res b/src/screens/HyperSwitch/Developer/Webhooks/WebhookList.res new file mode 100644 index 000000000..b35aff3cb --- /dev/null +++ b/src/screens/HyperSwitch/Developer/Webhooks/WebhookList.res @@ -0,0 +1,38 @@ +@react.component +let make = ( + ~isFromSettings=true, + ~showModalFromOtherScreen=false, + ~setShowModalFromOtherScreen=_bool => (), +) => { + open WebhookListEntity + let (offset, setOffset) = React.useState(_ => 0) + + let businessProfileValues = + HyperswitchAtom.businessProfilesAtom + ->Recoil.useRecoilValueFromAtom + ->HSwitchMerchantAccountUtils.getArrayOfBusinessProfile + + +
+
+ + Js.Array2.map(Js.Nullable.return)} + totalResults={businessProfileValues->Js.Array2.length} + offset + setOffset + currrentFetchCount={businessProfileValues->Js.Array2.length} + /> +
+
+
+} diff --git a/src/screens/HyperSwitch/Developer/Webhooks/WebhookListEntity.res b/src/screens/HyperSwitch/Developer/Webhooks/WebhookListEntity.res new file mode 100644 index 000000000..d45d06b64 --- /dev/null +++ b/src/screens/HyperSwitch/Developer/Webhooks/WebhookListEntity.res @@ -0,0 +1,63 @@ +open HSwitchSettingTypes +open BusinessMappingUtils + +type columns = + | ProfileName + | ReturnUrl + | WebhookUrl + +let visibleColumns = [WebhookUrl, ReturnUrl, ProfileName] + +let defaultColumns = [ProfileName, ReturnUrl, WebhookUrl] + +let allColumns = [ProfileName, ReturnUrl, WebhookUrl] + +let getHeading = colType => { + switch colType { + | ProfileName => + Table.makeHeaderInfo(~key="profile_name", ~title="Profile Name", ~showSort=true, ()) + | ReturnUrl => Table.makeHeaderInfo(~key="return_url", ~title="Return URL", ~showSort=true, ()) + | WebhookUrl => Table.makeHeaderInfo(~key="webhook_url", ~title="Webhook URL", ~showSort=true, ()) + } +} + +let getCell = (item: profileEntity, colType): Table.cell => { + switch colType { + | ProfileName => Text(item.profile_name) + | ReturnUrl => Text(item.return_url->Belt.Option.getWithDefault("")) + | WebhookUrl => Text(item.webhook_details.webhook_url->Belt.Option.getWithDefault("")) + } +} + +let itemToObjMapper = dict => { + open LogicUtils + open HSwitchMerchantAccountUtils + { + profile_id: getString(dict, "profile_id", ""), + profile_name: getString(dict, ProfileName->getStringFromVariant, ""), + merchant_id: getString(dict, "merchant_id", ""), + return_url: getOptionString(dict, "return_url"), + payment_response_hash_key: getOptionString(dict, "payment_response_hash_key"), + webhook_details: dict + ->getObj("webhook_details", Js.Dict.empty()) + ->constructWebhookDetailsObject, + } +} + +let getItems: Js.Json.t => array = json => { + LogicUtils.getArrayDataFromJson(json, itemToObjMapper) +} + +let webhookProfileTableEntity = EntityType.makeEntity( + ~uri="", + ~getObjects=getItems, + ~defaultColumns, + ~allColumns, + ~getHeading, + ~dataKey="", + ~getCell, + ~getShowLink={ + profile => `/webhooks/${profile.profile_id}` + }, + (), +) diff --git a/src/screens/HyperSwitch/Developer/Webhooks.res b/src/screens/HyperSwitch/Developer/Webhooks/Webhooks.res similarity index 78% rename from src/screens/HyperSwitch/Developer/Webhooks.res rename to src/screens/HyperSwitch/Developer/Webhooks/Webhooks.res index 8859c8995..e0a5a319c 100644 --- a/src/screens/HyperSwitch/Developer/Webhooks.res +++ b/src/screens/HyperSwitch/Developer/Webhooks/Webhooks.res @@ -1,3 +1,31 @@ +module InfoViewForWebhooks = { + @react.component + let make = (~heading, ~subHeading, ~isCopy=false) => { + let showToast = ToastState.useShowToast() + let onCopyClick = ev => { + ev->ReactEvent.Mouse.stopPropagation + Clipboard.writeText(subHeading) + showToast(~message="Copied to Clipboard!", ~toastType=ToastSuccess, ()) + } + +
+

{heading->React.string}

+
+

{subHeading->React.string}

+ + { + onCopyClick(ev) + }} + /> + +
+
+ } +} + @react.component let make = (~webhookOnly=false, ~showFormOnly=false, ~profileId="") => { open DeveloperUtils @@ -65,7 +93,7 @@ let make = (~webhookOnly=false, ~showFormOnly=false, ~profileId="") => { : "border border-jp-gray-500 rounded-md dark:border-jp-gray-960"} ${bgClass} `}> parseBussinessProfileJson->Js.Json.object_} + initialValues={businessProfileDetails->parseBussinessProfileJson->Js.Json.object_} subscription=ReactFinalForm.subscribeToValues validate={values => { open HSwitchSettingTypes @@ -87,6 +115,26 @@ let make = (~webhookOnly=false, ~showFormOnly=false, ~profileId="") => { className={`${showFormOnly ? "" : "px-2 py-4"} flex flex-col gap-7 overflow-hidden`}> +
+ + +
+
+ + Belt.Option.getWithDefault( + "NA", + )} + isCopy=true + /> +
{[webhookUrl, returnUrl] ->Js.Array2.filter(urlField => urlField.label === "Webhook URL" || !webhookOnly) @@ -112,6 +160,7 @@ let make = (~webhookOnly=false, ~showFormOnly=false, ~profileId="") => { />
+ }} /> diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res b/src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res index 7919ffbeb..f3594d1c7 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMConfigure.res @@ -32,7 +32,7 @@ let make = () => { setInitialValues(_ => { generateInitialValuesDict( ~selectedFRMInfo=frmInfo, - ~isLiveMode=featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false), + ~isLiveMode=featureFlagDetails.testLiveMode, (), ) }) diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res b/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res index b38dbca63..ca20884e5 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res @@ -228,11 +228,7 @@ let make = ( } | None => - generateInitialValuesDict( - ~selectedFRMInfo, - ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, - (), - ) + generateInitialValuesDict(~selectedFRMInfo, ~isLiveMode={featureFlagDetails.testLiveMode}, ()) } }, [retrivedValues]) diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMSelect.res b/src/screens/HyperSwitch/FraudAndRisk/FRMSelect.res index 82c783905..ec508b529 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMSelect.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMSelect.res @@ -199,7 +199,7 @@ let make = () => { setOffset entity={FRMTableUtils.connectorEntity("fraud-risk-management")} currrentFetchCount={filteredFRMData->Js.Array2.length} - collapseTabelRow=false + collapseTableRow=false /> diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res index 898e63aef..621364994 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res @@ -91,7 +91,7 @@ module ConfigureProcessor = { ~connector=connectorName, ~bodyType, ~isPayoutFlow=false, - ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, + ~isLiveMode={featureFlagDetails.testLiveMode}, (), ) setInitialValues(_ => body) diff --git a/src/screens/HyperSwitch/Home/HomeUtils.res b/src/screens/HyperSwitch/Home/HomeUtils.res index 663ae1785..e87ce358c 100644 --- a/src/screens/HyperSwitch/Home/HomeUtils.res +++ b/src/screens/HyperSwitch/Home/HomeUtils.res @@ -277,16 +277,13 @@ module ControlCenter = { let pageName = url.path->getPageNameFromUrl - 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" + let isLiveModeEnabledStyles = testLiveMode + ? "flex flex-col md:flex-row gap-5 w-full" + : "flex flex-col gap-5 md:w-1/2 w-full"
- Belt.Option.getWithDefault(false) ? "" : "h-3/6"}> + - Belt.Option.getWithDefault(false) ? "" : "h-4/6"}> +
- Belt.Option.getWithDefault(false))}> +
diff --git a/src/screens/HyperSwitch/Order/OrderUIUtils.res b/src/screens/HyperSwitch/Order/OrderUIUtils.res index 5cca74b2f..c84381ed3 100644 --- a/src/screens/HyperSwitch/Order/OrderUIUtils.res +++ b/src/screens/HyperSwitch/Order/OrderUIUtils.res @@ -88,7 +88,7 @@ module NoData = { ->FeatureFlagUtils.featureFlagType Belt.Option.getWithDefault(false) + ? testLiveMode ? "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."} @@ -96,7 +96,7 @@ module NoData = { moduleName="" paymentModal setPaymentModal - showRedirectCTA={!(testLiveMode->Belt.Option.getWithDefault(false))} + showRedirectCTA={!testLiveMode} mixPanelEventName={isConfigureConnector ? "paymentops_makeapayment" : "payemntops_connectaconnector"} diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res index e6f70932c..8779bcedf 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res @@ -121,9 +121,9 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { ) let {profile_id} = - Recoil.useRecoilValueFromAtom( - HyperswitchAtom.businessProfilesAtom, - )->HSwitchMerchantAccountUtils.getValueFromBusinessProfile + HyperswitchAtom.businessProfilesAtom + ->Recoil.useRecoilValueFromAtom + ->HSwitchMerchantAccountUtils.getValueFromBusinessProfile let updateSetupConnectorCredentials = async connectorId => { try { @@ -173,7 +173,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { ~values, ~connector=connectorName, ~bodyType, - ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, + ~isLiveMode={featureFlagDetails.testLiveMode}, (), ) @@ -238,7 +238,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { ~connector={connectorName}, ~bodyType, ~isPayoutFlow=false, - ~isLiveMode={featureFlagDetails.testLiveMode->Belt.Option.getWithDefault(false)}, + ~isLiveMode={featureFlagDetails.testLiveMode}, (), )->ignoreFields(connectorID, verifyConnectorIgnoreField) diff --git a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessMappingEntity.res b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessMappingEntity.res index 2a585cacb..79ab70890 100644 --- a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessMappingEntity.res +++ b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessMappingEntity.res @@ -4,22 +4,18 @@ open BusinessMappingUtils type columns = | ProfileName | ProfileId - | ReturnUrl - | WebhookUrl -let visibleColumns = [ProfileName, ProfileId, ReturnUrl, WebhookUrl] +let visibleColumns = [ProfileId, ProfileName] -let defaultColumns = [ProfileName, ProfileId, ReturnUrl, WebhookUrl] +let defaultColumns = [ProfileId, ProfileName] -let allColumns = [ProfileName, ProfileId, ReturnUrl, WebhookUrl] +let allColumns = [ProfileId, ProfileName] let getHeading = colType => { switch colType { | ProfileId => Table.makeHeaderInfo(~key="profile_id", ~title="Profile Id", ~showSort=true, ()) | ProfileName => Table.makeHeaderInfo(~key="profile_name", ~title="Profile Name", ~showSort=true, ()) - | ReturnUrl => Table.makeHeaderInfo(~key="return_url", ~title="Return URL", ~showSort=true, ()) - | WebhookUrl => Table.makeHeaderInfo(~key="webhook_url", ~title="Webhook URL", ~showSort=true, ()) } } @@ -27,8 +23,6 @@ let getCell = (item: profileEntity, colType): Table.cell => { switch colType { | ProfileId => Text(item.profile_id) | ProfileName => Text(item.profile_name) - | ReturnUrl => Text(item.return_url->Belt.Option.getWithDefault("")) - | WebhookUrl => Text(item.webhook_details.webhook_url->Belt.Option.getWithDefault("")) } } @@ -51,17 +45,16 @@ let getItems: Js.Json.t => array = json => { LogicUtils.getArrayDataFromJson(json, itemToObjMapper) } -let businessProfileTabelEntity = showLink => - EntityType.makeEntity( - ~uri="", - ~getObjects=getItems, - ~defaultColumns, - ~allColumns, - ~getHeading, - ~dataKey="", - ~getCell, - ~getShowLink={ - profile => showLink ? `/webhooks/${profile.profile_id}` : "" - }, - (), - ) +let businessProfileTableEntity = EntityType.makeEntity( + ~uri="", + ~getObjects=getItems, + ~defaultColumns, + ~allColumns, + ~getHeading, + ~dataKey="", + ~getCell, + ~getShowLink={ + profile => `/webhooks/${profile.profile_id}` + }, + (), +) diff --git a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res index 384f1d88f..49e03db00 100644 --- a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res +++ b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res @@ -67,7 +67,6 @@ let make = ( ~isFromSettings=true, ~showModalFromOtherScreen=false, ~setShowModalFromOtherScreen=_bool => (), - ~isFromWebhooks=false, ) => { open APIUtils open BusinessMappingUtils @@ -81,9 +80,9 @@ let make = ( let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Success) let businessProfileValues = - Recoil.useRecoilValueFromAtom( - HyperswitchAtom.businessProfilesAtom, - )->HSwitchMerchantAccountUtils.getArrayOfBusinessProfile + HyperswitchAtom.businessProfilesAtom + ->Recoil.useRecoilValueFromAtom + ->HSwitchMerchantAccountUtils.getArrayOfBusinessProfile let fetchBusinessProfiles = HSwitchMerchantAccountUtils.useFetchBusinessProfiles() @@ -111,24 +110,21 @@ let make = ( updateMerchantDetails(values)->ignore Js.Nullable.null } - let tableHeaderText = isFromWebhooks ? "Webhooks" : "Business Profiles"
Js.Array2.map(Js.Nullable.return)} totalResults={businessProfileValues->Js.Array2.length} @@ -136,14 +132,9 @@ let make = ( setOffset currrentFetchCount={businessProfileValues->Js.Array2.length} /> - // - -
- -
-
+
+ +
diff --git a/src/screens/HyperSwitch/UserManagement/HSwitchUserRoleEntry.res b/src/screens/HyperSwitch/UserManagement/HSwitchUserRoleEntry.res index 3a2a13480..7f202af1c 100644 --- a/src/screens/HyperSwitch/UserManagement/HSwitchUserRoleEntry.res +++ b/src/screens/HyperSwitch/UserManagement/HSwitchUserRoleEntry.res @@ -99,7 +99,7 @@ let make = () => { entity={userEntity} currrentFetchCount={usersFilterData->Js.Array2.length} showSerialNumber=true - collapseTabelRow=false + collapseTableRow=false rowHeightClass="h-20" tableheadingClass="h-16" /> diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthScreen.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthScreen.res index ed749027e..ade1b4c48 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthScreen.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthScreen.res @@ -74,7 +74,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit) => { }, [isMagicLinkEnabled]) React.useEffect1(() => { - if testLiveMode->Belt.Option.getWithDefault(false) { + if testLiveMode { setMode(_ => LiveButtonMode) } else { setMode(_ => TestButtonMode) diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res index 599639e1a..00456710d 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuthUtils.res @@ -383,18 +383,14 @@ module Header = {

{cardHeaderText->React.string}

{switch authType { | LoginWithPassword | LoginWithEmail => - switch testLiveMode { - | Some(val) => - !val - ? getHeaderLink( - ~prefix="New to Hyperswitch?", - ~authType=SignUP, - ~path="/register", - ~sufix="Sign up", - ) - : React.null - | _ => React.null - } + !testLiveMode + ? getHeaderLink( + ~prefix="New to Hyperswitch?", + ~authType=SignUP, + ~path="/register", + ~sufix="Sign up", + ) + : React.null | SignUP => getHeaderLink(