fix: Bank rules conditions column

This commit is contained in:
Ahmed Bouhuolia
2024-07-01 10:48:11 +02:00
parent 5bbcb7913d
commit da0fab9a58
4 changed files with 84 additions and 13 deletions

View File

@@ -2,17 +2,36 @@
import { useMemo } from 'react';
import { Intent, Tag } from '@blueprintjs/core';
const applyToTypeAccessor = (rule) => {
return rule.apply_if_transaction_type === 'deposit' ? (
<Tag round intent={Intent.SUCCESS}>
Deposits
</Tag>
) : (
<Tag round intent={Intent.DANGER}>
Withdrawals
</Tag>
);
};
const conditionsAccessor = (rule) => (
<span style={{ fontSize: 12, color: '#5F6B7C' }}>
{rule.conditions_formatted}
</span>
);
const applyToAccessor = (rule) => (
<Tag intent={Intent.NONE} minimal>
{rule.assign_account_name}
</Tag>
);
export const useBankRulesTableColumns = () => {
return useMemo(
() => [
{
Header: 'Apply to',
accessor: (rule) =>
rule.apply_if_transaction_type === 'deposit' ? (
<Tag round intent={Intent.SUCCESS}>Deposits</Tag>
) : (
<Tag round intent={Intent.DANGER}>Withdrawals</Tag>
),
accessor: applyToTypeAccessor,
},
{
Header: 'Rule Name',
@@ -20,15 +39,15 @@ export const useBankRulesTableColumns = () => {
},
{
Header: 'Categorize As',
accessor: () => 'Expense',
accessor: 'assign_category_formatted',
},
{
Header: 'Apply To',
accessor: () => <Tag intent={Intent.NONE} minimal>All Accounts</Tag>,
accessor: applyToAccessor,
},
{
Header: 'Conditions',
accessor: () => '',
accessor: conditionsAccessor,
},
],
[],