mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
68 lines
1.8 KiB
JavaScript
68 lines
1.8 KiB
JavaScript
import React, { useCallback, useMemo } from 'react';
|
|
import { useIntl } from 'react-intl';
|
|
|
|
import FinancialSheet from 'components/FinancialSheet';
|
|
import DataTable from 'components/DataTable';
|
|
import { useJournalSheetContext } from './JournalProvider';
|
|
|
|
import { defaultExpanderReducer } from 'utils';
|
|
import { useJournalTableColumns } from './components';
|
|
|
|
export default function JournalSheetTable({
|
|
// #ownProps
|
|
onFetchData,
|
|
companyName,
|
|
}) {
|
|
const { formatMessage } = useIntl();
|
|
|
|
// Journal sheet context.
|
|
const {
|
|
journalSheet: { tableRows, query },
|
|
isLoading
|
|
} = useJournalSheetContext();
|
|
|
|
// Retreive the journal table columns.
|
|
const columns = useJournalTableColumns();
|
|
|
|
// Default expanded rows of general journal table.
|
|
const expandedRows = useMemo(() => defaultExpanderReducer([], 1), []);
|
|
|
|
const rowClassNames = useCallback((row) => {
|
|
const { original } = row;
|
|
const rowTypes = Array.isArray(original.rowType)
|
|
? original.rowType
|
|
: [original.rowType];
|
|
|
|
return {
|
|
...rowTypes.reduce((acc, rowType) => {
|
|
acc[`row_type--${rowType}`] = rowType;
|
|
return acc;
|
|
}, {}),
|
|
};
|
|
}, []);
|
|
|
|
return (
|
|
<FinancialSheet
|
|
companyName={companyName}
|
|
sheetType={formatMessage({ id: 'journal_sheet' })}
|
|
fromDate={query.from_date}
|
|
toDate={query.to_date}
|
|
name="journal"
|
|
loading={isLoading}
|
|
// minimal={true}
|
|
fullWidth={true}
|
|
>
|
|
<DataTable
|
|
className="bigcapital-datatable--financial-report"
|
|
columns={columns}
|
|
data={tableRows}
|
|
rowClassNames={rowClassNames}
|
|
noResults={formatMessage({
|
|
id: 'this_report_does_not_contain_any_data_between_date_period',
|
|
})}
|
|
expanded={expandedRows}
|
|
sticky={true}
|
|
/>
|
|
</FinancialSheet>
|
|
);
|
|
} |