feat(webapp): add FCY/BCY switch to the account transactions

This commit is contained in:
a.bouhuolia
2023-04-19 06:15:13 +02:00
parent b2f3585047
commit 672a1bbb82
5 changed files with 153 additions and 54 deletions

View File

@@ -4,23 +4,24 @@ import intl from 'react-intl-universal';
import { Link } from 'react-router-dom';
import styled from 'styled-components';
import { compose } from '@/utils';
import { TableStyle } from '@/constants';
import { Card, DataTable, If } from '@/components';
import { AccountDrawerTableOptionsProvider } from './AccountDrawerTableOptionsProvider';
import { AccountDrawerTableHeader } from './AccountDrawerTableHeader';
import { useAccountReadEntriesColumns } from './utils';
import { useAppIntlContext } from '@/components/AppIntlProvider';
import { useAccountDrawerContext } from './AccountDrawerProvider';
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
import { compose } from '@/utils';
/**
* account drawer table.
*/
function AccountDrawerTable({ closeDrawer }) {
const { account, accounts, drawerName } = useAccountDrawerContext();
// Account read-only entries table columns.
const columns = useAccountReadEntriesColumns();
const { accounts, drawerName } = useAccountDrawerContext();
// Handle view more link click.
const handleLinkClick = () => {
@@ -31,27 +32,41 @@ function AccountDrawerTable({ closeDrawer }) {
return (
<Card>
<DataTable
columns={columns}
data={accounts}
payload={{ account }}
styleName={TableStyle.Constrant}
/>
<AccountDrawerTableOptionsProvider>
<AccountDrawerTableHeader />
<AccountDrawerDataTable />
<If condition={accounts.length > 0}>
<TableFooter>
<Link
to={`/financial-reports/general-ledger`}
onClick={handleLinkClick}
>
{isRTL ? '→' : '←'} {intl.get('view_more_transactions')}
</Link>
</TableFooter>
</If>
<If condition={accounts.length > 0}>
<TableFooter>
<Link
to={`/financial-reports/general-ledger`}
onClick={handleLinkClick}
>
{isRTL ? '→' : '←'} {intl.get('view_more_transactions')}
</Link>
</TableFooter>
</If>
</AccountDrawerTableOptionsProvider>
</Card>
);
}
function AccountDrawerDataTable() {
const { account, accounts } = useAccountDrawerContext();
// Account read-only entries table columns.
const columns = useAccountReadEntriesColumns();
return (
<DataTable
columns={columns}
data={accounts}
payload={{ account }}
styleName={TableStyle.Constrant}
/>
);
}
export default compose(withDrawerActions)(AccountDrawerTable);
const TableFooter = styled.div`