Skip to content

Commit

Permalink
chore: moving business profile component to helper file (#1959)
Browse files Browse the repository at this point in the history
Co-authored-by: Gitanjli Chopra <[email protected]>
  • Loading branch information
gitanjli525 and Gitanjli Chopra authored Dec 20, 2024
1 parent bd6905c commit 49471d3
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/screens/ConfigurePMTs/PaymentMethodEntity.res
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let getCell = (~setReferesh) => {
Table.CustomCell(
<PaymentMethodConfig
paymentMethodConfig
element={<BusinessProfileHook.BusinessProfileComponent
element={<HelperComponents.BusinessProfileComponent
profile_id={paymentMethodConfig.profile_id}
/>}
setReferesh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let getCell = (connector: connectorPayload, colType): Table.cell => {
| ProfileId => Text(connector.profile_id)
| ProfileName =>
Table.CustomCell(
<BusinessProfileHook.BusinessProfileComponent profile_id={connector.profile_id} />,
<HelperComponents.BusinessProfileComponent profile_id={connector.profile_id} />,
"",
)
| ConnectorLabel => Text(connector.connector_label)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ let getTableCell = (~connectorType: ConnectorTypes.connector=Processor) => {
| ProfileId => DisplayCopyCell(connector.profile_id)
| ProfileName =>
Table.CustomCell(
<BusinessProfileHook.BusinessProfileComponent profile_id={connector.profile_id} />,
<HelperComponents.BusinessProfileComponent profile_id={connector.profile_id} />,
"",
)
| ConnectorLabel => Text(connector.connector_label)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let getCell = (connector: connectorPayload, colType): Table.cell => {
| ProfileId => Text(connector.profile_id)
| ProfileName =>
Table.CustomCell(
<BusinessProfileHook.BusinessProfileComponent profile_id={connector.profile_id} />,
<HelperComponents.BusinessProfileComponent profile_id={connector.profile_id} />,
"",
)
| ConnectorLabel => Text(connector.connector_label)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let getCell = (connector: connectorPayload, colType): Table.cell => {
| ProfileId => Text(connector.profile_id)
| ProfileName =>
Table.CustomCell(
<BusinessProfileHook.BusinessProfileComponent profile_id={connector.profile_id} />,
<HelperComponents.BusinessProfileComponent profile_id={connector.profile_id} />,
"",
)
| ConnectorLabel => Text(connector.connector_label)
Expand Down
10 changes: 10 additions & 0 deletions src/screens/Helpers/HelperComponents.res
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,13 @@ module ConnectorCustomCell = {
}
}
}

module BusinessProfileComponent = {
@react.component
let make = (~profile_id: string, ~className="") => {
let {profile_name} = BusinessProfileHook.useGetBusinessProflile(profile_id)
<div className>
{(profile_name->LogicUtils.isNonEmptyString ? profile_name : "NA")->React.string}
</div>
}
}
10 changes: 0 additions & 10 deletions src/screens/Hooks/BusinessProfileHook.res
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,3 @@ let useGetBusinessProflile = profileId => {
->Array.find(profile => profile.profile_id == profileId)
->Option.getOr(MerchantAccountUtils.defaultValueForBusinessProfile)
}

module BusinessProfileComponent = {
@react.component
let make = (~profile_id: string, ~className="") => {
let {profile_name} = useGetBusinessProflile(profile_id)
<div className>
{(profile_name->LogicUtils.isNonEmptyString ? profile_name : "NA")->React.string}
</div>
}
}
2 changes: 1 addition & 1 deletion src/screens/PayoutRouting/PayoutHistoryTableEntity.res
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let getTableCell = activeRoutingIds => {
| ProfileId => Text(historyData.profile_id)
| ProfileName =>
Table.CustomCell(
<BusinessProfileHook.BusinessProfileComponent profile_id={historyData.profile_id} />,
<HelperComponents.BusinessProfileComponent profile_id={historyData.profile_id} />,
"",
)
| Description => Text(historyData.description)
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Routing/ActiveRouting.res
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module ActiveSection = {
</div>
<RenderIf condition={profileId->isNonEmptyString}>
<div className="flex gap-2">
<BusinessProfileHook.BusinessProfileComponent
<HelperComponents.BusinessProfileComponent
profile_id={profileId} className="text-lightgray_background opacity-50 text-sm"
/>
<p className="text-lightgray_background opacity-50 text-sm">
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Routing/HistoryEntity.res
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let getTableCell = activeRoutingIds => {
| ProfileId => Text(historyData.profile_id)
| ProfileName =>
Table.CustomCell(
<BusinessProfileHook.BusinessProfileComponent profile_id={historyData.profile_id} />,
<HelperComponents.BusinessProfileComponent profile_id={historyData.profile_id} />,
"",
)
| Description => Text(historyData.description)
Expand Down
2 changes: 1 addition & 1 deletion src/screens/RoutingRevamp/BasicDetailsForm.res
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ let make = (
</span>
<AddDataAttributes attributes=[("data-text", getStringFromJson(ip3.value, ""))]>
<span className="font-semibold">
<BusinessProfileHook.BusinessProfileComponent
<HelperComponents.BusinessProfileComponent
profile_id={profile->Option.getOr(defaultBusinessProfile.profile_id)}
/>
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Transaction/Order/OrderEntity.res
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ let getCellForAboutPayment = (order, aboutPaymentColType: aboutPaymentColType):
| ProfileId => Text(order.profile_id)
| ProfileName =>
Table.CustomCell(
<BusinessProfileHook.BusinessProfileComponent profile_id={order.profile_id} />,
<HelperComponents.BusinessProfileComponent profile_id={order.profile_id} />,
"",
)
| CaptureMethod => Text(order.capture_method)
Expand Down

0 comments on commit 49471d3

Please sign in to comment.