feat: get bank account meta summary

This commit is contained in:
Ahmed Bouhuolia
2024-07-02 19:21:26 +02:00
parent 8a09de9771
commit 91730d204e
22 changed files with 476 additions and 69 deletions

View File

@@ -0,0 +1,3 @@
.root{
max-width: 600px;
}

View File

@@ -4,32 +4,44 @@ import { Button, Intent } from '@blueprintjs/core';
import { EmptyStatus, Can, FormattedMessage as T } from '@/components';
import { AbilitySubject, BankRuleAction } from '@/constants/abilityOption';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
import styles from './BankRulesLandingEmptyState.module.scss';
function BankRulesLandingEmptyStateRoot({
// #withDialogAction
openDialog,
}) {
const handleNewBtnClick = () => {
openDialog(DialogsName.BankRuleForm);
};
return (
<EmptyStatus
title={"The organization doesn't have taxes, yet!"}
title={'Create rules to categorize bank transactions automatically'}
description={
<p>
Setup the organization taxes to start tracking taxes on sales
transactions.
Bank rules will run automatically to categorize the incoming bank
transactions under the conditions you set up.
</p>
}
action={
<>
<Can I={BankRuleAction.Create} a={AbilitySubject.BankRule}>
<Button intent={Intent.PRIMARY} large={true} onClick={() => {}}>
New tax rate
<Button
intent={Intent.PRIMARY}
large={true}
onClick={handleNewBtnClick}
>
New Bank Rule
</Button>
<Button intent={Intent.NONE} large={true}>
<T id={'learn_more'} />
</Button>
</Can>
</>
}
classNames={{ root: styles.root }}
/>
);
}

View File

@@ -1,10 +1,12 @@
import React, { createContext } from 'react';
import { DialogContent } from '@/components';
import { useBankRules } from '@/hooks/query/bank-rules';
import { isEmpty } from 'lodash';
interface RulesListBootValues {
bankRules: any;
isBankRulesLoading: boolean;
isEmptyState: boolean;
}
const RulesListBootContext = createContext<RulesListBootValues>(
@@ -18,9 +20,11 @@ interface RulesListBootProps {
function RulesListBoot({ ...props }: RulesListBootProps) {
const { data: bankRules, isLoading: isBankRulesLoading } = useBankRules();
const provider = { bankRules, isBankRulesLoading } as RulesListBootValues;
const isEmptyState = !isBankRulesLoading && isEmpty(bankRules);
const isLoading = isBankRulesLoading;
const provider = { bankRules, isBankRulesLoading, isEmptyState } as RulesListBootValues;
return (
<DialogContent isLoading={isLoading}>
<RulesListBootContext.Provider {...props} value={provider} />

View File

@@ -33,7 +33,7 @@ function RulesTable({
}) {
// Invoices table columns.
const columns = useBankRulesTableColumns();
const { bankRules } = useRulesListBoot();
const { bankRules, isEmptyState } = useRulesListBoot();
// Handle edit bank rule.
const handleDeleteBankRule = ({ id }) => {
@@ -45,8 +45,6 @@ function RulesTable({
openDialog(DialogsName.BankRuleForm, { bankRuleId: id });
};
const isEmptyState = false;
// Display invoice empty status instead of the table.
if (isEmptyState) {
return <BankRulesLandingEmptyState />;