Skip to content

Commit

Permalink
fix: connector label and profile id default value fix (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
Riddhiagrawal001 authored Dec 13, 2023
1 parent 5634990 commit 9822972
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ let make = (~connectProcessorValue: connectProcessor) => {
}
}

React.useEffect2(() => {
setInitialValues(prevJson => {
let prevJsonDict = prevJson->LogicUtils.getDictFromJsonObject
prevJsonDict->Js.Dict.set(
"connector_label",
`${selectedConnector->ConnectorUtils.getConnectorNameString}_${activeBusinessProfile.profile_name}`->Js.Json.string,
)
prevJsonDict->Js.Json.object_
})

None
}, (selectedConnector, activeBusinessProfile.profile_name))

let volumeBasedRoutingAPICall = async () => {
try {
open LogicUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ module ConfigureProcessor = {
checkboxText=""
/>
</QuickStartUIUtils.BaseComponent>
<FormValuesSpy />
</Form>
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module ConnectorDetailsForm = {
~verifyErrorMessage,
~checkboxText,
) => {
let featureFlagDetails = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
let (showVerifyModal, setShowVerifyModal) = React.useState(_ => false)

let (
Expand All @@ -37,6 +38,11 @@ module ConnectorDetailsForm = {
)

<div className="flex flex-col gap-6">
<UIUtils.RenderIf condition={featureFlagDetails.businessProfile}>
<ConnectorAccountDetails.BusinessProfileRender
isUpdateFlow=false selectedConnector={connectorName}
/>
</UIUtils.RenderIf>
<ConnectorAccountDetailsHelper.ConnectorConfigurationFields
connectorAccountFields
connector={connectorName->getConnectorNameTypeFromString}
Expand Down Expand Up @@ -86,6 +92,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => {
let (connectorDetails, setConnectorDetails) = React.useState(_ => Js.Json.null)
let (isLoading, setIsLoading) = React.useState(_ => false)
let merchantId = HSLocalStorage.getFromMerchantDetails("merchant_id")
let (initialValues, setInitialValues) = React.useState(_ => Js.Json.null)

let getDetails = async () => {
let _wasmResult = await Window.connectorWasmInit()
Expand All @@ -110,12 +117,28 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => {
connectorWebHookDetails,
connectorLabelDetailField,
) = getConnectorFields(connectorDetails)
let businessProfiles = Recoil.useRecoilValueFromAtom(HyperswitchAtom.businessProfilesAtom)
let defaultBusinessProfile = businessProfiles->MerchantAccountUtils.getValueFromBusinessProfile

let (suggestedAction, suggestedActionExists) = getSuggestedAction(
~verifyErrorMessage,
~connector={connectorName},
)

React.useEffect1(() => {
setInitialValues(prevJson => {
let prevJsonDict = prevJson->LogicUtils.getDictFromJsonObject
prevJsonDict->Js.Dict.set(
"connector_label",
`${selectedConnector->ConnectorUtils.getConnectorNameString}_${defaultBusinessProfile.profile_name}`->Js.Json.string,
)
prevJsonDict->Js.Dict.set("profile_id", defaultBusinessProfile.profile_id->Js.Json.string)
prevJsonDict->Js.Json.object_
})

None
}, [selectedConnector])

let {profile_id} =
HyperswitchAtom.businessProfilesAtom
->Recoil.useRecoilValueFromAtom
Expand Down Expand Up @@ -349,10 +372,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => {
}

<PageLoaderWrapper screenState>
<Form
initialValues={Js.Dict.empty()->Js.Json.object_}
onSubmit={handleSubmit}
validate={validateMandatoryField}>
<Form initialValues onSubmit={handleSubmit} validate={validateMandatoryField}>
<div className="flex flex-col h-full w-full ">
<div className="flex justify-between px-11 py-8 flex-wrap gap-4">
<div className="flex gap-4 items-center">
Expand Down Expand Up @@ -396,6 +416,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => {
suggestedAction
setVerifyDone
/>
<FormValuesSpy />
</Form>
</PageLoaderWrapper>
}

0 comments on commit 9822972

Please sign in to comment.