Skip to content

Commit

Permalink
chore: omp views redesign changes (#1894)
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 19, 2024
1 parent 4addc3e commit 2dfb19a
Show file tree
Hide file tree
Showing 33 changed files with 351 additions and 207 deletions.
3 changes: 3 additions & 0 deletions public/hyperswitch/icons/solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/components/DynamicFilter.res
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ module CustomFilters = {

@react.component
let make = (
~title="",
~initialFilters: array<EntityType.initialFilters<'t>>,
~options: array<EntityType.optionType<'t>>,
~popupFilterFields,
Expand Down Expand Up @@ -217,6 +218,7 @@ let make = (

<div className="flex-1 ml-1">
<Filter
title
defaultFilters
fixedFilters=initialFixedFilters
requiredSearchFieldsList=[]
Expand Down
1 change: 1 addition & 0 deletions src/components/Filter.res
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ let make = (
fieldWrapperClass="p-0"
/>
</RenderIf>
<PortalCapture key={`${title}OMPView`} name={`${title}OMPView`} />
<PortalCapture key={`${title}CustomizeColumn`} name={`${title}CustomizeColumn`} />
</div>
</div>
Expand Down
23 changes: 20 additions & 3 deletions src/components/SelectBox.res
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ module ListItem = {
~textEllipsisForDropDownOptions=false,
~textColorClass="",
~customRowClass="",
~labelDescription=Some(""),
~labelDescriptionClass="",
) => {
let {globalUIConfig: {font}} = React.useContext(ThemeProvider.themeContext)
let labelText = switch labelValue->String.length {
Expand Down Expand Up @@ -271,9 +273,14 @@ module ListItem = {
let selectOptions =
<AddDataAttributes
attributes=[("data-text", labelText)] key={i->Int.toString}>
<span key={i->Int.toString} className=textClass value=labelText>
{item->React.string}
</span>
{<div className="flex gap-1 items-center">
<span key={i->Int.toString} className=textClass value=labelText>
{item->React.string}
</span>
<p className={`${labelDescriptionClass}`}>
{`${labelDescription->Option.getOr("")}`->React.string}
</p>
</div>}
</AddDataAttributes>

{
Expand Down Expand Up @@ -365,6 +372,7 @@ type dropdownOptionWithoutOptional = {
isDisabled: bool,
icon: Button.iconType,
description: option<string>,
labelDescription: option<string>,
iconStroke: string,
textColor: string,
optGroup: string,
Expand All @@ -373,6 +381,7 @@ type dropdownOptionWithoutOptional = {
type dropdownOption = {
label: string,
value: string,
labelDescription?: string,
optGroup?: string,
isDisabled?: bool,
icon?: Button.iconType,
Expand All @@ -393,6 +402,7 @@ let makeNonOptional = (dropdownOption: dropdownOption): dropdownOptionWithoutOpt
textColor: dropdownOption.textColor->Option.getOr(""),
optGroup: dropdownOption.optGroup->Option.getOr("-"),
customRowClass: dropdownOption.customRowClass->Option.getOr(""),
labelDescription: dropdownOption.labelDescription,
}
}

Expand Down Expand Up @@ -1105,6 +1115,7 @@ module RenderListItemInBaseRadio = {
~selectClass="",
~customScrollStyle=?,
~shouldDisplaySelectedOnTop,
~labelDescriptionClass="",
) => {
let decodedValue = value->JSON.Decode.string
switch (decodedValue, shouldDisplaySelectedOnTop) {
Expand Down Expand Up @@ -1161,6 +1172,8 @@ module RenderListItemInBaseRadio = {
customRowClass={option.customRowClass}
optionClass
selectClass
labelDescription=option.labelDescription
labelDescriptionClass
/>

if !descriptionOnHover {
Expand Down Expand Up @@ -1293,6 +1306,7 @@ module BaseRadio = {
~customScrollStyle=?,
~dropdownContainerStyle="",
~shouldDisplaySelectedOnTop=false,
~labelDescriptionClass="",
) => {
let options = React.useMemo(() => {
options->Array.map(makeNonOptional)
Expand Down Expand Up @@ -1483,6 +1497,7 @@ module BaseRadio = {
selectClass
?customScrollStyle
shouldDisplaySelectedOnTop
labelDescriptionClass
/>
} else {
{
Expand Down Expand Up @@ -1613,6 +1628,7 @@ module BaseDropdown = {
~customScrollStyle=?,
~dropdownContainerStyle="",
~shouldDisplaySelectedOnTop=false,
~labelDescriptionClass="",
) => {
let transformedOptions = useTransformed(options)
let isMobileView = MatchMedia.useMobileChecker()
Expand Down Expand Up @@ -1883,6 +1899,7 @@ module BaseDropdown = {
?customScrollStyle
dropdownContainerStyle
shouldDisplaySelectedOnTop
labelDescriptionClass
/>
}

Expand Down
7 changes: 7 additions & 0 deletions src/components/SelectBox.resi
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ module ListItem: {
~textEllipsisForDropDownOptions: bool=?,
~textColorClass: string=?,
~customRowClass: string=?,
~labelDescription: option<string>=?,
~labelDescriptionClass: string=?,
) => React.element
}
type dropdownOptionWithoutOptional = {
Expand All @@ -56,6 +58,7 @@ type dropdownOptionWithoutOptional = {
isDisabled: bool,
icon: Button.iconType,
description: option<string>,
labelDescription: option<string>,
iconStroke: string,
textColor: string,
optGroup: string,
Expand All @@ -64,6 +67,7 @@ type dropdownOptionWithoutOptional = {
type dropdownOption = {
label: string,
value: string,
labelDescription?: string,
optGroup?: string,
isDisabled?: bool,
icon?: Button.iconType,
Expand Down Expand Up @@ -184,6 +188,7 @@ module RenderListItemInBaseRadio: {
~selectClass: string=?,
~customScrollStyle: string=?,
~shouldDisplaySelectedOnTop: bool,
~labelDescriptionClass: string=?,
) => React.element
}
let getHashMappedOptionValues: array<dropdownOptionWithoutOptional> => RescriptCore.Dict.t<
Expand Down Expand Up @@ -232,6 +237,7 @@ module BaseRadio: {
~customScrollStyle: string=?,
~dropdownContainerStyle: string=?,
~shouldDisplaySelectedOnTop: bool=?,
~labelDescriptionClass: string=?,
) => React.element
}
type direction = BottomLeft | BottomMiddle | BottomRight | TopLeft | TopMiddle | TopRight
Expand Down Expand Up @@ -315,6 +321,7 @@ module BaseDropdown: {
~customScrollStyle: string=?,
~dropdownContainerStyle: string=?,
~shouldDisplaySelectedOnTop: bool=?,
~labelDescriptionClass: string=?,
) => React.element
}
module InfraSelectBox: {
Expand Down
4 changes: 3 additions & 1 deletion src/screens/APIUtils/APIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ let responseHandler = async (
sendEvent(~eventName="API Error", ~description=Some(responseStatus), ~metadata=metaData)
}

let noAccessControlText = "You do not have the required permissions to access this module. Please contact your admin."

switch responseStatus {
| 200 => json
| _ => {
Expand Down Expand Up @@ -810,7 +812,7 @@ let responseHandler = async (
popUpType: (Warning, WithIcon),
heading: "Access Forbidden",
description: {
HSwitchUtils.noAccessControlText->React.string
noAccessControlText->React.string
},
handleConfirm: {
text: "Close",
Expand Down
1 change: 1 addition & 0 deletions src/screens/Analytics/Analytics.res
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ let make = (
views={OMPSwitchUtils.analyticsViewList(~checkUserEntity)}
selectedEntity={analyticsEntity}
onChange={updateAnalytcisEntity}
entityMapper=UserInfoUtils.analyticsEntityMapper
/>
</RenderIf>
</div>
Expand Down
15 changes: 10 additions & 5 deletions src/screens/Analytics/PaymentsAnalytics/PaymentAnalytics.res
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ let make = () => {
| Some(filterData) =>
<div className="flex flex-row">
<DynamicFilter
title="PaymentAnalytics"
initialFilters={initialFilterFields(filterData)}
options=[]
popupFilterFields={options(filterData)}
Expand All @@ -223,6 +224,7 @@ let make = () => {
| None =>
<div className="flex flex-row">
<DynamicFilter
title="PaymentAnalytics"
initialFilters=[]
options=[]
popupFilterFields=[]
Expand All @@ -243,11 +245,14 @@ let make = () => {
<div className="flex flex-col gap-5">
<div className="flex items-center justify-between ">
<PageUtils.PageHeading title />
<OMPSwitchHelper.OMPViews
views={OMPSwitchUtils.analyticsViewList(~checkUserEntity)}
selectedEntity={analyticsEntity}
onChange={updateAnalytcisEntity}
/>
<Portal to="PaymentAnalyticsOMPView">
<OMPSwitchHelper.OMPViews
views={OMPSwitchUtils.analyticsViewList(~checkUserEntity)}
selectedEntity={analyticsEntity}
onChange={updateAnalytcisEntity}
entityMapper=UserInfoUtils.analyticsEntityMapper
/>
</Portal>
</div>
<div
className="-ml-1 sticky top-0 z-30 p-1 bg-hyperswitch_background/70 py-1 rounded-lg my-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ let make = (~domain="payments") => {
views={OMPSwitchUtils.analyticsViewList(~checkUserEntity)}
selectedEntity={analyticsEntity}
onChange={updateAnalytcisEntity}
entityMapper=UserInfoUtils.analyticsEntityMapper
/>
</div>
<div
Expand Down
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={<HelperComponents.BusinessProfileComponent
element={<BusinessProfileHook.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(
<HelperComponents.BusinessProfileComponent profile_id={connector.profile_id} />,
<BusinessProfileHook.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(
<HelperComponents.BusinessProfileComponent profile_id={connector.profile_id} />,
<BusinessProfileHook.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(
<HelperComponents.BusinessProfileComponent profile_id={connector.profile_id} />,
<BusinessProfileHook.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(
<HelperComponents.BusinessProfileComponent profile_id={connector.profile_id} />,
<BusinessProfileHook.BusinessProfileComponent profile_id={connector.profile_id} />,
"",
)
| ConnectorLabel => Text(connector.connector_label)
Expand Down
55 changes: 45 additions & 10 deletions src/screens/Helpers/HelperComponents.res
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,51 @@ module CopyTextCustomComp = {
}
}

module EllipsisText = {
@react.component
let make = (
~displayValue,
~endValue=17,
~showCopy=true,
~customTextStyle="",
~expandText=true,
) => {
open LogicUtils
let (isTextVisible, setIsTextVisible) = React.useState(_ => false)

let handleClick = ev => {
ev->ReactEvent.Mouse.stopPropagation
if expandText {
setIsTextVisible(_ => true)
}
}

let text = if showCopy {
<CopyTextCustomComp displayValue customTextCss="text-nowrap" />
} else {
<div> {displayValue->React.string} </div>
}

<div>
<RenderIf condition={isTextVisible}>
<div> {text} </div>
</RenderIf>
<RenderIf condition={!isTextVisible && displayValue->isNonEmptyString}>
<div className="flex text-nowrap gap-1">
<p className="">
{`${displayValue->String.slice(~start=0, ~end=endValue)}`->React.string}
</p>
<span
className={`flex text-blue-811 text-sm font-extrabold ${customTextStyle}`}
onClick={ev => handleClick(ev)}>
{"..."->React.string}
</span>
</div>
</RenderIf>
</div>
}
}

module BluredTableComponent = {
@react.component
let make = (
Expand Down Expand Up @@ -151,13 +196,3 @@ 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>
}
}
18 changes: 10 additions & 8 deletions src/screens/Home/Home.res
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ let make = (~setAppScreenState) => {
let {userInfo: {recoveryCodesLeft}} = React.useContext(UserInfoProvider.defaultContext)
let recoveryCode = recoveryCodesLeft->Option.getOr(0)

<div className="w-full gap-8 flex flex-col">
<>
<div className="flex flex-col gap-4">
<RenderIf condition={recoveryCodesLeft->Option.isSome && recoveryCode < 3}>
<HomeUtils.LowRecoveryCodeBanner recoveryCode />
</RenderIf>
<PendingInvitationsHome setAppScreenState />
</div>
<PageHeading
title={`${greeting}, it's great to see you!`}
subTitle="Welcome to the home of your Payments Control Centre. It aims at providing your team with a 360-degree view of payments."
/>
<ControlCenter />
<DevResources />
</div>
<div className="w-full gap-8 flex flex-col">
<PageHeading
title={`${greeting}, it's great to see you!`}
subTitle="Welcome to the home of your Payments Control Centre. It aims at providing your team with a 360-degree view of payments."
/>
<ControlCenter />
<DevResources />
</div>
</>
}
Loading

0 comments on commit 2dfb19a

Please sign in to comment.