feat: optmize style of payment receive details.

This commit is contained in:
a.bouhuolia
2021-12-20 14:33:48 +02:00
parent a0098382e7
commit ace3fdc569
8 changed files with 167 additions and 108 deletions

View File

@@ -40,10 +40,6 @@ export default function InvoiceGLEntriesTable() {
); );
} }
const InvoiceGLEntriesDatatable = styled(JournalEntriesTable)` const InvoiceGLEntriesDatatable = styled(JournalEntriesTable)``;
.table .tbody .tr:last-child .td {
border-bottom: 0;
}
`;
const InvoiceGLEntriesRoot = styled(Card)``; const InvoiceGLEntriesRoot = styled(Card)``;

View File

@@ -1,6 +1,5 @@
import React from 'react'; import React from 'react';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { import {
Button, Button,
NavbarGroup, NavbarGroup,
@@ -8,7 +7,6 @@ import {
NavbarDivider, NavbarDivider,
Intent, Intent,
} from '@blueprintjs/core'; } from '@blueprintjs/core';
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider'; import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider';
@@ -16,7 +14,13 @@ import withDialogActions from 'containers/Dialog/withDialogActions';
import withAlertsActions from 'containers/Alert/withAlertActions'; import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions'; import withDrawerActions from 'containers/Drawer/withDrawerActions';
import { Can, Icon, FormattedMessage as T, MoreMenuItems } from 'components'; import {
Can,
Icon,
FormattedMessage as T,
MoreMenuItems,
DrawerActionsBar,
} from 'components';
import { import {
PaymentReceiveAction, PaymentReceiveAction,
AbilitySubject, AbilitySubject,
@@ -59,7 +63,7 @@ function PaymentReceiveActionsBar({
}; };
return ( return (
<DashboardActionsBar> <DrawerActionsBar>
<NavbarGroup> <NavbarGroup>
<Can I={PaymentReceiveAction.Edit} a={AbilitySubject.PaymentReceive}> <Can I={PaymentReceiveAction.Edit} a={AbilitySubject.PaymentReceive}>
<Button <Button
@@ -80,7 +84,10 @@ function PaymentReceiveActionsBar({
/> />
<NavbarDivider /> <NavbarDivider />
</Can> </Can>
<Can I={PaymentReceiveAction.NotifyBySms} a={AbilitySubject.PaymentReceive}> <Can
I={PaymentReceiveAction.NotifyBySms}
a={AbilitySubject.PaymentReceive}
>
<MoreMenuItems <MoreMenuItems
payload={{ payload={{
onNotifyViaSMS: handleNotifyViaSMS, onNotifyViaSMS: handleNotifyViaSMS,
@@ -88,7 +95,7 @@ function PaymentReceiveActionsBar({
/> />
</Can> </Can>
</NavbarGroup> </NavbarGroup>
</DashboardActionsBar> </DrawerActionsBar>
); );
} }

View File

@@ -1,36 +1,46 @@
import React from 'react'; import React from 'react';
import { Tab } from '@blueprintjs/core'; import { Tab } from '@blueprintjs/core';
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import clsx from 'classnames'; import styled from 'styled-components';
import { DrawerMainTabs } from 'components'; import { DrawerMainTabs } from 'components';
import PaymentReceiveDetailTab from './PaymentReceiveDetailTab'; import PaymentReceiveDetailTab from './PaymentReceiveDetailTab';
import PaymentReceiveActionsBar from './PaymentReceiveActionsBar';
import { PaymentReceiveGLEntriesPanel } from './PaymentReceiveGLEntriesPanel';
import JournalEntriesTable from '../../JournalEntriesTable/JournalEntriesTable'; /**
import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider'; * Payment receive details tabs.
* @returns {React.JSX}
import PaymentDrawerCls from './PaymentReceiveDrawer.module.scss'; */
function PaymentReceiveDetailsTabs() {
return (
<DrawerMainTabs defaultSelectedTabId="details">
<Tab
id={'details'}
title={intl.get('details')}
panel={<PaymentReceiveDetailTab />}
/>
<Tab
id={'journal_entries'}
title={intl.get('journal_entries')}
panel={<PaymentReceiveGLEntriesPanel />}
/>
</DrawerMainTabs>
);
}
/** /**
* Payment receive view detail. * Payment receive view detail.
* @returns {React.JSX}
*/ */
export default function PaymentReceiveDetail() { export default function PaymentReceiveDetail() {
const { transactions } = usePaymentReceiveDetailContext();
return ( return (
<div className={clsx(PaymentDrawerCls.root)}> <PaymentReceiveDetailsRoot>
<DrawerMainTabs defaultSelectedTabId="details"> <PaymentReceiveActionsBar />
<Tab <PaymentReceiveDetailsTabs />
id={'details'} </PaymentReceiveDetailsRoot>
title={intl.get('details')}
panel={<PaymentReceiveDetailTab />}
/>
<Tab
id={'journal_entries'}
title={intl.get('journal_entries')}
panel={<JournalEntriesTable transactions={transactions} />}
/>
</DrawerMainTabs>
</div>
); );
} }
const PaymentReceiveDetailsRoot = styled.div``;

View File

@@ -1,13 +1,19 @@
import React from 'react'; import React from 'react';
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import clsx from 'classnames';
import { defaultTo } from 'lodash'; import { defaultTo } from 'lodash';
import { FormatDate, DetailsMenu, DetailItem } from 'components'; import {
Row,
Col,
FormatDate,
DetailsMenu,
DetailItem,
CommercialDocHeader,
CommercialDocTopHeader,
ButtonLink,
} from 'components';
import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider'; import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider';
import PaymentDrawerCls from './PaymentReceiveDrawer.module.scss';
/** /**
* Payment receive detail header. * Payment receive detail header.
*/ */
@@ -15,42 +21,54 @@ export default function PaymentReceiveDetailHeader() {
const { paymentReceive } = usePaymentReceiveDetailContext(); const { paymentReceive } = usePaymentReceiveDetailContext();
return ( return (
<div className={clsx(PaymentDrawerCls.detail_panel_header)}> <CommercialDocHeader>
<DetailsMenu> <CommercialDocTopHeader>
<DetailItem <DetailsMenu>
label={intl.get('amount')} <DetailItem label={intl.get('amount')}>
children={
<h3 class="big-number">{paymentReceive.formatted_amount}</h3> <h3 class="big-number">{paymentReceive.formatted_amount}</h3>
} </DetailItem>
/> </DetailsMenu>
<DetailItem </CommercialDocTopHeader>
label={intl.get('payment_receive.details.payment_number')}
children={defaultTo(paymentReceive.payment_receive_no, '-')}
/>
<DetailItem
label={intl.get('customer_name')}
children={paymentReceive.customer?.display_name}
/>
<DetailItem
label={intl.get('deposit_account')}
children={paymentReceive.deposit_account?.name}
/>
<DetailItem
label={intl.get('payment_date')}
children={<FormatDate value={paymentReceive.payment_date} />}
/>
</DetailsMenu>
<DetailsMenu direction={'horizantal'} minLabelSize={'140px'}> <Row>
<DetailItem <Col xs={6}>
label={intl.get('description')} <DetailsMenu direction={'horizantal'} minLabelSize={'180px'}>
children={defaultTo(paymentReceive.statement, '—')} <DetailItem
/> label={intl.get('payment_receive.details.payment_number')}
<DetailItem children={defaultTo(paymentReceive.payment_receive_no, '-')}
label={intl.get('created_at')} />
children={<FormatDate value={paymentReceive.created_at} />} <DetailItem label={intl.get('customer_name')}>
/> <ButtonLink>{paymentReceive.customer?.display_name}</ButtonLink>
</DetailsMenu> </DetailItem>
</div>
<DetailItem
label={intl.get('deposit_account')}
children={paymentReceive.deposit_account?.name}
/>
<DetailItem
label={intl.get('payment_date')}
children={<FormatDate value={paymentReceive.payment_date} />}
/>
</DetailsMenu>
</Col>
<Col xs={6}>
<DetailsMenu
textAlign={'right'}
direction={'horizantal'}
minLabelSize={'180px'}
>
<DetailItem
label={intl.get('description')}
children={defaultTo(paymentReceive.statement, '—')}
/>
<DetailItem
label={intl.get('created_at')}
children={<FormatDate value={paymentReceive.created_at} />}
/>
</DetailsMenu>
</Col>
</Row>
</CommercialDocHeader>
); );
} }

View File

@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import { DrawerHeaderContent, DrawerLoading } from 'components'; import { DrawerHeaderContent, DrawerLoading } from 'components';
import { useTransactionsByReference, usePaymentReceive } from 'hooks/query'; import { usePaymentReceive } from 'hooks/query';
const PaymentReceiveDetailContext = React.createContext(); const PaymentReceiveDetailContext = React.createContext();
@@ -9,6 +9,7 @@ const PaymentReceiveDetailContext = React.createContext();
* Payment receive detail provider. * Payment receive detail provider.
*/ */
function PaymentReceiveDetailProvider({ paymentReceiveId, ...props }) { function PaymentReceiveDetailProvider({ paymentReceiveId, ...props }) {
// Fetches specific payment receive details.
const { const {
data: paymentReceive, data: paymentReceive,
isLoading: isPaymentLoading, isLoading: isPaymentLoading,
@@ -17,28 +18,15 @@ function PaymentReceiveDetailProvider({ paymentReceiveId, ...props }) {
enabled: !!paymentReceiveId, enabled: !!paymentReceiveId,
}); });
// Handle fetch transaction by reference.
const {
data: { transactions },
isLoading: isTransactionLoading,
} = useTransactionsByReference(
{
reference_id: paymentReceiveId,
reference_type: 'paymentReceive',
},
{ enabled: !!paymentReceiveId },
);
// Provider. // Provider.
const provider = { const provider = {
isPaymentFetching, isPaymentFetching,
transactions,
paymentReceive, paymentReceive,
paymentReceiveId, paymentReceiveId,
}; };
return ( return (
<DrawerLoading loading={isTransactionLoading || isPaymentLoading}> <DrawerLoading loading={isPaymentLoading}>
<DrawerHeaderContent <DrawerHeaderContent
name="payment-receive-detail-drawer" name="payment-receive-detail-drawer"
title={intl.get('payment_receive_details')} title={intl.get('payment_receive_details')}

View File

@@ -1,25 +1,26 @@
import React from 'react'; import React from 'react';
import clsx from 'classnames'; import styled from 'styled-components';
import { Card } from 'components'; import { CommercialDocBox } from 'components';
import PaymentReceiveActionsBar from './PaymentReceiveActionsBar';
import PaymentReceiveDetailHeader from './PaymentReceiveDetailHeader'; import PaymentReceiveDetailHeader from './PaymentReceiveDetailHeader';
import PaymentReceiveDetailTable from './PaymentReceiveDetailTable'; import PaymentReceiveDetailTable from './PaymentReceiveDetailTable';
import PaymentReceiveDetailFooter from './PaymentReceiveDetailFooter'; import PaymentReceiveDetailFooter from './PaymentReceiveDetailFooter';
import PaymentDrawerCls from './PaymentReceiveDrawer.module.scss'; /**
* Payment receive - overview panel.
* @returns {React.JSX}
*/
export default function PaymentReceiveDetailTab() { export default function PaymentReceiveDetailTab() {
return ( return (
<div className={clsx(PaymentDrawerCls.detail_panel)}> <PaymentReceiveDetailsTabPanelRoot>
<PaymentReceiveActionsBar /> <CommercialDocBox>
<Card>
<PaymentReceiveDetailHeader /> <PaymentReceiveDetailHeader />
<PaymentReceiveDetailTable /> <PaymentReceiveDetailTable />
<PaymentReceiveDetailFooter /> <PaymentReceiveDetailFooter />
</Card> </CommercialDocBox>
</div> </PaymentReceiveDetailsTabPanelRoot>
); );
} }
const PaymentReceiveDetailsTabPanelRoot = styled.div``;

View File

@@ -1,12 +1,11 @@
import React from 'react'; import React from 'react';
import clsx from 'classnames';
import { CommercialDocEntriesTable } from 'components';
import { usePaymentReceiveEntriesColumns } from './utils'; import { usePaymentReceiveEntriesColumns } from './utils';
import { DataTable } from 'components';
import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider'; import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider';
import PaymentDrawerCls from './PaymentReceiveDrawer.module.scss'; import { TableStyle } from 'common';
/** /**
* Payment receive readonly details table. * Payment receive readonly details table.
@@ -19,12 +18,10 @@ export default function PaymentReceiveDetailTable() {
} = usePaymentReceiveDetailContext(); } = usePaymentReceiveDetailContext();
return ( return (
<div className={clsx(PaymentDrawerCls.detail_panel_table)}> <CommercialDocEntriesTable
<DataTable columns={columns}
columns={columns} data={entries}
data={entries} styleName={TableStyle.Constrant}
className={'table-constrant'} />
/>
</div>
); );
} }

View File

@@ -0,0 +1,42 @@
import React from 'react';
import styled from 'styled-components';
import { Card } from 'components';
import JournalEntriesTable, {
AmountDisplayedBaseCurrencyMessage,
} from '../../JournalEntriesTable/JournalEntriesTable';
import { useTransactionsByReference } from 'hooks/query';
import { usePaymentReceiveDetailContext } from './PaymentReceiveDetailProvider';
/**
* Payment receive GL entries table panel.
* @returns {React.JSX}
*/
export function PaymentReceiveGLEntriesPanel() {
const { paymentReceiveId } = usePaymentReceiveDetailContext();
// Handle fetch transaction by reference.
const {
data: { transactions },
isLoading: isTransactionsLoading,
} = useTransactionsByReference(
{
reference_id: paymentReceiveId,
reference_type: 'paymentReceive',
},
{ enabled: !!paymentReceiveId },
);
return (
<PaymentReceiveGLEntriesRoot>
<AmountDisplayedBaseCurrencyMessage />
<JournalEntriesTable
loading={isTransactionsLoading}
transactions={transactions}
/>
</PaymentReceiveGLEntriesRoot>
);
}
const PaymentReceiveGLEntriesRoot = styled(Card)``;