diff --git a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessMappingUtils.res b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessMappingUtils.res
index 6a21fd6cd..6d2cdafd2 100644
--- a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessMappingUtils.res
+++ b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessMappingUtils.res
@@ -17,7 +17,7 @@ let labelField = FormRenderer.makeFieldInfo(
(),
)
-type modalState = Loading | Edit
+type modalState = Loading | Edit | Successful
let validateEmptyValue = (key, errors) => {
switch key {
diff --git a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res
index 4cea24ef1..ad54c171b 100644
--- a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res
+++ b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res
@@ -1,9 +1,30 @@
+module WarningArea = {
+ @react.component
+ let make = (~warningText) => {
+
+ {"NOTE:"->React.string}
+ {warningText->React.string}
+
+ }
+}
module AddEntryBtn = {
@react.component
- let make = (~onSubmit, ~modalState, ~showModal, ~setShowModal, ~list, ~isFromSettings=true) => {
+ let make = (
+ ~onSubmit,
+ ~modalState,
+ ~showModal,
+ ~setShowModal,
+ ~list,
+ ~isFromSettings=true,
+ ~updatedProfileId,
+ ~setModalState,
+ ) => {
open HSwitchUtils
open BusinessMappingUtils
- let initialValues = [("profile_name", "Default"->Js.Json.string)]->Js.Dict.fromArray
+ let initialValues =
+ [
+ ("profile_name", `default${list->Js.Array2.length->string_of_int}`->Js.Json.string),
+ ]->Js.Dict.fromArray
let modalBody =
{switch modalState {
@@ -37,9 +58,34 @@ module AddEntryBtn = {
+ | Successful =>
+
+
+
+ {"Business Profile successfully created! Set up your payments settings like webhooks, return url for your new profile before trying a payment."->React.string}
+
+
{
+ if updatedProfileId->Js.String2.length > 0 {
+ RescriptReactRouter.replace(`/payment-settings/${updatedProfileId}`)
+ setModalState(_ => Edit)
+ }
+ }}
+ customButtonStyle="!w-1/3 mt-6"
+ />
+
}}
+ let modalHeaderText = switch modalState {
+ | Edit | Loading => "Add Business Profile Name"
+ | Successful => "Configure payment settings"
+ }
+
@@ -78,6 +124,7 @@ let make = (
let (showModal, setShowModal) = React.useState(_ => false)
let (modalState, setModalState) = React.useState(_ => Edit)
let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Success)
+ let (updatedProfileId, setUpdatedProfileId) = React.useState(_ => "")
let businessProfileValues =
HyperswitchAtom.businessProfilesAtom
@@ -90,7 +137,10 @@ let make = (
try {
setScreenState(_ => PageLoaderWrapper.Loading)
let url = getURL(~entityName=BUSINESS_PROFILE, ~methodType=Post, ())
- let _ = await updateDetails(url, body, Post)
+ let response = await updateDetails(url, body, Post)
+ setUpdatedProfileId(_ =>
+ response->LogicUtils.getDictFromJsonObject->LogicUtils.getString("profile_id", "")
+ )
fetchBusinessProfiles()->ignore
showToast(~message="Your Entry added successfully", ~toastType=ToastState.ToastSuccess, ())
if !isFromSettings {
@@ -100,9 +150,12 @@ let make = (
} catch {
| _ => setScreenState(_ => PageLoaderWrapper.Error(""))
}
- isFromSettings ? setShowModal(_ => false) : setShowModalFromOtherScreen(_ => false)
- setModalState(_ => Edit)
- setShowModal(_ => false)
+
+ if !isFromSettings {
+ setShowModalFromOtherScreen(_ => false)
+ }
+ setModalState(_ => Successful)
+
Js.Nullable.null
}
@@ -114,11 +167,16 @@ let make = (
-
+
+
Js.Array2.length > 1}>
+
+
Js.Array2.length}
/>
@@ -146,6 +212,8 @@ let make = (
showModal={showModalFromOtherScreen}
setShowModal={setShowModalFromOtherScreen}
list={businessProfileValues}
+ updatedProfileId
+ setModalState
/>