mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
feat: Optimize connect component props with redux store.
This commit is contained in:
@@ -6,5 +6,5 @@ export default function PreferencesPage() {
|
|||||||
<div class="preferences-page">
|
<div class="preferences-page">
|
||||||
<PreferencesSidebar />
|
<PreferencesSidebar />
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
divider: true
|
divider: true
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
import {connect} from 'react-redux';
|
|
||||||
import {
|
|
||||||
fetchBalanceSheet,
|
|
||||||
} from 'store/financialStatement/financialStatements.actions';
|
|
||||||
import {
|
|
||||||
getFinancialSheetIndexByQuery,
|
|
||||||
getFinancialSheet,
|
|
||||||
getFinancialSheetAccounts,
|
|
||||||
getFinancialSheetColumns,
|
|
||||||
getFinancialSheetQuery,
|
|
||||||
} from 'store/financialStatement/financialStatements.selectors';
|
|
||||||
|
|
||||||
|
|
||||||
export const mapStateToProps = (state, props) => ({
|
|
||||||
getBalanceSheetIndex: (query) => getFinancialSheetIndexByQuery(state.financialStatements.balanceSheet.sheets, query),
|
|
||||||
getBalanceSheet: (index) => getFinancialSheet(state.financialStatements.balanceSheet.sheets, index),
|
|
||||||
getBalanceSheetAccounts: (index) => getFinancialSheetAccounts(state.financialStatements.balanceSheet.sheets, index),
|
|
||||||
getBalanceSheetColumns:(index) => getFinancialSheetColumns(state.financialStatements.balanceSheet.sheets, index),
|
|
||||||
getBalanceSheetQuery: (index) => getFinancialSheetQuery(state.financialStatements.balanceSheet.sheets, index),
|
|
||||||
balanceSheetLoading: state.financialStatements.balanceSheet.loading,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const mapDispatchToProps = (dispatch) => ({
|
|
||||||
fetchBalanceSheet: (query = {}) => dispatch(fetchBalanceSheet({ query })),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps);
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import {connect} from 'react-redux';
|
|
||||||
import {
|
|
||||||
fetchBalanceSheet,
|
|
||||||
} from 'store/financialStatement/financialStatements.actions';
|
|
||||||
import {
|
|
||||||
getFinancialSheetIndexByQuery,
|
|
||||||
getFinancialSheet,
|
|
||||||
getFinancialSheetsAccounts,
|
|
||||||
getFinancialSheetsColumns,
|
|
||||||
} from 'store/financialStatement/financialStatements.selectors';
|
|
||||||
|
|
||||||
|
|
||||||
export const mapStateToProps = (state, props) => {
|
|
||||||
const sheetIndex = props.balanceSheetIndex;
|
|
||||||
|
|
||||||
return {
|
|
||||||
balanceSheetAccounts: props.getBalanceSheetAccounts(sheetIndex),
|
|
||||||
balanceSheetQuery: props.getBalanceSheetQuery(sheetIndex),
|
|
||||||
balanceSheetColumns: props.getBalanceSheetColumns(sheetIndex),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const mapDispatchToProps = (dispatch) => ({
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps);
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import {connect} from 'react-redux';
|
|
||||||
import {
|
|
||||||
fetchGeneralLedger,
|
|
||||||
fetchBalanceSheet,
|
|
||||||
} from 'store/financialStatement/financialStatements.actions';
|
|
||||||
import {
|
|
||||||
getBalanceSheetByQuery,
|
|
||||||
getBalanceSheetColumns,
|
|
||||||
getBalanceSheetIndexByQuery,
|
|
||||||
getBalanceSheetByIndex,
|
|
||||||
getBalanceSheetAssetsAccounts,
|
|
||||||
getBalanceSheetLiabilitiesAccounts,
|
|
||||||
getBalanceSheetQuery,
|
|
||||||
} from 'store/financialStatement/financialStatements.selectors';
|
|
||||||
|
|
||||||
export const mapStateToProps = (state, props) => ({
|
|
||||||
generalLedeger: state.financialStatements.generalLedger,
|
|
||||||
balanceSheets: state.financialStatements.balanceSheets,
|
|
||||||
|
|
||||||
getBalanceSheetByQuery: (query) => getBalanceSheetByQuery(state.financialStatements.balanceSheets, query),
|
|
||||||
getBalanceSheetColumns: (sheetIndex) => getBalanceSheetColumns(state.financialStatements.balanceSheets, sheetIndex),
|
|
||||||
getBalanceSheetIndexByQuery: (query) => getBalanceSheetIndexByQuery(state.financialStatements.balanceSheets, query),
|
|
||||||
getBalanceSheetByIndex: (sheetIndex) => getBalanceSheetByIndex(state.financialStatements.balanceSheets, sheetIndex),
|
|
||||||
|
|
||||||
getBalanceSheetAssetsAccounts: (sheetIndex) => getBalanceSheetAssetsAccounts(state.financialStatements.balanceSheets, sheetIndex),
|
|
||||||
getBalanceSheetLiabilitiesAccounts: (sheetIndex) => getBalanceSheetLiabilitiesAccounts(state.financialStatements.balanceSheets, sheetIndex),
|
|
||||||
|
|
||||||
getBalanceSheetQuery: (sheetIndex) => getBalanceSheetQuery(state.financialStatements.balanceSheets, sheetIndex),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const mapDispatchToProps = (dispatch) => ({
|
|
||||||
fetchGeneralLedger: (query = {}) => dispatch(fetchGeneralLedger({ query })),
|
|
||||||
fetchBalanceSheet: (query = {}) => dispatch(fetchBalanceSheet({ query })),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps);
|
|
||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
getFinancialSheet,
|
getFinancialSheet,
|
||||||
} from 'store/financialStatement/financialStatements.selectors';
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
|
||||||
|
|
||||||
export const mapStateToProps = (state, props) => ({
|
export const mapStateToProps = (state, props) => ({
|
||||||
getJournalSheetIndex: (query) => getFinancialSheetIndexByQuery(state.financialStatements.journal.sheets, query),
|
getJournalSheetIndex: (query) => getFinancialSheetIndexByQuery(state.financialStatements.journal.sheets, query),
|
||||||
getJournalSheet: (index) => getFinancialSheet(state.financialStatements.journal.sheets, index),
|
getJournalSheet: (index) => getFinancialSheet(state.financialStatements.journal.sheets, index),
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
import {connect} from 'react-redux';
|
|
||||||
import {
|
|
||||||
fetchProfitLossSheet,
|
|
||||||
} from 'store/financialStatement/financialStatements.actions';
|
|
||||||
import {
|
|
||||||
getFinancialSheetIndexByQuery,
|
|
||||||
getFinancialSheet,
|
|
||||||
getFinancialSheetColumns,
|
|
||||||
getFinancialSheetQuery,
|
|
||||||
getFinancialSheetTableRows,
|
|
||||||
} from 'store/financialStatement/financialStatements.selectors';
|
|
||||||
|
|
||||||
export const mapStateToProps = (state, props) => ({
|
|
||||||
getProfitLossSheetIndex: (query) => getFinancialSheetIndexByQuery(state.financialStatements.profitLoss.sheets, query),
|
|
||||||
getProfitLossSheet: (index) => getFinancialSheet(state.financialStatements.profitLoss.sheets, index),
|
|
||||||
getProfitLossColumns: (index) => getFinancialSheetColumns(state.financialStatements.profitLoss.sheets, index),
|
|
||||||
getProfitLossQuery: (index) => getFinancialSheetQuery(state.financialStatements.profitLoss.sheets, index),
|
|
||||||
getProfitLossTableRows: (index) => getFinancialSheetTableRows(state.financialStatements.profitLoss.sheets, index),
|
|
||||||
|
|
||||||
profitLossSheetLoading: state.financialStatements.profitLoss.loading,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const mapDispatchToProps = (dispatch) => ({
|
|
||||||
fetchProfitLossSheet: (query = {}) => dispatch(fetchProfitLossSheet({ query })),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps);
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import {connect} from 'react-redux';
|
|
||||||
|
|
||||||
export const mapStateToProps = (state, props) => {
|
|
||||||
const sheetIndex = props.profitLossSheetIndex;
|
|
||||||
|
|
||||||
return {
|
|
||||||
profitLossTableRows: props.getProfitLossTableRows(sheetIndex),
|
|
||||||
profitLossColumns: props.getProfitLossColumns(sheetIndex),
|
|
||||||
profitLossQuery: props.getProfitLossQuery(sheetIndex),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const mapDispatchToProps = (dispatch) => ({
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps);
|
|
||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
getFinancialSheetQuery,
|
getFinancialSheetQuery,
|
||||||
} from 'store/financialStatement/financialStatements.selectors';
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
|
||||||
|
|
||||||
export const mapStateToProps = (state, props) => ({
|
export const mapStateToProps = (state, props) => ({
|
||||||
getTrialBalanceSheetIndex: (query) => getFinancialSheetIndexByQuery(state.financialStatements.trialBalance.sheets, query),
|
getTrialBalanceSheetIndex: (query) => getFinancialSheetIndexByQuery(state.financialStatements.trialBalance.sheets, query),
|
||||||
getTrialBalanceAccounts: (sheetIndex) => getFinancialSheetAccounts(state.financialStatements.trialBalance.sheets, sheetIndex),
|
getTrialBalanceAccounts: (sheetIndex) => getFinancialSheetAccounts(state.financialStatements.trialBalance.sheets, sheetIndex),
|
||||||
|
|||||||
@@ -23,12 +23,15 @@ import {compose} from 'utils';
|
|||||||
|
|
||||||
|
|
||||||
function MakeJournalEntriesForm({
|
function MakeJournalEntriesForm({
|
||||||
|
// #withMedia
|
||||||
requestSubmitMedia,
|
requestSubmitMedia,
|
||||||
requestDeleteMedia,
|
requestDeleteMedia,
|
||||||
|
|
||||||
|
// #withJournalsActions
|
||||||
requestMakeJournalEntries,
|
requestMakeJournalEntries,
|
||||||
requestEditManualJournal,
|
requestEditManualJournal,
|
||||||
|
|
||||||
|
// #withDashboard
|
||||||
changePageTitle,
|
changePageTitle,
|
||||||
changePageSubtitle,
|
changePageSubtitle,
|
||||||
|
|
||||||
@@ -252,8 +255,6 @@ function MakeJournalEntriesForm({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
// ManualJournalsConnect,
|
|
||||||
// MakeJournalEntriesConnect,
|
|
||||||
withJournalsActions,
|
withJournalsActions,
|
||||||
withManualJournalDetail,
|
withManualJournalDetail,
|
||||||
withAccountsActions,
|
withAccountsActions,
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ function MakeJournalEntriesPage({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
// DashboardConnect,
|
|
||||||
withAccountsActions,
|
withAccountsActions,
|
||||||
withManualJournalsActions,
|
withManualJournalsActions,
|
||||||
)(MakeJournalEntriesPage);
|
)(MakeJournalEntriesPage);
|
||||||
@@ -76,13 +76,16 @@ const NoteCellRenderer = (chainedComponent) => (props) => {
|
|||||||
/**
|
/**
|
||||||
* Make journal entries table component.
|
* Make journal entries table component.
|
||||||
*/
|
*/
|
||||||
function MakeJournalEntriesTable({
|
function MakeJournalEntriesTable({
|
||||||
formik: { errors, values, setFieldValue },
|
// #withAccounts
|
||||||
accounts,
|
accounts,
|
||||||
|
|
||||||
|
// #ownPorps
|
||||||
onClickRemoveRow,
|
onClickRemoveRow,
|
||||||
onClickAddNewRow,
|
onClickAddNewRow,
|
||||||
defaultRow,
|
defaultRow,
|
||||||
initialValues,
|
initialValues,
|
||||||
|
formik: { errors, values, setFieldValue },
|
||||||
}) {
|
}) {
|
||||||
const [rows, setRow] = useState([]);
|
const [rows, setRow] = useState([]);
|
||||||
|
|
||||||
@@ -226,5 +229,7 @@ function MakeJournalEntriesTable({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
withAccounts,
|
withAccounts(({ accounts }) => ({
|
||||||
|
accounts,
|
||||||
|
})),
|
||||||
)(MakeJournalEntriesTable);
|
)(MakeJournalEntriesTable);
|
||||||
@@ -14,10 +14,12 @@ import {
|
|||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useRouteMatch, useHistory } from 'react-router-dom';
|
import { useRouteMatch, useHistory } from 'react-router-dom';
|
||||||
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
import FilterDropdown from 'components/FilterDropdown';
|
||||||
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||||
import DialogConnect from 'connectors/Dialog.connector';
|
import DialogConnect from 'connectors/Dialog.connector';
|
||||||
import { compose } from 'utils';
|
import { If } from 'components';
|
||||||
import FilterDropdown from 'components/FilterDropdown';
|
|
||||||
|
|
||||||
import withResourceDetail from 'containers/Resources/withResourceDetails';
|
import withResourceDetail from 'containers/Resources/withResourceDetails';
|
||||||
import withManualJournals from 'containers/Accounting/withManualJournals';
|
import withManualJournals from 'containers/Accounting/withManualJournals';
|
||||||
@@ -25,10 +27,14 @@ import withManualJournalsActions from 'containers/Accounting/withManualJournalsA
|
|||||||
|
|
||||||
|
|
||||||
function ManualJournalActionsBar({
|
function ManualJournalActionsBar({
|
||||||
|
// #withResourceDetail
|
||||||
resourceName = 'manual_journal',
|
resourceName = 'manual_journal',
|
||||||
resourceFields,
|
resourceFields,
|
||||||
|
|
||||||
|
// #withManualJournals
|
||||||
manualJournalsViews,
|
manualJournalsViews,
|
||||||
|
|
||||||
|
// #withManualJournalsActions
|
||||||
addManualJournalsTableQueries,
|
addManualJournalsTableQueries,
|
||||||
|
|
||||||
onFilterChanged,
|
onFilterChanged,
|
||||||
@@ -80,7 +86,9 @@ function ManualJournalActionsBar({
|
|||||||
rightIcon={'caret-down'}
|
rightIcon={'caret-down'}
|
||||||
/>
|
/>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|
||||||
<NavbarDivider />
|
<NavbarDivider />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon='plus' />}
|
icon={<Icon icon='plus' />}
|
||||||
@@ -99,7 +107,7 @@ function ManualJournalActionsBar({
|
|||||||
/>
|
/>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|
||||||
{(hasSelectedRows) && (
|
<If condition={hasSelectedRows}>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon='trash' iconSize={15} />}
|
icon={<Icon icon='trash' iconSize={15} />}
|
||||||
@@ -107,7 +115,8 @@ function ManualJournalActionsBar({
|
|||||||
intent={Intent.DANGER}
|
intent={Intent.DANGER}
|
||||||
onClick={handleBulkDelete}
|
onClick={handleBulkDelete}
|
||||||
/>
|
/>
|
||||||
)}
|
</If>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon icon='file-import' />}
|
icon={<Icon icon='file-import' />}
|
||||||
@@ -125,7 +134,11 @@ function ManualJournalActionsBar({
|
|||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
DialogConnect,
|
DialogConnect,
|
||||||
withResourceDetail,
|
withResourceDetail(({ resourceFields }) => ({
|
||||||
withManualJournals,
|
resourceFields,
|
||||||
|
})),
|
||||||
|
withManualJournals(({ manualJournalsViews }) => ({
|
||||||
|
manualJournalsViews,
|
||||||
|
})),
|
||||||
withManualJournalsActions,
|
withManualJournalsActions,
|
||||||
)(ManualJournalActionsBar);
|
)(ManualJournalActionsBar);
|
||||||
|
|||||||
@@ -202,6 +202,9 @@ export default compose(
|
|||||||
withDashboardActions,
|
withDashboardActions,
|
||||||
// withViewsActions,
|
// withViewsActions,
|
||||||
withManualJournalsActions,
|
withManualJournalsActions,
|
||||||
withManualJournals,
|
withManualJournals(({ manualJournals, manualJournalsLoading, }) => ({
|
||||||
|
manualJournals,
|
||||||
|
manualJournalsLoading,
|
||||||
|
})),
|
||||||
withViewDetails,
|
withViewDetails,
|
||||||
)(ManualJournalsDataTable);
|
)(ManualJournalsDataTable);
|
||||||
|
|||||||
@@ -22,15 +22,17 @@ import { compose } from 'utils';
|
|||||||
* Manual journals table.
|
* Manual journals table.
|
||||||
*/
|
*/
|
||||||
function ManualJournalsTable({
|
function ManualJournalsTable({
|
||||||
|
// #withDashboardActions
|
||||||
changePageTitle,
|
changePageTitle,
|
||||||
|
|
||||||
|
// #withViewsActions
|
||||||
requestFetchResourceViews,
|
requestFetchResourceViews,
|
||||||
|
|
||||||
|
// #withManualJournalsActions
|
||||||
requestFetchManualJournalsTable,
|
requestFetchManualJournalsTable,
|
||||||
requestDeleteManualJournal,
|
requestDeleteManualJournal,
|
||||||
requestPublishManualJournal,
|
requestPublishManualJournal,
|
||||||
requestDeleteBulkManualJournals,
|
requestDeleteBulkManualJournals,
|
||||||
|
|
||||||
addManualJournalsTableQueries,
|
addManualJournalsTableQueries,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@@ -141,8 +143,7 @@ function ManualJournalsTable({
|
|||||||
'/dashboard/accounting/manual-journals/:custom_view_id/custom_view',
|
'/dashboard/accounting/manual-journals/:custom_view_id/custom_view',
|
||||||
'/dashboard/accounting/manual-journals',
|
'/dashboard/accounting/manual-journals',
|
||||||
]}>
|
]}>
|
||||||
<ManualJournalsViewTabs
|
|
||||||
onViewChanged={handleViewChanged} />
|
|
||||||
</Route>
|
</Route>
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|
||||||
|
|||||||
@@ -12,15 +12,26 @@ import { useParams } from 'react-router-dom';
|
|||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
import ManualJournalsConnect from 'connectors/ManualJournals.connect';
|
|
||||||
import DashboardConnect from 'connectors/Dashboard.connector';
|
|
||||||
import { useUpdateEffect } from 'hooks';
|
import { useUpdateEffect } from 'hooks';
|
||||||
|
|
||||||
|
import withManualJournals from './withManualJournals';
|
||||||
|
import withManualJournalsActions from './withManualJournalsActions';
|
||||||
|
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||||
|
|
||||||
|
|
||||||
function ManualJournalsViewTabs({
|
function ManualJournalsViewTabs({
|
||||||
views,
|
// #withManualJournals
|
||||||
setTopbarEditView,
|
manualJournalsViews,
|
||||||
customViewChanged,
|
|
||||||
|
// #withManualJournalsActions
|
||||||
addManualJournalsTableQueries,
|
addManualJournalsTableQueries,
|
||||||
|
|
||||||
|
// #withDashboard
|
||||||
|
setTopbarEditView,
|
||||||
|
|
||||||
|
// #ownProps
|
||||||
|
customViewChanged,
|
||||||
onViewChanged,
|
onViewChanged,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@@ -49,7 +60,7 @@ function ManualJournalsViewTabs({
|
|||||||
});
|
});
|
||||||
}, [customViewId]);
|
}, [customViewId]);
|
||||||
|
|
||||||
const tabs = views.map((view) => {
|
const tabs = manualJournalsViews.map((view) => {
|
||||||
const baseUrl = '/dashboard/accounting/manual-journals';
|
const baseUrl = '/dashboard/accounting/manual-journals';
|
||||||
const link = (
|
const link = (
|
||||||
<Link
|
<Link
|
||||||
@@ -91,6 +102,9 @@ function ManualJournalsViewTabs({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
ManualJournalsConnect,
|
withManualJournals(({ manualJournalsViews }) => ({
|
||||||
DashboardConnect
|
manualJournalsViews,
|
||||||
|
})),
|
||||||
|
withManualJournalsActions,
|
||||||
|
withDashboard
|
||||||
)(ManualJournalsViewTabs);
|
)(ManualJournalsViewTabs);
|
||||||
|
|||||||
@@ -4,13 +4,17 @@ import {
|
|||||||
getManualJournalsItems,
|
getManualJournalsItems,
|
||||||
} from 'store/manualJournals/manualJournals.selectors'
|
} from 'store/manualJournals/manualJournals.selectors'
|
||||||
|
|
||||||
|
export default (mapState) => {
|
||||||
const mapStateToProps = (state, props) => ({
|
const mapStateToProps = (state, props) => {
|
||||||
manualJournals: getManualJournalsItems(state, state.manualJournals.currentViewId),
|
const mapped = {
|
||||||
manualJournalsViews: getResourceViews(state, 'manual_journals'),
|
manualJournals: getManualJournalsItems(state, state.manualJournals.currentViewId),
|
||||||
manualJournalsItems: state.manualJournals.items,
|
manualJournalsViews: getResourceViews(state, 'manual_journals'),
|
||||||
manualJournalsTableQuery: state.manualJournals.tableQuery,
|
manualJournalsItems: state.manualJournals.items,
|
||||||
manualJournalsLoading: state.manualJournals.loading,
|
manualJournalsTableQuery: state.manualJournals.tableQuery,
|
||||||
});
|
manualJournalsLoading: state.manualJournals.loading,
|
||||||
|
};
|
||||||
export default connect(mapStateToProps);
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
|
};
|
||||||
|
|
||||||
|
return connect(mapStateToProps);
|
||||||
|
};
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ function AccountsActionsBar({
|
|||||||
openDialog,
|
openDialog,
|
||||||
accountsViews,
|
accountsViews,
|
||||||
|
|
||||||
|
// #withResourceDetail
|
||||||
resourceFields,
|
resourceFields,
|
||||||
|
|
||||||
|
// #withAccountsActions
|
||||||
addAccountsTableQueries,
|
addAccountsTableQueries,
|
||||||
|
|
||||||
selectedRows = [],
|
selectedRows = [],
|
||||||
@@ -151,7 +154,11 @@ const withAccountsActionsBar = connect(mapStateToProps);
|
|||||||
export default compose(
|
export default compose(
|
||||||
withAccountsActionsBar,
|
withAccountsActionsBar,
|
||||||
DialogConnect,
|
DialogConnect,
|
||||||
withAccounts,
|
withAccounts(({ accountsViews }) => ({
|
||||||
withResourceDetail,
|
accountsViews,
|
||||||
|
})),
|
||||||
|
withResourceDetail(({ resourceFields }) => ({
|
||||||
|
resourceFields,
|
||||||
|
})),
|
||||||
withAccountsTableActions,
|
withAccountsTableActions,
|
||||||
)(AccountsActionsBar);
|
)(AccountsActionsBar);
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ function AccountsChart({
|
|||||||
|
|
||||||
// Fetch accounts list according to the given custom view id.
|
// Fetch accounts list according to the given custom view id.
|
||||||
const fetchAccountsHook = useQuery(['accounts-table', accountsTableQuery],
|
const fetchAccountsHook = useQuery(['accounts-table', accountsTableQuery],
|
||||||
() => requestFetchAccountsTable());
|
() => requestFetchAccountsTable(),
|
||||||
|
{ refetchInterval: 3000 });
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
changePageTitle('Chart of Accounts');
|
changePageTitle('Chart of Accounts');
|
||||||
@@ -262,6 +263,7 @@ export default compose(
|
|||||||
withViewsActions,
|
withViewsActions,
|
||||||
withResourceActions,
|
withResourceActions,
|
||||||
withDashboardActions,
|
withDashboardActions,
|
||||||
|
withAccounts(({ accountsTableQuery }) => ({
|
||||||
withAccounts,
|
accountsTableQuery,
|
||||||
|
})),
|
||||||
)(AccountsChart);
|
)(AccountsChart);
|
||||||
@@ -21,14 +21,13 @@ import withDashboardActions from 'containers/Dashboard/withDashboard';
|
|||||||
import withAccountsActions from 'containers/Accounts/withAccountsActions';
|
import withAccountsActions from 'containers/Accounts/withAccountsActions';
|
||||||
import withAccounts from 'containers/Accounts/withAccounts';
|
import withAccounts from 'containers/Accounts/withAccounts';
|
||||||
|
|
||||||
import {If} from 'components';
|
|
||||||
|
|
||||||
function AccountsDataTable({
|
function AccountsDataTable({
|
||||||
// # withAccounts
|
// #withAccounts
|
||||||
accounts,
|
accounts,
|
||||||
accountsLoading,
|
accountsLoading,
|
||||||
|
|
||||||
// # withDialog.
|
// #withDialog.
|
||||||
openDialog,
|
openDialog,
|
||||||
|
|
||||||
// own properties
|
// own properties
|
||||||
@@ -164,9 +163,6 @@ function AccountsDataTable({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<LoadingIndicator loading={loading} mount={false}>
|
<LoadingIndicator loading={loading} mount={false}>
|
||||||
<If condition={loading}>
|
|
||||||
asdasdsadsa
|
|
||||||
</If>
|
|
||||||
<DataTable
|
<DataTable
|
||||||
noInitialFetch={true}
|
noInitialFetch={true}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
@@ -187,5 +183,8 @@ export default compose(
|
|||||||
DialogConnect,
|
DialogConnect,
|
||||||
withDashboardActions,
|
withDashboardActions,
|
||||||
withAccountsActions,
|
withAccountsActions,
|
||||||
withAccounts,
|
withAccounts(({ accountsLoading, accounts }) => ({
|
||||||
|
accountsLoading,
|
||||||
|
accounts,
|
||||||
|
})),
|
||||||
)(AccountsDataTable);
|
)(AccountsDataTable);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import withAccounts from 'containers/Accounts/withAccounts';
|
|||||||
import withAccountsTableActions from 'containers/Accounts/withAccountsTableActions';
|
import withAccountsTableActions from 'containers/Accounts/withAccountsTableActions';
|
||||||
import withViewDetail from 'containers/Views/withViewDetails';
|
import withViewDetail from 'containers/Views/withViewDetails';
|
||||||
|
|
||||||
|
|
||||||
function AccountsViewsTabs({
|
function AccountsViewsTabs({
|
||||||
// #withViewDetail
|
// #withViewDetail
|
||||||
viewId,
|
viewId,
|
||||||
@@ -63,7 +64,6 @@ function AccountsViewsTabs({
|
|||||||
onViewChanged && onViewChanged(customViewId);
|
onViewChanged && onViewChanged(customViewId);
|
||||||
}, [customViewId]);
|
}, [customViewId]);
|
||||||
|
|
||||||
|
|
||||||
// Handle click a new view tab.
|
// Handle click a new view tab.
|
||||||
const handleClickNewView = () => {
|
const handleClickNewView = () => {
|
||||||
setTopbarEditView(null);
|
setTopbarEditView(null);
|
||||||
@@ -115,7 +115,6 @@ function AccountsViewsTabs({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => ({
|
const mapStateToProps = (state, ownProps) => ({
|
||||||
|
|
||||||
// Mapping view id from matched route params.
|
// Mapping view id from matched route params.
|
||||||
viewId: ownProps.match.params.custom_view_id,
|
viewId: ownProps.match.params.custom_view_id,
|
||||||
});
|
});
|
||||||
@@ -126,7 +125,9 @@ export default compose(
|
|||||||
withRouter,
|
withRouter,
|
||||||
withAccountsViewsTabs,
|
withAccountsViewsTabs,
|
||||||
withDashboard,
|
withDashboard,
|
||||||
withAccounts,
|
withAccounts(({ accountsViews }) => ({
|
||||||
|
accountsViews,
|
||||||
|
})),
|
||||||
withAccountsTableActions,
|
withAccountsTableActions,
|
||||||
withViewDetail
|
withViewDetail
|
||||||
)(AccountsViewsTabs);
|
)(AccountsViewsTabs);
|
||||||
|
|||||||
@@ -6,14 +6,20 @@ import {
|
|||||||
getResourceViews,
|
getResourceViews,
|
||||||
} from 'store/customViews/customViews.selectors';
|
} from 'store/customViews/customViews.selectors';
|
||||||
|
|
||||||
const mapStateToProps = (state, props) => ({
|
|
||||||
accountsViews: getResourceViews(state, 'accounts'),
|
|
||||||
accounts: getAccountsItems(state, state.accounts.currentViewId),
|
|
||||||
accountsTypes: state.accounts.accountsTypes,
|
|
||||||
|
|
||||||
accountsTableQuery: state.accounts.tableQuery,
|
export default (mapState) => {
|
||||||
accountsLoading: state.accounts.loading,
|
const mapStateToProps = (state, props) => {
|
||||||
accountErrors: state.accounts.errors,
|
const mapped = {
|
||||||
});
|
accountsViews: getResourceViews(state, 'accounts'),
|
||||||
|
accounts: getAccountsItems(state, state.accounts.currentViewId),
|
||||||
export default connect(mapStateToProps);
|
accountsTypes: state.accounts.accountsTypes,
|
||||||
|
|
||||||
|
accountsTableQuery: state.accounts.tableQuery,
|
||||||
|
accountsLoading: state.accounts.loading,
|
||||||
|
accountErrors: state.accounts.errors,
|
||||||
|
};
|
||||||
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
|
};
|
||||||
|
|
||||||
|
return connect(mapStateToProps);
|
||||||
|
};
|
||||||
@@ -24,7 +24,10 @@ export default compose(
|
|||||||
AccountFormDialogConnect,
|
AccountFormDialogConnect,
|
||||||
withAccountsActions,
|
withAccountsActions,
|
||||||
withAccountDetail,
|
withAccountDetail,
|
||||||
withAccounts,
|
withAccounts(({ accountsTypes, accounts }) => ({
|
||||||
|
accountsTypes,
|
||||||
|
accounts,
|
||||||
|
})),
|
||||||
DialogReduxConnect,
|
DialogReduxConnect,
|
||||||
DialogConnect,
|
DialogConnect,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import * as Yup from 'yup';
|
|||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import { useFormik } from 'formik';
|
import { useFormik } from 'formik';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
import { useQuery } from 'react-query';
|
import { useQuery, queryCache } from 'react-query';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import AppToaster from 'components/AppToaster';
|
import AppToaster from 'components/AppToaster';
|
||||||
@@ -73,7 +73,16 @@ function ItemCategoryDialog({
|
|||||||
}), []);
|
}), []);
|
||||||
|
|
||||||
// Formik
|
// Formik
|
||||||
const formik = useFormik({
|
const {
|
||||||
|
errors,
|
||||||
|
values,
|
||||||
|
touched,
|
||||||
|
setFieldValue,
|
||||||
|
handleSubmit,
|
||||||
|
resetForm,
|
||||||
|
getFieldProps,
|
||||||
|
isSubmitting,
|
||||||
|
} = useFormik({
|
||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
initialValues: {
|
initialValues: {
|
||||||
...(payload.action === 'edit' &&
|
...(payload.action === 'edit' &&
|
||||||
@@ -85,9 +94,11 @@ function ItemCategoryDialog({
|
|||||||
requestEditItemCategory(payload.id, values).then(response => {
|
requestEditItemCategory(payload.id, values).then(response => {
|
||||||
closeDialog(name);
|
closeDialog(name);
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: 'the_category_has_been_edited'
|
message: 'the_category_has_been_edited',
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
});
|
});
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
|
queryCache.refetchQueries('items-categories-table', { force: true });
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
});
|
});
|
||||||
@@ -96,9 +107,11 @@ function ItemCategoryDialog({
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
closeDialog(name);
|
closeDialog(name);
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: 'the_category_has_been_submit'
|
message: 'the_category_has_been_submit',
|
||||||
|
intent: Intent.SUCCESS,
|
||||||
});
|
});
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
|
queryCache.refetchQueries('items-categories-table', { force: true });
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
@@ -106,7 +119,6 @@ function ItemCategoryDialog({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const { values, errors, touched } = useMemo(() => formik, [formik]);
|
|
||||||
|
|
||||||
const filterItemCategory = useCallback((query, category, _index, exactMatch) => {
|
const filterItemCategory = useCallback((query, category, _index, exactMatch) => {
|
||||||
const normalizedTitle = category.name.toLowerCase();
|
const normalizedTitle = category.name.toLowerCase();
|
||||||
@@ -135,13 +147,13 @@ function ItemCategoryDialog({
|
|||||||
|
|
||||||
const onChangeParentCategory = useCallback((parentCategory) => {
|
const onChangeParentCategory = useCallback((parentCategory) => {
|
||||||
setParentCategory(parentCategory);
|
setParentCategory(parentCategory);
|
||||||
formik.setFieldValue('parent_category_id', parentCategory.id);
|
setFieldValue('parent_category_id', parentCategory.id);
|
||||||
}, [formik]);
|
}, [setFieldValue]);
|
||||||
|
|
||||||
const onDialogClosed = useCallback(() => {
|
const onDialogClosed = useCallback(() => {
|
||||||
formik.resetForm();
|
resetForm();
|
||||||
closeDialog(name);
|
closeDialog(name);
|
||||||
}, [formik, closeDialog, name]);
|
}, [resetForm, closeDialog, name]);
|
||||||
|
|
||||||
const requiredSpan = useMemo(() => (<span class="required">*</span>), []);
|
const requiredSpan = useMemo(() => (<span class="required">*</span>), []);
|
||||||
const infoIcon = useMemo(() => (<Icon icon="info-circle" iconSize={12} />), []);
|
const infoIcon = useMemo(() => (<Icon icon="info-circle" iconSize={12} />), []);
|
||||||
@@ -161,20 +173,20 @@ function ItemCategoryDialog({
|
|||||||
isLoading={fetchList.isFetching}
|
isLoading={fetchList.isFetching}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
>
|
>
|
||||||
<form onSubmit={formik.handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<div className={Classes.DIALOG_BODY}>
|
<div className={Classes.DIALOG_BODY}>
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={'Category Name'}
|
label={'Category Name'}
|
||||||
labelInfo={requiredSpan}
|
labelInfo={requiredSpan}
|
||||||
className={'form-group--category-name'}
|
className={'form-group--category-name'}
|
||||||
intent={(errors.name && touched.name) && Intent.DANGER}
|
intent={(errors.name && touched.name) && Intent.DANGER}
|
||||||
helperText={(<ErrorMessage name="name" {...formik} />)}
|
helperText={(<ErrorMessage name="name" {...{ errors, touched }} />)}
|
||||||
inline={true}
|
inline={true}
|
||||||
>
|
>
|
||||||
<InputGroup
|
<InputGroup
|
||||||
medium={true}
|
medium={true}
|
||||||
intent={(errors.name && touched.name) && Intent.DANGER}
|
intent={(errors.name && touched.name) && Intent.DANGER}
|
||||||
{...formik.getFieldProps('name')}
|
{...getFieldProps('name')}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|
||||||
@@ -187,7 +199,7 @@ function ItemCategoryDialog({
|
|||||||
Classes.FILL,
|
Classes.FILL,
|
||||||
)}
|
)}
|
||||||
inline={true}
|
inline={true}
|
||||||
helperText={(<ErrorMessage name="parent_category_id" {...formik} />)}
|
helperText={(<ErrorMessage name="parent_category_id" {...{errors, touched}} />)}
|
||||||
intent={(errors.parent_category_id && touched.parent_category_id) && Intent.DANGER}
|
intent={(errors.parent_category_id && touched.parent_category_id) && Intent.DANGER}
|
||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
@@ -210,20 +222,21 @@ function ItemCategoryDialog({
|
|||||||
label={'Description'}
|
label={'Description'}
|
||||||
className={'form-group--description'}
|
className={'form-group--description'}
|
||||||
intent={(errors.description && touched.description) && Intent.DANGER}
|
intent={(errors.description && touched.description) && Intent.DANGER}
|
||||||
helperText={(<ErrorMessage name="description" {...formik} />)}
|
helperText={(<ErrorMessage name="description" {...{errors, touched}} />)}
|
||||||
inline={true}
|
inline={true}
|
||||||
>
|
>
|
||||||
<TextArea
|
<TextArea
|
||||||
growVertically={true}
|
growVertically={true}
|
||||||
large={true}
|
large={true}
|
||||||
{...formik.getFieldProps('description')}
|
{...getFieldProps('description')}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={Classes.DIALOG_FOOTER}>
|
<div className={Classes.DIALOG_FOOTER}>
|
||||||
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||||
<Button onClick={handleClose}>Close</Button>
|
<Button onClick={handleClose}>Close</Button>
|
||||||
<Button intent={Intent.PRIMARY} type='submit'>
|
<Button intent={Intent.PRIMARY} type='submit' disabled={isSubmitting}>
|
||||||
{payload.action === 'edit' ? 'Edit' : 'Submit'}
|
{payload.action === 'edit' ? 'Edit' : 'Submit'}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -238,7 +251,7 @@ const mapStateToProps = (state, props) => {
|
|||||||
const dialogPayload = getDialogPayload(state, 'item-category-form');
|
const dialogPayload = getDialogPayload(state, 'item-category-form');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: 'account-form',
|
name: 'item-category-form',
|
||||||
payload: {action: 'new', id: null, ...dialogPayload},
|
payload: {action: 'new', id: null, ...dialogPayload},
|
||||||
|
|
||||||
itemCategoryId: dialogPayload?.id || null,
|
itemCategoryId: dialogPayload?.id || null,
|
||||||
@@ -248,10 +261,12 @@ const mapStateToProps = (state, props) => {
|
|||||||
const withItemCategoryDialog = connect(mapStateToProps);
|
const withItemCategoryDialog = connect(mapStateToProps);
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
|
withItemCategoryDialog,
|
||||||
DialogConnect,
|
DialogConnect,
|
||||||
DialogReduxConnect,
|
DialogReduxConnect,
|
||||||
withItemCategoryDialog,
|
|
||||||
withItemCategoryDetail,
|
withItemCategoryDetail,
|
||||||
withItemCategories,
|
withItemCategories(({ categoriesList }) => ({
|
||||||
|
categoriesList
|
||||||
|
})),
|
||||||
withItemCategoriesActions
|
withItemCategoriesActions
|
||||||
)(ItemCategoryDialog);
|
)(ItemCategoryDialog);
|
||||||
|
|||||||
@@ -1,23 +1,34 @@
|
|||||||
import React, {useEffect, useMemo, useCallback, useState} from 'react';
|
import React, {useEffect, useMemo, useCallback, useState} from 'react';
|
||||||
import DashboardConnect from 'connectors/Dashboard.connector';
|
|
||||||
import {compose} from 'utils';
|
import {compose} from 'utils';
|
||||||
import useAsync from 'hooks/async';
|
import { useQuery } from 'react-query';
|
||||||
import BalanceSheetConnect from 'connectors/BalanceSheet.connect';
|
import { useIntl } from 'react-intl';
|
||||||
import {useIntl} from 'react-intl';
|
import moment from 'moment';
|
||||||
|
|
||||||
import BalanceSheetHeader from './BalanceSheetHeader';
|
import BalanceSheetHeader from './BalanceSheetHeader';
|
||||||
import BalanceSheetTable from './BalanceSheetTable';
|
import BalanceSheetTable from './BalanceSheetTable';
|
||||||
import moment from 'moment';
|
|
||||||
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import BalanceSheetActionsBar from './BalanceSheetActionsBar';
|
import BalanceSheetActionsBar from './BalanceSheetActionsBar';
|
||||||
import SettingsConnect from 'connectors/Settings.connect';
|
import SettingsConnect from 'connectors/Settings.connect';
|
||||||
|
|
||||||
|
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||||
|
import withBalanceSheetActions from './withBalanceSheetActions';
|
||||||
|
import withBalanceSheetDetail from './withBalanceSheetDetail';
|
||||||
|
|
||||||
|
|
||||||
function BalanceSheet({
|
function BalanceSheet({
|
||||||
fetchBalanceSheet,
|
// #withDashboard
|
||||||
changePageTitle,
|
changePageTitle,
|
||||||
balanceSheetLoading,
|
|
||||||
getBalanceSheetIndex,
|
// #withBalanceSheetActions
|
||||||
getBalanceSheet,
|
fetchBalanceSheet,
|
||||||
|
|
||||||
|
// #withBalanceSheetDetail
|
||||||
|
balanceSheetLoading,
|
||||||
|
|
||||||
|
// #withPreferences
|
||||||
organizationSettings
|
organizationSettings
|
||||||
}) {
|
}) {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
@@ -30,24 +41,18 @@ function BalanceSheet({
|
|||||||
none_zero: false,
|
none_zero: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchHook = useAsync(async (query = filter) => {
|
const fetchHook = useQuery(['balance-sheet', filter],
|
||||||
await Promise.all([
|
(key, query) => { fetchBalanceSheet({ ...query }); });
|
||||||
fetchBalanceSheet({ ...query }),
|
|
||||||
]);
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
// Handle fetch the data of balance sheet.
|
// Handle fetch the data of balance sheet.
|
||||||
const handleFetchData = useCallback(() => { fetchHook.execute(); }, [fetchHook]);
|
const handleFetchData = useCallback(() => {
|
||||||
|
fetchHook.refetch();
|
||||||
|
}, [fetchHook]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
changePageTitle('Balance Sheet');
|
changePageTitle('Balance Sheet');
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Retrieve balance sheet index by the given filter query.
|
|
||||||
const balanceSheetIndex = useMemo(() =>
|
|
||||||
getBalanceSheetIndex(filter),
|
|
||||||
[filter, getBalanceSheetIndex]);
|
|
||||||
|
|
||||||
// Handle re-fetch balance sheet after filter change.
|
// Handle re-fetch balance sheet after filter change.
|
||||||
const handleFilterSubmit = useCallback((filter) => {
|
const handleFilterSubmit = useCallback((filter) => {
|
||||||
const _filter = {
|
const _filter = {
|
||||||
@@ -56,8 +61,7 @@ function BalanceSheet({
|
|||||||
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
setFilter({ ..._filter });
|
setFilter({ ..._filter });
|
||||||
fetchHook.execute(_filter);
|
}, [setFilter]);
|
||||||
}, [setFilter, fetchHook]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider>
|
<DashboardInsider>
|
||||||
@@ -73,7 +77,7 @@ function BalanceSheet({
|
|||||||
<BalanceSheetTable
|
<BalanceSheetTable
|
||||||
companyName={organizationSettings.name}
|
companyName={organizationSettings.name}
|
||||||
loading={balanceSheetLoading}
|
loading={balanceSheetLoading}
|
||||||
balanceSheetIndex={balanceSheetIndex}
|
balanceSheetQuery={filter}
|
||||||
onFetchData={handleFetchData} />
|
onFetchData={handleFetchData} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -83,7 +87,11 @@ function BalanceSheet({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
DashboardConnect,
|
withDashboard,
|
||||||
BalanceSheetConnect,
|
withBalanceSheetActions,
|
||||||
|
withBalanceSheetDetail(({ balanceSheetLoading }) => ({
|
||||||
|
balanceSheetLoading,
|
||||||
|
})),
|
||||||
|
// BalanceSheetConnect,
|
||||||
SettingsConnect,
|
SettingsConnect,
|
||||||
)(BalanceSheet);
|
)(BalanceSheet);
|
||||||
@@ -1,23 +1,30 @@
|
|||||||
import React, {useMemo, useState, useCallback, useEffect} from 'react';
|
import React, {useMemo, useCallback } from 'react';
|
||||||
import moment from 'moment';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import Money from 'components/Money';
|
import Money from 'components/Money';
|
||||||
import FinancialSheet from 'components/FinancialSheet';
|
import FinancialSheet from 'components/FinancialSheet';
|
||||||
import DataTable from 'components/DataTable';
|
import DataTable from 'components/DataTable';
|
||||||
import BalanceSheetConnect from 'connectors/BalanceSheet.connect';
|
|
||||||
import BalanceSheetTableConnect from 'connectors/BalanceSheetTable.connect';
|
|
||||||
import {
|
|
||||||
compose,
|
|
||||||
defaultExpanderReducer,
|
|
||||||
} from 'utils';
|
|
||||||
import SettingsConnect from 'connectors/Settings.connect';
|
import SettingsConnect from 'connectors/Settings.connect';
|
||||||
|
import withBalanceSheetDetail from './withBalanceSheetDetail';
|
||||||
|
import {
|
||||||
|
getFinancialSheetIndexByQuery,
|
||||||
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
|
||||||
|
import { compose, defaultExpanderReducer } from 'utils';
|
||||||
|
|
||||||
|
|
||||||
function BalanceSheetTable({
|
function BalanceSheetTable({
|
||||||
|
// #withPreferences
|
||||||
organizationSettings,
|
organizationSettings,
|
||||||
|
|
||||||
|
// #withBalanceSheetDetail
|
||||||
balanceSheetAccounts,
|
balanceSheetAccounts,
|
||||||
balanceSheetColumns,
|
balanceSheetColumns,
|
||||||
balanceSheetQuery,
|
balanceSheetQuery,
|
||||||
|
|
||||||
|
// #ownProps
|
||||||
onFetchData,
|
onFetchData,
|
||||||
asDate,
|
|
||||||
loading,
|
loading,
|
||||||
}) {
|
}) {
|
||||||
const columns = useMemo(() => [
|
const columns = useMemo(() => [
|
||||||
@@ -130,8 +137,27 @@ function BalanceSheetTable({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mapStateToProps = (state, props) => {
|
||||||
|
const { balanceSheetQuery } = props;
|
||||||
|
return {
|
||||||
|
balanceSheetIndex: getFinancialSheetIndexByQuery(
|
||||||
|
state.financialStatements.balanceSheet.sheets,
|
||||||
|
balanceSheetQuery,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const withBalanceSheetTable = connect(mapStateToProps);
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
BalanceSheetConnect,
|
withBalanceSheetTable,
|
||||||
BalanceSheetTableConnect,
|
withBalanceSheetDetail(({
|
||||||
|
balanceSheetAccounts,
|
||||||
|
balanceSheetColumns,
|
||||||
|
balanceSheetQuery }) => ({
|
||||||
|
balanceSheetAccounts,
|
||||||
|
balanceSheetColumns,
|
||||||
|
balanceSheetQuery,
|
||||||
|
})),
|
||||||
SettingsConnect,
|
SettingsConnect,
|
||||||
)(BalanceSheetTable);
|
)(BalanceSheetTable);
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import {connect} from 'react-redux';
|
||||||
|
import {
|
||||||
|
fetchBalanceSheet,
|
||||||
|
} from 'store/financialStatement/financialStatements.actions';
|
||||||
|
|
||||||
|
export const mapDispatchToProps = (dispatch) => ({
|
||||||
|
fetchBalanceSheet: (query = {}) => dispatch(fetchBalanceSheet({ query })),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(null, mapDispatchToProps);
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { connect } from 'react-redux';
|
||||||
|
import {
|
||||||
|
getFinancialSheet,
|
||||||
|
getFinancialSheetAccounts,
|
||||||
|
getFinancialSheetColumns,
|
||||||
|
getFinancialSheetQuery,
|
||||||
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
|
||||||
|
|
||||||
|
export default (mapState) => {
|
||||||
|
const mapStateToProps = (state, props) => {
|
||||||
|
const { balanceSheetIndex } = props;
|
||||||
|
const mapped = {
|
||||||
|
balanceSheet: getFinancialSheet(state.financialStatements.balanceSheet.sheets, balanceSheetIndex),
|
||||||
|
balanceSheetAccounts: getFinancialSheetAccounts(state.financialStatements.balanceSheet.sheets, balanceSheetIndex),
|
||||||
|
balanceSheetColumns: getFinancialSheetColumns(state.financialStatements.balanceSheet.sheets, balanceSheetIndex),
|
||||||
|
balanceSheetQuery: getFinancialSheetQuery(state.financialStatements.balanceSheet.sheets, balanceSheetIndex),
|
||||||
|
balanceSheetLoading: state.financialStatements.balanceSheet.loading,
|
||||||
|
};
|
||||||
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
|
};
|
||||||
|
|
||||||
|
return connect(mapStateToProps);
|
||||||
|
}
|
||||||
@@ -1,23 +1,32 @@
|
|||||||
import React, {useState, useCallback, useEffect, useMemo} from 'react';
|
import React, { useState, useCallback, useEffect } from 'react';
|
||||||
|
import { useQuery } from 'react-query';
|
||||||
import {compose} from 'utils';
|
import {compose} from 'utils';
|
||||||
import JournalConnect from 'connectors/Journal.connect';
|
|
||||||
import JournalHeader from 'containers/FinancialStatements/Journal/JournalHeader';
|
|
||||||
import useAsync from 'hooks/async';
|
|
||||||
import {useIntl} from 'react-intl';
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import JournalTable from './JournalTable';
|
import JournalTable from './JournalTable';
|
||||||
import DashboardConnect from 'connectors/Dashboard.connector';
|
|
||||||
|
import JournalHeader from './JournalHeader';
|
||||||
import JournalActionsBar from './JournalActionsBar';
|
import JournalActionsBar from './JournalActionsBar';
|
||||||
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import SettingsConnect from 'connectors/Settings.connect';
|
import SettingsConnect from 'connectors/Settings.connect';
|
||||||
|
|
||||||
|
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||||
|
import withJournal from './withJournal';
|
||||||
|
import withJournalActions from './withJournalActions';
|
||||||
|
|
||||||
|
|
||||||
function Journal({
|
function Journal({
|
||||||
fetchJournalSheet,
|
// #withJournalActions
|
||||||
getJournalSheet,
|
requestFetchJournalSheet,
|
||||||
getJournalSheetIndex,
|
|
||||||
changePageTitle,
|
// #withDashboard
|
||||||
|
changePageTitle,
|
||||||
|
|
||||||
|
// #withJournal
|
||||||
journalSheetLoading,
|
journalSheetLoading,
|
||||||
|
|
||||||
|
// #withPreferences
|
||||||
organizationSettings,
|
organizationSettings,
|
||||||
}) {
|
}) {
|
||||||
const [filter, setFilter] = useState({
|
const [filter, setFilter] = useState({
|
||||||
@@ -30,21 +39,8 @@ function Journal({
|
|||||||
changePageTitle('Journal Sheet');
|
changePageTitle('Journal Sheet');
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const fetchHook = useAsync((query = filter) => {
|
const fetchHook = useQuery(['journal', filter],
|
||||||
return Promise.all([
|
(key, query) => { requestFetchJournalSheet(query); });
|
||||||
fetchJournalSheet(query),
|
|
||||||
]);
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
// Retrieve journal sheet index by the given filter query.
|
|
||||||
const journalSheetIndex = useMemo(() =>
|
|
||||||
getJournalSheetIndex(filter),
|
|
||||||
[getJournalSheetIndex, filter]);
|
|
||||||
|
|
||||||
// Retrieve journal sheet by the given sheet index.
|
|
||||||
const journalSheet = useMemo(() =>
|
|
||||||
getJournalSheet(journalSheetIndex),
|
|
||||||
[getJournalSheet, journalSheetIndex]);
|
|
||||||
|
|
||||||
// Handle financial statement filter change.
|
// Handle financial statement filter change.
|
||||||
const handleFilterSubmit = useCallback((filter) => {
|
const handleFilterSubmit = useCallback((filter) => {
|
||||||
@@ -54,7 +50,6 @@ function Journal({
|
|||||||
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
setFilter(_filter);
|
setFilter(_filter);
|
||||||
fetchHook.execute(_filter);
|
|
||||||
}, [fetchHook]);
|
}, [fetchHook]);
|
||||||
|
|
||||||
const handlePrintClick = useCallback(() => {
|
const handlePrintClick = useCallback(() => {
|
||||||
@@ -66,7 +61,7 @@ function Journal({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleFetchData = useCallback(({ sortBy, pageIndex, pageSize }) => {
|
const handleFetchData = useCallback(({ sortBy, pageIndex, pageSize }) => {
|
||||||
fetchHook.execute();
|
fetchHook.refetch();
|
||||||
}, [fetchHook]);
|
}, [fetchHook]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -85,12 +80,9 @@ function Journal({
|
|||||||
<div class="financial-statement__table">
|
<div class="financial-statement__table">
|
||||||
<JournalTable
|
<JournalTable
|
||||||
companyName={organizationSettings.name}
|
companyName={organizationSettings.name}
|
||||||
data={[
|
journalQuery={filter}
|
||||||
...(journalSheet && journalSheet.tableRows)
|
|
||||||
? journalSheet.tableRows : []
|
|
||||||
]}
|
|
||||||
loading={journalSheetLoading}
|
loading={journalSheetLoading}
|
||||||
onFetchData={handleFetchData} />
|
onFetchData={handleFetchData} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DashboardPageContent>
|
</DashboardPageContent>
|
||||||
@@ -99,7 +91,10 @@ function Journal({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
JournalConnect,
|
withDashboard,
|
||||||
DashboardConnect,
|
withJournalActions,
|
||||||
|
withJournal(({ journalSheetLoading }) => ({
|
||||||
|
journalSheetLoading,
|
||||||
|
})),
|
||||||
SettingsConnect,
|
SettingsConnect,
|
||||||
)(Journal);
|
)(Journal);
|
||||||
@@ -28,9 +28,9 @@ export default function JournalHeader({
|
|||||||
from_date: Yup.date().required(),
|
from_date: Yup.date().required(),
|
||||||
to_date: Yup.date().min(Yup.ref('from_date')).required(),
|
to_date: Yup.date().min(Yup.ref('from_date')).required(),
|
||||||
}),
|
}),
|
||||||
onSubmit: (values, actions) => {
|
onSubmit: (values, { setSubmitting }) => {
|
||||||
onSubmitFilter(values);
|
onSubmitFilter(values);
|
||||||
actions.setSubmitting(false);
|
setSubmitting(false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,25 @@
|
|||||||
import React, {useState, useEffect, useCallback, useMemo} from 'react';
|
import React, { useCallback, useMemo } from 'react';
|
||||||
|
import {connect} from 'react-redux';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
import FinancialSheet from 'components/FinancialSheet';
|
import FinancialSheet from 'components/FinancialSheet';
|
||||||
import DataTable from 'components/DataTable';
|
import DataTable from 'components/DataTable';
|
||||||
import {compose, defaultExpanderReducer} from 'utils';
|
import {compose, defaultExpanderReducer} from 'utils';
|
||||||
import moment from 'moment';
|
|
||||||
import JournalConnect from 'connectors/Journal.connect';
|
|
||||||
import {
|
|
||||||
getFinancialSheet,
|
|
||||||
} from 'store/financialStatement/financialStatements.selectors';
|
|
||||||
import {connect} from 'react-redux';
|
|
||||||
import Money from 'components/Money';
|
import Money from 'components/Money';
|
||||||
|
import {
|
||||||
|
getFinancialSheetIndexByQuery,
|
||||||
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
|
||||||
|
import withJournal from './withJournal';
|
||||||
|
|
||||||
|
|
||||||
function JournalSheetTable({
|
function JournalSheetTable({
|
||||||
|
// #withJournal
|
||||||
|
journalSheetTableRows,
|
||||||
|
|
||||||
|
// #ownProps
|
||||||
onFetchData,
|
onFetchData,
|
||||||
data,
|
|
||||||
loading,
|
loading,
|
||||||
companyName,
|
companyName,
|
||||||
}) {
|
}) {
|
||||||
@@ -73,7 +80,7 @@ function JournalSheetTable({
|
|||||||
}, [onFetchData]);
|
}, [onFetchData]);
|
||||||
|
|
||||||
// Default expanded rows of general journal table.
|
// Default expanded rows of general journal table.
|
||||||
const expandedRows = useMemo(() => defaultExpanderReducer(data, 1), [data]);
|
const expandedRows = useMemo(() => defaultExpanderReducer([], 1), []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FinancialSheet
|
<FinancialSheet
|
||||||
@@ -82,11 +89,11 @@ function JournalSheetTable({
|
|||||||
date={new Date()}
|
date={new Date()}
|
||||||
name="journal"
|
name="journal"
|
||||||
loading={loading}>
|
loading={loading}>
|
||||||
|
|
||||||
<DataTable
|
<DataTable
|
||||||
className="bigcapital-datatable--financial-report"
|
className="bigcapital-datatable--financial-report"
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={data}
|
data={journalSheetTableRows}
|
||||||
onFetchData={handleFetchData}
|
onFetchData={handleFetchData}
|
||||||
noResults={"This report does not contain any data."}
|
noResults={"This report does not contain any data."}
|
||||||
expanded={expandedRows}
|
expanded={expandedRows}
|
||||||
@@ -95,6 +102,19 @@ function JournalSheetTable({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const mapStateToProps = (state, props) => {
|
||||||
|
const { journalQuery } = props;
|
||||||
|
return {
|
||||||
|
journalIndex: getFinancialSheetIndexByQuery(state.financialStatements.journal.sheets, journalQuery)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const withJournalTable = connect(mapStateToProps);
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
JournalConnect,
|
withJournalTable,
|
||||||
|
withJournal(({ journalSheetTableRows }) => ({
|
||||||
|
journalSheetTableRows
|
||||||
|
})),
|
||||||
)(JournalSheetTable);
|
)(JournalSheetTable);
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import {connect} from 'react-redux';
|
||||||
|
import {
|
||||||
|
getFinancialSheetIndexByQuery,
|
||||||
|
getFinancialSheet,
|
||||||
|
getFinancialSheetTableRows,
|
||||||
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
|
||||||
|
export default (mapState) => {
|
||||||
|
const mapStateToProps = (state, props) => {
|
||||||
|
const { journalIndex } = props;
|
||||||
|
|
||||||
|
const mapped = {
|
||||||
|
journalSheet: getFinancialSheet(state.financialStatements.journal.sheets, journalIndex),
|
||||||
|
journalSheetTableRows: getFinancialSheetTableRows(state.financialStatements.journal.sheets, journalIndex),
|
||||||
|
journalSheetLoading: state.financialStatements.journal.loading,
|
||||||
|
};
|
||||||
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
|
};
|
||||||
|
|
||||||
|
return connect(mapStateToProps);
|
||||||
|
};
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import {connect} from 'react-redux';
|
||||||
|
import {
|
||||||
|
fetchJournalSheet
|
||||||
|
} from 'store/financialStatement/financialStatements.actions';
|
||||||
|
|
||||||
|
export const mapDispatchToProps = (dispatch) => ({
|
||||||
|
requestFetchJournalSheet: (query) => dispatch(fetchJournalSheet({ query })),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(null, mapDispatchToProps);
|
||||||
@@ -3,12 +3,7 @@ import {
|
|||||||
NavbarGroup,
|
NavbarGroup,
|
||||||
Button,
|
Button,
|
||||||
Classes,
|
Classes,
|
||||||
NavbarHeading,
|
|
||||||
NavbarDivider,
|
NavbarDivider,
|
||||||
Intent,
|
|
||||||
Popover,
|
|
||||||
PopoverInteractionKind,
|
|
||||||
Position,
|
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'
|
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'
|
||||||
|
|||||||
@@ -1,22 +1,32 @@
|
|||||||
import React, {useState, useMemo, useCallback, useEffect} from 'react';
|
import React, {useState, useCallback, useEffect} from 'react';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import useAsync from 'hooks/async';
|
|
||||||
import {compose} from 'utils';
|
import {compose} from 'utils';
|
||||||
|
import { useQuery } from 'react-query';
|
||||||
|
|
||||||
import ProfitLossSheetHeader from './ProfitLossSheetHeader';
|
import ProfitLossSheetHeader from './ProfitLossSheetHeader';
|
||||||
import ProfitLossSheetTable from './ProfitLossSheetTable';
|
import ProfitLossSheetTable from './ProfitLossSheetTable';
|
||||||
import DashboardConnect from 'connectors/Dashboard.connector';
|
import ProfitLossActionsBar from './ProfitLossActionsBar';
|
||||||
import ProfitLossSheetConnect from 'connectors/ProfitLossSheet.connect';
|
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider'
|
import DashboardInsider from 'components/Dashboard/DashboardInsider'
|
||||||
import DashboardPageContent from 'components/Dashboard/DashboardPageContent'
|
import DashboardPageContent from 'components/Dashboard/DashboardPageContent'
|
||||||
import ProfitLossActionsBar from './ProfitLossActionsBar';
|
|
||||||
|
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||||
|
import withProfitLossActions from './withProfitLossActions';
|
||||||
|
import withProfitLoss from './withProfitLoss';
|
||||||
import SettingsConnect from 'connectors/Settings.connect';
|
import SettingsConnect from 'connectors/Settings.connect';
|
||||||
|
|
||||||
|
|
||||||
function ProfitLossSheet({
|
function ProfitLossSheet({
|
||||||
|
// #withDashboard
|
||||||
changePageTitle,
|
changePageTitle,
|
||||||
|
|
||||||
|
// #withProfitLossActions
|
||||||
fetchProfitLossSheet,
|
fetchProfitLossSheet,
|
||||||
getProfitLossSheetIndex,
|
|
||||||
|
// #withProfitLoss
|
||||||
profitLossSheetLoading,
|
profitLossSheetLoading,
|
||||||
|
|
||||||
|
// #withPreferences
|
||||||
organizationSettings,
|
organizationSettings,
|
||||||
}) {
|
}) {
|
||||||
const [filter, setFilter] = useState({
|
const [filter, setFilter] = useState({
|
||||||
@@ -31,16 +41,8 @@ function ProfitLossSheet({
|
|||||||
}, [changePageTitle]);
|
}, [changePageTitle]);
|
||||||
|
|
||||||
// Fetches profit/loss sheet.
|
// Fetches profit/loss sheet.
|
||||||
const fetchHook = useAsync((query = filter) => {
|
const fetchHook = useQuery(['profit-loss', filter],
|
||||||
return Promise.all([
|
(key, query) => { fetchProfitLossSheet(query); });
|
||||||
fetchProfitLossSheet(query),
|
|
||||||
]);
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
// Retrieve profit/loss sheet index based on the given filter query.
|
|
||||||
const profitLossSheetIndex = useMemo(() =>
|
|
||||||
getProfitLossSheetIndex(filter),
|
|
||||||
[getProfitLossSheetIndex, filter]);
|
|
||||||
|
|
||||||
// Handle submit filter.
|
// Handle submit filter.
|
||||||
const handleSubmitFilter = useCallback((filter) => {
|
const handleSubmitFilter = useCallback((filter) => {
|
||||||
@@ -50,16 +52,17 @@ function ProfitLossSheet({
|
|||||||
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
setFilter(_filter);
|
setFilter(_filter);
|
||||||
fetchHook.execute(_filter);
|
}, []);
|
||||||
}, [fetchHook]);
|
|
||||||
|
|
||||||
// Handle fetch data of profit/loss sheet table.
|
// Handle fetch data of profit/loss sheet table.
|
||||||
const handleFetchData = useCallback(() => { fetchHook.execute(); }, [fetchHook]);
|
const handleFetchData = useCallback(() => {
|
||||||
|
fetchHook.refetch();
|
||||||
|
}, [fetchHook]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider>
|
<DashboardInsider>
|
||||||
<ProfitLossActionsBar />
|
<ProfitLossActionsBar />
|
||||||
|
|
||||||
<DashboardPageContent>
|
<DashboardPageContent>
|
||||||
<div class="financial-statement">
|
<div class="financial-statement">
|
||||||
<ProfitLossSheetHeader
|
<ProfitLossSheetHeader
|
||||||
@@ -69,7 +72,7 @@ function ProfitLossSheet({
|
|||||||
<div class="financial-statement__body">
|
<div class="financial-statement__body">
|
||||||
<ProfitLossSheetTable
|
<ProfitLossSheetTable
|
||||||
companyName={organizationSettings.name}
|
companyName={organizationSettings.name}
|
||||||
profitLossSheetIndex={profitLossSheetIndex}
|
profitLossQuery={filter}
|
||||||
onFetchData={handleFetchData}
|
onFetchData={handleFetchData}
|
||||||
loading={profitLossSheetLoading} />
|
loading={profitLossSheetLoading} />
|
||||||
</div>
|
</div>
|
||||||
@@ -80,7 +83,10 @@ function ProfitLossSheet({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
DashboardConnect,
|
withDashboard,
|
||||||
ProfitLossSheetConnect,
|
withProfitLossActions,
|
||||||
|
withProfitLoss(({ profitLossSheetLoading }) => ({
|
||||||
|
profitLossSheetLoading,
|
||||||
|
})),
|
||||||
SettingsConnect,
|
SettingsConnect,
|
||||||
)(ProfitLossSheet);
|
)(ProfitLossSheet);
|
||||||
@@ -1,18 +1,25 @@
|
|||||||
import React, {useState, useMemo, useCallback} from 'react';
|
import React, { useMemo, useCallback } from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
import FinancialSheet from 'components/FinancialSheet';
|
import FinancialSheet from 'components/FinancialSheet';
|
||||||
import DataTable from 'components/DataTable';
|
import DataTable from 'components/DataTable';
|
||||||
import Money from 'components/Money';
|
import Money from 'components/Money';
|
||||||
import ProfitLossSheetConnect from 'connectors/ProfitLossSheet.connect';
|
|
||||||
import ProfitLossSheetTableConnect from 'connectors/ProfitLossTable.connect';
|
|
||||||
import { compose, defaultExpanderReducer } from 'utils';
|
import { compose, defaultExpanderReducer } from 'utils';
|
||||||
|
import {
|
||||||
|
getFinancialSheetIndexByQuery,
|
||||||
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
import withProfitLossDetail from './withProfitLoss';
|
||||||
|
|
||||||
|
|
||||||
function ProfitLossSheetTable({
|
function ProfitLossSheetTable({
|
||||||
loading,
|
// #withProfitLoss
|
||||||
onFetchData,
|
|
||||||
profitLossTableRows,
|
profitLossTableRows,
|
||||||
profitLossQuery,
|
profitLossQuery,
|
||||||
profitLossColumns,
|
profitLossColumns,
|
||||||
|
|
||||||
|
// #ownProps
|
||||||
|
loading,
|
||||||
|
onFetchData,
|
||||||
companyName,
|
companyName,
|
||||||
}) {
|
}) {
|
||||||
const columns = useMemo(() => [
|
const columns = useMemo(() => [
|
||||||
@@ -132,7 +139,20 @@ function ProfitLossSheetTable({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mapStateToProps = (state, props) => ({
|
||||||
|
profitLossIndex: getFinancialSheetIndexByQuery(
|
||||||
|
state.financialStatements.profitLoss.sheets,
|
||||||
|
props.profitLossQuery,
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
const withProfitLossTable = connect(mapStateToProps);
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
ProfitLossSheetConnect,
|
withProfitLossTable,
|
||||||
ProfitLossSheetTableConnect,
|
withProfitLossDetail(({ profitLossQuery, profitLossColumns, profitLossTableRows }) => ({
|
||||||
|
profitLossColumns,
|
||||||
|
profitLossQuery,
|
||||||
|
profitLossTableRows,
|
||||||
|
})),
|
||||||
)(ProfitLossSheetTable);
|
)(ProfitLossSheetTable);
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import {connect} from 'react-redux';
|
||||||
|
import {
|
||||||
|
getFinancialSheetIndexByQuery,
|
||||||
|
getFinancialSheet,
|
||||||
|
getFinancialSheetColumns,
|
||||||
|
getFinancialSheetQuery,
|
||||||
|
getFinancialSheetTableRows,
|
||||||
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
|
||||||
|
|
||||||
|
export default (mapState) => {
|
||||||
|
const mapStateToProps = (state, props) => {
|
||||||
|
const { profitLossIndex } = props;
|
||||||
|
|
||||||
|
const mapped = {
|
||||||
|
profitLossSheet: getFinancialSheet(state.financialStatements.profitLoss.sheets, profitLossIndex),
|
||||||
|
profitLossColumns: getFinancialSheetColumns(state.financialStatements.profitLoss.sheets, profitLossIndex),
|
||||||
|
profitLossQuery: getFinancialSheetQuery(state.financialStatements.profitLoss.sheets, profitLossIndex),
|
||||||
|
profitLossTableRows: getFinancialSheetTableRows(state.financialStatements.profitLoss.sheets, profitLossIndex),
|
||||||
|
|
||||||
|
profitLossSheetLoading: state.financialStatements.profitLoss.loading,
|
||||||
|
};
|
||||||
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
|
};
|
||||||
|
return connect(mapStateToProps);
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import {connect} from 'react-redux';
|
||||||
|
import {
|
||||||
|
fetchProfitLossSheet,
|
||||||
|
} from 'store/financialStatement/financialStatements.actions';
|
||||||
|
|
||||||
|
export const mapDispatchToProps = (dispatch) => ({
|
||||||
|
fetchProfitLossSheet: (query = {}) => dispatch(fetchProfitLossSheet({ query })),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(null, mapDispatchToProps);
|
||||||
@@ -1,22 +1,32 @@
|
|||||||
import React, { useEffect, useCallback, useState, useMemo } from 'react';
|
import React, { useEffect, useCallback, useState, useMemo } from 'react';
|
||||||
import TrialBalanceSheetHeader from "./TrialBalanceSheetHeader";
|
import TrialBalanceSheetHeader from "./TrialBalanceSheetHeader";
|
||||||
import TrialBalanceSheetTable from './TrialBalanceSheetTable';
|
import TrialBalanceSheetTable from './TrialBalanceSheetTable';
|
||||||
import useAsync from 'hooks/async';
|
import { useQuery } from 'react-query';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import {compose} from 'utils';
|
import {compose} from 'utils';
|
||||||
import TrialBalanceSheetConnect from 'connectors/TrialBalanceSheet.connect';
|
|
||||||
import DashboardConnect from 'connectors/Dashboard.connector';
|
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
||||||
|
|
||||||
import TrialBalanceActionsBar from './TrialBalanceActionsBar';
|
import TrialBalanceActionsBar from './TrialBalanceActionsBar';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
|
||||||
|
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||||
|
import withTrialBalanceActions from './withTrialBalanceActions';
|
||||||
|
import withTrialBalance from './withTrialBalance';
|
||||||
import SettingsConnect from 'connectors/Settings.connect';
|
import SettingsConnect from 'connectors/Settings.connect';
|
||||||
|
|
||||||
|
|
||||||
function TrialBalanceSheet({
|
function TrialBalanceSheet({
|
||||||
|
// #withDashboard
|
||||||
changePageTitle,
|
changePageTitle,
|
||||||
|
|
||||||
|
// #withTrialBalanceActions
|
||||||
fetchTrialBalanceSheet,
|
fetchTrialBalanceSheet,
|
||||||
getTrialBalanceSheetIndex,
|
|
||||||
getTrialBalanceAccounts,
|
// #withTrialBalance
|
||||||
trialBalanceSheetLoading,
|
trialBalanceSheetLoading,
|
||||||
|
|
||||||
|
// #withPreferences
|
||||||
organizationSettings,
|
organizationSettings,
|
||||||
}) {
|
}) {
|
||||||
const [filter, setFilter] = useState({
|
const [filter, setFilter] = useState({
|
||||||
@@ -26,24 +36,13 @@ function TrialBalanceSheet({
|
|||||||
none_zero: false,
|
none_zero: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchHook = useAsync((query = filter) => {
|
const fetchHook = useQuery(['trial-balance', filter],
|
||||||
return Promise.all([
|
(key, query) => { fetchTrialBalanceSheet(query); });
|
||||||
fetchTrialBalanceSheet(query),
|
|
||||||
]);
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
// handle fetch data of trial balance table.
|
// handle fetch data of trial balance table.
|
||||||
const handleFetchData = useCallback(() => { fetchHook.execute() }, [fetchHook]);
|
const handleFetchData = useCallback(() => {
|
||||||
|
fetchHook.refetch()
|
||||||
// Retrieve balance sheet index by the given filter query.
|
}, [fetchHook]);
|
||||||
const trialBalanceSheetIndex = useMemo(() =>
|
|
||||||
getTrialBalanceSheetIndex(filter),
|
|
||||||
[getTrialBalanceSheetIndex, filter]);
|
|
||||||
|
|
||||||
// Retrieve balance sheet accounts bu the given sheet index.
|
|
||||||
const trialBalanceAccounts = useMemo(() =>
|
|
||||||
getTrialBalanceAccounts(trialBalanceSheetIndex),
|
|
||||||
[getTrialBalanceAccounts, trialBalanceSheetIndex]);
|
|
||||||
|
|
||||||
// Change page title of the dashboard.
|
// Change page title of the dashboard.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -57,8 +56,7 @@ function TrialBalanceSheet({
|
|||||||
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
to_date: moment(filter.to_date).format('YYYY-MM-DD'),
|
||||||
};
|
};
|
||||||
setFilter(parsedFilter);
|
setFilter(parsedFilter);
|
||||||
fetchHook.execute(parsedFilter);
|
}, [setFilter]);
|
||||||
}, [setFilter, fetchHook]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider>
|
<DashboardInsider>
|
||||||
@@ -73,8 +71,7 @@ function TrialBalanceSheet({
|
|||||||
<div class="financial-statement__body">
|
<div class="financial-statement__body">
|
||||||
<TrialBalanceSheetTable
|
<TrialBalanceSheetTable
|
||||||
companyName={organizationSettings.name}
|
companyName={organizationSettings.name}
|
||||||
trialBalanceSheetAccounts={trialBalanceAccounts}
|
trialBalanceQuery={filter}
|
||||||
trialBalanceSheetIndex={trialBalanceSheetIndex}
|
|
||||||
onFetchData={handleFetchData}
|
onFetchData={handleFetchData}
|
||||||
loading={trialBalanceSheetLoading} />
|
loading={trialBalanceSheetLoading} />
|
||||||
</div>
|
</div>
|
||||||
@@ -85,7 +82,10 @@ function TrialBalanceSheet({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
DashboardConnect,
|
withDashboard,
|
||||||
TrialBalanceSheetConnect,
|
withTrialBalanceActions,
|
||||||
|
withTrialBalance(({ trialBalanceSheetLoading }) => ({
|
||||||
|
trialBalanceSheetLoading,
|
||||||
|
})),
|
||||||
SettingsConnect,
|
SettingsConnect,
|
||||||
)(TrialBalanceSheet);
|
)(TrialBalanceSheet);
|
||||||
@@ -1,30 +1,22 @@
|
|||||||
import React, {useState, useCallback, useMemo} from 'react';
|
import React, {useState, useCallback, useMemo} from 'react';
|
||||||
import FinancialStatementHeader from 'containers/FinancialStatements/FinancialStatementHeader';
|
import * as Yup from 'yup';
|
||||||
import {Row, Col} from 'react-grid-system';
|
import {Row, Col} from 'react-grid-system';
|
||||||
|
import FinancialStatementHeader from 'containers/FinancialStatements/FinancialStatementHeader';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
FormGroup,
|
|
||||||
Position,
|
|
||||||
MenuItem,
|
|
||||||
RadioGroup,
|
|
||||||
Radio,
|
|
||||||
HTMLSelect,
|
|
||||||
Intent,
|
|
||||||
Popover,
|
|
||||||
} from "@blueprintjs/core";
|
} from "@blueprintjs/core";
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import {useIntl} from 'react-intl';
|
import {useIntl} from 'react-intl';
|
||||||
import { useFormik } from 'formik';
|
import { useFormik } from 'formik';
|
||||||
import * as Yup from 'yup';
|
|
||||||
import Icon from 'components/Icon';
|
|
||||||
import FinancialStatementDateRange from 'containers/FinancialStatements/FinancialStatementDateRange';
|
import FinancialStatementDateRange from 'containers/FinancialStatements/FinancialStatementDateRange';
|
||||||
|
|
||||||
|
|
||||||
export default function TrialBalanceSheetHeader({
|
export default function TrialBalanceSheetHeader({
|
||||||
pageFilter,
|
pageFilter,
|
||||||
onSubmitFilter,
|
onSubmitFilter,
|
||||||
}) {
|
}) {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
initialValues: {
|
initialValues: {
|
||||||
@@ -36,9 +28,9 @@ export default function TrialBalanceSheetHeader({
|
|||||||
from_date: Yup.date().required(),
|
from_date: Yup.date().required(),
|
||||||
to_date: Yup.date().min(Yup.ref('from_date')).required(),
|
to_date: Yup.date().min(Yup.ref('from_date')).required(),
|
||||||
}),
|
}),
|
||||||
onSubmit: (values, actions) => {
|
onSubmit: (values, { setSubmitting }) => {
|
||||||
onSubmitFilter(values);
|
onSubmitFilter(values);
|
||||||
actions.setSubmitting(false);
|
setSubmitting(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,28 @@
|
|||||||
import React, {useEffect, useState, useCallback, useMemo} from 'react';
|
import React, {useEffect, useState, useCallback, useMemo} from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
import FinancialSheet from 'components/FinancialSheet';
|
import FinancialSheet from 'components/FinancialSheet';
|
||||||
import DataTable from 'components/DataTable';
|
import DataTable from 'components/DataTable';
|
||||||
import Money from 'components/Money';
|
import Money from 'components/Money';
|
||||||
|
import {
|
||||||
|
getFinancialSheetIndexByQuery,
|
||||||
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
|
||||||
|
import withTrialBalance from './withTrialBalance';
|
||||||
|
|
||||||
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
|
||||||
|
function TrialBalanceSheetTable({
|
||||||
|
// #withTrialBalanceDetail
|
||||||
|
trialBalanceAccounts,
|
||||||
|
|
||||||
|
// #withTrialBalanceTable
|
||||||
|
trialBalanceIndex,
|
||||||
|
|
||||||
export default function TrialBalanceSheetTable({
|
|
||||||
trialBalanceSheetAccounts,
|
|
||||||
trialBalanceSheetIndex,
|
|
||||||
onFetchData,
|
onFetchData,
|
||||||
loading,
|
loading,
|
||||||
companyName,
|
companyName,
|
||||||
}) {
|
}) {
|
||||||
const [data, setData] = useState([]);
|
|
||||||
|
|
||||||
const columns = useMemo(() => [
|
const columns = useMemo(() => [
|
||||||
{
|
{
|
||||||
// Build our expander column
|
// Build our expander column
|
||||||
@@ -98,8 +109,25 @@ export default function TrialBalanceSheetTable({
|
|||||||
<DataTable
|
<DataTable
|
||||||
className="bigcapital-datatable--financial-report"
|
className="bigcapital-datatable--financial-report"
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={trialBalanceSheetAccounts}
|
data={trialBalanceAccounts}
|
||||||
onFetchData={handleFetchData} />
|
onFetchData={handleFetchData} />
|
||||||
</FinancialSheet>
|
</FinancialSheet>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const mapStateToProps = (state, props) => {
|
||||||
|
const { trialBalanceQuery } = props;
|
||||||
|
return {
|
||||||
|
trialBalanceIndex: getFinancialSheetIndexByQuery(state.financialStatements.trialBalance.sheets, trialBalanceQuery),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const withTrialBalanceTable = connect(mapStateToProps);
|
||||||
|
|
||||||
|
export default compose(
|
||||||
|
withTrialBalanceTable,
|
||||||
|
withTrialBalance(({ trialBalanceAccounts }) => ({
|
||||||
|
trialBalanceAccounts,
|
||||||
|
})),
|
||||||
|
)(TrialBalanceSheetTable);
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import {connect} from 'react-redux';
|
||||||
|
import {
|
||||||
|
getFinancialSheetAccounts,
|
||||||
|
getFinancialSheetQuery,
|
||||||
|
} from 'store/financialStatement/financialStatements.selectors';
|
||||||
|
|
||||||
|
|
||||||
|
export default (mapState) => {
|
||||||
|
const mapStateToProps = (state, props) => {
|
||||||
|
const { trialBalanceIndex } = props;
|
||||||
|
const mapped = {
|
||||||
|
trialBalanceAccounts: getFinancialSheetAccounts(state.financialStatements.trialBalance.sheets, trialBalanceIndex),
|
||||||
|
trialBalanceQuery: getFinancialSheetQuery(state.financialStatements.trialBalance.sheets, trialBalanceIndex),
|
||||||
|
|
||||||
|
trialBalanceSheetLoading: state.financialStatements.trialBalance.loading,
|
||||||
|
};
|
||||||
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
|
};
|
||||||
|
|
||||||
|
return connect(mapStateToProps);
|
||||||
|
};
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import {connect} from 'react-redux';
|
||||||
|
import {
|
||||||
|
fetchTrialBalanceSheet
|
||||||
|
} from 'store/financialStatement/financialStatements.actions';
|
||||||
|
|
||||||
|
export const mapDispatchToProps = (dispatch) => ({
|
||||||
|
fetchTrialBalanceSheet: (query = {}) => dispatch(fetchTrialBalanceSheet({ query })),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(null, mapDispatchToProps);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useState, useCallback } from 'react';
|
import React, { useEffect, useState, useCallback } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import useAsync from 'hooks/async';
|
import { useQuery } from 'react-query';
|
||||||
|
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import ItemCategoriesDataTable from 'containers/Items/ItemCategoriesTable';
|
import ItemCategoriesDataTable from 'containers/Items/ItemCategoriesTable';
|
||||||
@@ -8,12 +8,14 @@ import ItemsCategoryActionsBar from 'containers/Items/ItemsCategoryActionsBar';
|
|||||||
|
|
||||||
import withDashboardActions from 'containers/Dashboard/withDashboard';
|
import withDashboardActions from 'containers/Dashboard/withDashboard';
|
||||||
import withItemCategoriesActions from 'containers/Items/withItemCategoriesActions';
|
import withItemCategoriesActions from 'containers/Items/withItemCategoriesActions';
|
||||||
import withItemCategories from 'containers/Items/withItemCategories';
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
|
|
||||||
const ItemCategoryList = ({
|
const ItemCategoryList = ({
|
||||||
|
// #withDashboardActions
|
||||||
changePageTitle,
|
changePageTitle,
|
||||||
|
|
||||||
|
// #withItemCategoriesActions
|
||||||
requestFetchItemCategories,
|
requestFetchItemCategories,
|
||||||
}) => {
|
}) => {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
@@ -25,23 +27,26 @@ const ItemCategoryList = ({
|
|||||||
: changePageTitle('Category List');
|
: changePageTitle('Category List');
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const fetchCategories = useAsync(() => {
|
const fetchCategories = useQuery('items-categories-table',
|
||||||
return Promise.all([
|
() => { requestFetchItemCategories(); });
|
||||||
requestFetchItemCategories(),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleFilterChanged = useCallback(() => {
|
const handleFilterChanged = useCallback(() => {
|
||||||
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// Handle selected rows change.
|
||||||
|
const handleSelectedRowsChange = useCallback((itemCategories) => {
|
||||||
|
setSelectedRows(itemCategories);
|
||||||
|
}, [setSelectedRows]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider name={'item-category-list'}>
|
<DashboardInsider name={'item-category-list'}>
|
||||||
<ItemsCategoryActionsBar
|
<ItemsCategoryActionsBar
|
||||||
onFilterChanged={handleFilterChanged}
|
onFilterChanged={handleFilterChanged}
|
||||||
selectedRows={selectedRows} />
|
selectedRows={selectedRows} />
|
||||||
|
|
||||||
<ItemCategoriesDataTable />
|
<ItemCategoriesDataTable
|
||||||
|
onSelectedRowsChange={handleSelectedRowsChange} />
|
||||||
</DashboardInsider>
|
</DashboardInsider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -49,5 +54,4 @@ const ItemCategoryList = ({
|
|||||||
export default compose(
|
export default compose(
|
||||||
withDashboardActions,
|
withDashboardActions,
|
||||||
withItemCategoriesActions,
|
withItemCategoriesActions,
|
||||||
withItemCategories,
|
|
||||||
)(ItemCategoryList);
|
)(ItemCategoryList);
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
import React, { useCallback, useMemo } from 'react';
|
import React, { useCallback, useMemo } from 'react';
|
||||||
import Icon from 'components/Icon';
|
|
||||||
import ItemsCategoryConnect from 'connectors/ItemsCategory.connect';
|
|
||||||
import DialogConnect from 'connectors/Dialog.connector';
|
|
||||||
import LoadingIndicator from 'components/LoadingIndicator';
|
|
||||||
import { compose } from 'utils';
|
|
||||||
import DataTable from 'components/DataTable';
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Popover,
|
Popover,
|
||||||
@@ -12,9 +6,19 @@ import {
|
|||||||
MenuItem,
|
MenuItem,
|
||||||
Position,
|
Position,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
|
import Icon from 'components/Icon';
|
||||||
|
import LoadingIndicator from 'components/LoadingIndicator';
|
||||||
|
import { compose } from 'utils';
|
||||||
|
import DataTable from 'components/DataTable';
|
||||||
|
|
||||||
|
import DialogConnect from 'connectors/Dialog.connector';
|
||||||
|
import withItemCategories from './withItemCategories';
|
||||||
|
|
||||||
|
|
||||||
const ItemsCategoryList = ({
|
const ItemsCategoryList = ({
|
||||||
categories,
|
// #withItemCategories
|
||||||
|
categoriesList,
|
||||||
|
|
||||||
onFetchData,
|
onFetchData,
|
||||||
onDeleteCategory,
|
onDeleteCategory,
|
||||||
onEditCategory,
|
onEditCategory,
|
||||||
@@ -91,7 +95,7 @@ const ItemsCategoryList = ({
|
|||||||
<LoadingIndicator spinnerSize={30}>
|
<LoadingIndicator spinnerSize={30}>
|
||||||
<DataTable
|
<DataTable
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={Object.values(categories)}
|
data={categoriesList}
|
||||||
onFetchData={handelFetchData}
|
onFetchData={handelFetchData}
|
||||||
manualSortBy={true}
|
manualSortBy={true}
|
||||||
selectionColumn={true}
|
selectionColumn={true}
|
||||||
@@ -104,5 +108,7 @@ const ItemsCategoryList = ({
|
|||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
DialogConnect,
|
DialogConnect,
|
||||||
ItemsCategoryConnect,
|
withItemCategories(({ categoriesList }) => ({
|
||||||
|
categoriesList,
|
||||||
|
})),
|
||||||
)(ItemsCategoryList);
|
)(ItemsCategoryList);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const ItemsActionsBar = ({
|
|||||||
resourceName = 'items',
|
resourceName = 'items',
|
||||||
resourceFields,
|
resourceFields,
|
||||||
|
|
||||||
|
// #withItems
|
||||||
itemsViews,
|
itemsViews,
|
||||||
|
|
||||||
onFilterChanged,
|
onFilterChanged,
|
||||||
@@ -128,6 +129,10 @@ const ItemsActionsBar = ({
|
|||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
DialogConnect,
|
DialogConnect,
|
||||||
withItems,
|
withItems(({ itemsViews }) => ({
|
||||||
withResourceDetail,
|
itemsViews,
|
||||||
|
})),
|
||||||
|
withResourceDetail(({ resourceFields }) => ({
|
||||||
|
resourceFields,
|
||||||
|
})),
|
||||||
)(ItemsActionsBar);
|
)(ItemsActionsBar);
|
||||||
|
|||||||
@@ -23,16 +23,20 @@ import withDashboard from 'containers/Dashboard/withDashboard';
|
|||||||
|
|
||||||
|
|
||||||
const ItemsCategoryActionsBar = ({
|
const ItemsCategoryActionsBar = ({
|
||||||
|
// #withResourceDetail
|
||||||
resourceName = 'item_category',
|
resourceName = 'item_category',
|
||||||
resourceFields,
|
resourceFields,
|
||||||
|
|
||||||
|
// #withDialog
|
||||||
openDialog,
|
openDialog,
|
||||||
|
|
||||||
|
// #ownProps
|
||||||
onDeleteCategory,
|
onDeleteCategory,
|
||||||
onFilterChanged,
|
onFilterChanged,
|
||||||
selectedRows,
|
selectedRows,
|
||||||
}) => {
|
}) => {
|
||||||
const onClickNewCategory = useCallback(() => {
|
const onClickNewCategory = useCallback(() => {
|
||||||
openDialog('item-form', {});
|
openDialog('item-category-form', {});
|
||||||
}, [openDialog]);
|
}, [openDialog]);
|
||||||
|
|
||||||
const handleDeleteCategory = useCallback((category) => {
|
const handleDeleteCategory = useCallback((category) => {
|
||||||
@@ -104,5 +108,7 @@ export default compose(
|
|||||||
withItemsCategoriesActionsBar,
|
withItemsCategoriesActionsBar,
|
||||||
DialogConnect,
|
DialogConnect,
|
||||||
withDashboard,
|
withDashboard,
|
||||||
withResourceDetail
|
withResourceDetail(({ resourceFields }) => ({
|
||||||
|
resourceFields,
|
||||||
|
}))
|
||||||
)(ItemsCategoryActionsBar);
|
)(ItemsCategoryActionsBar);
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ import Money from 'components/Money';
|
|||||||
import withItems from 'containers/Items/withItems';
|
import withItems from 'containers/Items/withItems';
|
||||||
import LoadingIndicator from 'components/LoadingIndicator';
|
import LoadingIndicator from 'components/LoadingIndicator';
|
||||||
|
|
||||||
|
|
||||||
const ItemsDataTable = ({
|
const ItemsDataTable = ({
|
||||||
loading,
|
loading,
|
||||||
|
|
||||||
|
// #withItems
|
||||||
itemsTableLoading,
|
itemsTableLoading,
|
||||||
itemsCurrentPage,
|
itemsCurrentPage,
|
||||||
|
|
||||||
@@ -130,5 +132,8 @@ const ItemsDataTable = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
withItems,
|
withItems(({ itemsCurrentPage, itemsTableLoading }) => ({
|
||||||
|
itemsCurrentPage,
|
||||||
|
itemsTableLoading,
|
||||||
|
})),
|
||||||
)(ItemsDataTable);
|
)(ItemsDataTable);
|
||||||
@@ -7,10 +7,12 @@ import {
|
|||||||
Intent,
|
Intent,
|
||||||
Alert,
|
Alert,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
|
||||||
import { useQuery } from 'react-query';
|
import { useQuery } from 'react-query';
|
||||||
|
|
||||||
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import ItemsActionsBar from 'containers/Items/ItemsActionsBar';
|
import ItemsActionsBar from 'containers/Items/ItemsActionsBar';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
import ItemsDataTable from './ItemsDataTable';
|
import ItemsDataTable from './ItemsDataTable';
|
||||||
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
||||||
|
|
||||||
@@ -33,15 +35,12 @@ function ItemsList({
|
|||||||
requestFetchResourceFields,
|
requestFetchResourceFields,
|
||||||
|
|
||||||
// #withItems
|
// #withItems
|
||||||
itemsViews,
|
|
||||||
itemsCurrentPage,
|
|
||||||
itemsTableQuery,
|
itemsTableQuery,
|
||||||
|
|
||||||
// #withItemsActions
|
// #withItemsActions
|
||||||
requestDeleteItem,
|
requestDeleteItem,
|
||||||
requestFetchItems,
|
requestFetchItems,
|
||||||
addItemsTableQueries,
|
addItemsTableQueries,
|
||||||
changeItemsCurrentView
|
|
||||||
}) {
|
}) {
|
||||||
const [deleteItem, setDeleteItem] = useState(false);
|
const [deleteItem, setDeleteItem] = useState(false);
|
||||||
const [selectedRows, setSelectedRows] = useState([]);
|
const [selectedRows, setSelectedRows] = useState([]);
|
||||||
@@ -121,8 +120,7 @@ function ItemsList({
|
|||||||
|
|
||||||
<ItemsActionsBar
|
<ItemsActionsBar
|
||||||
onFilterChanged={handleFilterChanged}
|
onFilterChanged={handleFilterChanged}
|
||||||
selectedRows={selectedRows}
|
selectedRows={selectedRows} />
|
||||||
views={itemsViews} />
|
|
||||||
|
|
||||||
<DashboardPageContent>
|
<DashboardPageContent>
|
||||||
<Switch>
|
<Switch>
|
||||||
@@ -133,9 +131,8 @@ function ItemsList({
|
|||||||
'/dashboard/items'
|
'/dashboard/items'
|
||||||
]}>
|
]}>
|
||||||
<ItemsViewsTabs
|
<ItemsViewsTabs
|
||||||
itemsViews={itemsViews}
|
onViewChanged={handleCustomViewChanged} />
|
||||||
onViewChanged={handleCustomViewChanged} />
|
|
||||||
|
|
||||||
<ItemsDataTable
|
<ItemsDataTable
|
||||||
loading={tableLoading}
|
loading={tableLoading}
|
||||||
onDeleteItem={handleDeleteItem}
|
onDeleteItem={handleDeleteItem}
|
||||||
@@ -164,7 +161,9 @@ function ItemsList({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
withItems,
|
withItems(({ itemsTableQuery }) => ({
|
||||||
|
itemsTableQuery,
|
||||||
|
})),
|
||||||
withResourceActions,
|
withResourceActions,
|
||||||
withDashboardActions,
|
withDashboardActions,
|
||||||
withItemsActions,
|
withItemsActions,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {useUpdateEffect} from 'hooks';
|
|||||||
import withItemsActions from 'containers/Items/withItemsActions';
|
import withItemsActions from 'containers/Items/withItemsActions';
|
||||||
import withDashboard from 'containers/Dashboard/withDashboard';
|
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||||
import withViewDetail from 'containers/Views/withViewDetails';
|
import withViewDetail from 'containers/Views/withViewDetails';
|
||||||
|
import withItems from 'containers/Items/withItems';
|
||||||
|
|
||||||
|
|
||||||
function ItemsViewsTabs({
|
function ItemsViewsTabs({
|
||||||
@@ -25,6 +26,7 @@ function ItemsViewsTabs({
|
|||||||
viewId,
|
viewId,
|
||||||
viewItem,
|
viewItem,
|
||||||
|
|
||||||
|
// #withItems
|
||||||
itemsViews,
|
itemsViews,
|
||||||
|
|
||||||
// #withItemsActions
|
// #withItemsActions
|
||||||
@@ -121,4 +123,7 @@ export default compose(
|
|||||||
withDashboard,
|
withDashboard,
|
||||||
withItemsActions,
|
withItemsActions,
|
||||||
withViewDetail,
|
withViewDetail,
|
||||||
|
withItems( ({ itemsViews }) => ({
|
||||||
|
itemsViews,
|
||||||
|
}))
|
||||||
)(ItemsViewsTabs);
|
)(ItemsViewsTabs);
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
export default (mapState) => {
|
||||||
export const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
return {
|
const mapped = {
|
||||||
categoriesList: Object.values(state.itemCategories.categories),
|
categoriesList: Object.values(state.itemCategories.categories),
|
||||||
categoriesTableLoading: state.itemCategories.loading,
|
categoriesTableLoading: state.itemCategories.loading,
|
||||||
|
};
|
||||||
|
return mapState ? mapState(mapped, state, props) : mapState;
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
return connect(mapStateToProps);
|
||||||
export default connect(mapStateToProps);
|
};
|
||||||
@@ -7,20 +7,22 @@ import {
|
|||||||
getCurrentPageResults
|
getCurrentPageResults
|
||||||
} from 'store/selectors';
|
} from 'store/selectors';
|
||||||
|
|
||||||
export const mapStateToProps = (state, props) => {
|
export default (mapState) => {
|
||||||
const viewPages = getViewPages(state.items.views, state.items.currentViewId);
|
const mapStateToProps = (state, props) => {
|
||||||
|
const viewPages = getViewPages(state.items.views, state.items.currentViewId);
|
||||||
return {
|
const mapped = {
|
||||||
itemsViews: getResourceViews(state, 'items'),
|
itemsViews: getResourceViews(state, 'items'),
|
||||||
itemsCurrentPage: getCurrentPageResults(
|
itemsCurrentPage: getCurrentPageResults(
|
||||||
state.items.items,
|
state.items.items,
|
||||||
viewPages,
|
viewPages,
|
||||||
state.items.currentPage,
|
state.items.currentPage,
|
||||||
),
|
),
|
||||||
itemsBulkSelected: state.items.bulkActions,
|
itemsBulkSelected: state.items.bulkActions,
|
||||||
itemsTableLoading: state.items.loading,
|
itemsTableLoading: state.items.loading,
|
||||||
itemsTableQuery: state.items.tableQuery,
|
itemsTableQuery: state.items.tableQuery,
|
||||||
|
};
|
||||||
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
export default connect(mapStateToProps);
|
return connect(mapStateToProps);
|
||||||
|
};
|
||||||
@@ -5,16 +5,15 @@ import {
|
|||||||
getResourceMetadata,
|
getResourceMetadata,
|
||||||
} from 'store/resources/resources.reducer';
|
} from 'store/resources/resources.reducer';
|
||||||
|
|
||||||
export const mapStateToProps = (state, props) => {
|
export default (mapState) => {
|
||||||
const { resourceName } = props;
|
const mapStateToProps = (state, props) => {
|
||||||
|
const { resourceName } = props;
|
||||||
console.log(props, 'XX');
|
const mapped = {
|
||||||
|
resourceFields: getResourceFields(state, resourceName),
|
||||||
return {
|
resourceColumns: getResourceColumns(state, resourceName),
|
||||||
resourceFields: getResourceFields(state, resourceName),
|
resourceMetadata: getResourceMetadata(state, resourceName),
|
||||||
resourceColumns: getResourceColumns(state, resourceName),
|
};
|
||||||
resourceMetadata: getResourceMetadata(state, resourceName),
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
|
return connect(mapStateToProps);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps);
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import {connect} from 'react-redux';
|
import {connect} from 'react-redux';
|
||||||
import {compose} from 'utils';
|
import {compose} from 'utils';
|
||||||
import DashboardConnect from 'connectors/Dashboard.connector';
|
|
||||||
|
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||||
import withResourceDetail from 'containers/Resources/withResourceDetails';
|
import withResourceDetail from 'containers/Resources/withResourceDetails';
|
||||||
import withViewsActions from 'containers/Views/withViewsActions';
|
import withViewsActions from 'containers/Views/withViewsActions';
|
||||||
import withViewsDetails from 'containers/Views/withViewDetails';
|
import withViewsDetails from 'containers/Views/withViewDetails';
|
||||||
@@ -15,9 +16,9 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
const viewFormConnect = connect(mapStateToProps);
|
const viewFormConnect = connect(mapStateToProps);
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
DashboardConnect,
|
withDashboard,
|
||||||
withViewsActions,
|
withViewsActions,
|
||||||
withViewsDetails,
|
withViewsDetails(),
|
||||||
viewFormConnect,
|
viewFormConnect,
|
||||||
withResourceDetail,
|
withResourceDetail(),
|
||||||
);
|
);
|
||||||
@@ -32,7 +32,6 @@ function ViewForm({
|
|||||||
|
|
||||||
viewId,
|
viewId,
|
||||||
viewMeta,
|
viewMeta,
|
||||||
viewItem,
|
|
||||||
|
|
||||||
resourceName,
|
resourceName,
|
||||||
resourceColumns,
|
resourceColumns,
|
||||||
|
|||||||
@@ -5,13 +5,16 @@ import { Intent, Alert } from '@blueprintjs/core';
|
|||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
import DashboardPageContent from 'components/Dashboard/DashboardPageContent';
|
||||||
import ViewForm from 'containers/Views/ViewForm';
|
import ViewForm from 'containers/Views/ViewForm';
|
||||||
import withResourcesActions from 'containers/Resources/withResourcesActions';
|
|
||||||
import withViewsActions from 'containers/Views/withViewsActions';
|
|
||||||
import withDashboard from 'containers/Dashboard/withDashboard';
|
|
||||||
import AppToaster from 'components/AppToaster';
|
import AppToaster from 'components/AppToaster';
|
||||||
import {compose} from 'utils';
|
import {compose} from 'utils';
|
||||||
import { If } from 'components';
|
import { If } from 'components';
|
||||||
|
|
||||||
|
import withResourcesActions from 'containers/Resources/withResourcesActions';
|
||||||
|
import withViewsActions from 'containers/Views/withViewsActions';
|
||||||
|
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||||
|
|
||||||
|
|
||||||
// @flow
|
// @flow
|
||||||
function ViewFormPage({
|
function ViewFormPage({
|
||||||
changePageTitle,
|
changePageTitle,
|
||||||
|
|||||||
Reference in New Issue
Block a user