Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show staged payment (if it enabled) in payments list #3563

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ import {
// Waves,
ArrowsOutLineHorizontal,
// @TODO: uncomment when staged payment is ready
// Steps,
Steps,
type Icon,
} from '@phosphor-icons/react';

import { Action } from '~constants/actions.ts';
import { formatText } from '~utils/intl.ts';

export const GROUP_LIST = [
type GroupListItem = {
title: string;
description: string;
Icon: Icon;
action: Action;
isNew?: boolean;
isHidden?: boolean;
};

export const GROUP_LIST: GroupListItem[] = [
{
title: formatText({ id: 'actions.simplePayment' }),
description: formatText({
Expand Down Expand Up @@ -47,14 +57,13 @@ export const GROUP_LIST = [
action: Action.SplitPayment,
isNew: true,
},
// @TODO: uncomment when staged payment is ready
// {
// title: formatText({ id: 'actions.stagedPayment' }),
// description: formatText({
// id: 'actions.description.stagedPayment',
// }),
// Icon: Steps,
// action: Action.StagedPayment,
// isNew: true,
// },
{
title: formatText({ id: 'actions.stagedPayment' }),
description: formatText({
id: 'actions.description.stagedPayment',
}),
Icon: Steps,
action: Action.StagedPayment,
isNew: true,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,31 @@ import { formatText } from '~utils/intl.ts';
import GroupedAction from '../GroupedAction/index.ts';
import GroupedActionWrapper from '../GroupedActionWrapper/index.ts';

import { GROUP_LIST } from './GroupList.ts';
import { useGetGroupList } from './useGetGroupList.tsx';

const PaymentGroup = () => {
const groupList = useGetGroupList();
return (
<GroupedActionWrapper
title={formatText({ id: 'actions.payments' })}
description={formatText({ id: 'actions.description.payments' })}
>
<GroupedAction.List>
{GROUP_LIST.map(({ Icon, title, description, action, isNew }) => {
return (
<GroupedAction.Item
color="blue"
Icon={Icon}
title={title}
description={description}
action={action}
key={`group-action-item-${action}`}
isNew={isNew}
/>
);
})}
{groupList.map(
({ Icon, title, description, action, isNew, isHidden }) => {
return !isHidden ? (
<GroupedAction.Item
color="blue"
Icon={Icon}
title={title}
description={description}
action={action}
key={`group-action-item-${action}`}
isNew={isNew}
/>
) : null;
},
)}
</GroupedAction.List>
</GroupedActionWrapper>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Action } from '~constants/actions.ts';
import useEnabledExtensions from '~hooks/useEnabledExtensions.ts';

import { GROUP_LIST } from './GroupList.ts';

export const useGetGroupList = () => {
const { isStagedExpenditureEnabled } = useEnabledExtensions();
let groupListTransformed = [...GROUP_LIST];

if (!isStagedExpenditureEnabled) {
groupListTransformed = groupListTransformed.map(({ action, ...rest }) => {
return {
...rest,
action,
isHidden: action === Action.StagedPayment,
};
});
}

return groupListTransformed;
};
Loading