mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
Merge branch 'master' of https://github.com/abouolia/Ratteb
This commit is contained in:
@@ -73,7 +73,7 @@ function RegisterUserForm({ requestRegister, requestLogin }) {
|
||||
validationSchema: ValidationSchema,
|
||||
initialValues: {
|
||||
...initialValues,
|
||||
country: 'libya',
|
||||
country: 'LY',
|
||||
},
|
||||
onSubmit: (values, { setSubmitting, setErrors }) => {
|
||||
requestRegister(values)
|
||||
@@ -152,7 +152,6 @@ function RegisterUserForm({ requestRegister, requestLogin }) {
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit} className={'authentication-page__form'}>
|
||||
|
||||
<Row className={'name-section'}>
|
||||
<Col md={6}>
|
||||
<FormGroup
|
||||
@@ -279,6 +278,4 @@ function RegisterUserForm({ requestRegister, requestLogin }) {
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withAuthenticationActions,
|
||||
)(RegisterUserForm);
|
||||
export default compose(withAuthenticationActions)(RegisterUserForm);
|
||||
|
||||
@@ -38,13 +38,12 @@ function BillActionsBar({
|
||||
|
||||
//#withBillActions
|
||||
addBillsTableQueries,
|
||||
|
||||
changeBillView,
|
||||
// #own Porps
|
||||
onFilterChanged,
|
||||
selectedRows = [],
|
||||
}) {
|
||||
const history = useHistory();
|
||||
const { path } = useRouteMatch();
|
||||
const [filterCount, setFilterCount] = useState(0);
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
@@ -52,6 +51,17 @@ function BillActionsBar({
|
||||
history.push('/bills/new');
|
||||
}, [history]);
|
||||
|
||||
const hasSelectedRows = useMemo(() => selectedRows.length > 0, [
|
||||
selectedRows,
|
||||
]);
|
||||
|
||||
const handleTabChange = (viewId) => {
|
||||
changeBillView(viewId.id || -1);
|
||||
addBillsTableQueries({
|
||||
custom_view_id: viewId.id || null,
|
||||
});
|
||||
};
|
||||
|
||||
// const FilterDropdown = FilterDropdown({
|
||||
// initialCondition: {
|
||||
// fieldKey: '',
|
||||
@@ -67,14 +77,14 @@ function BillActionsBar({
|
||||
// },
|
||||
// });
|
||||
|
||||
const hasSelectedRows = useMemo(() => selectedRows.length > 0, [
|
||||
selectedRows,
|
||||
]);
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
<DashboardActionViewsList resourceName={'bills'} views={[]} />
|
||||
<DashboardActionViewsList
|
||||
resourceName={'bills'}
|
||||
views={billsViews}
|
||||
onChange={handleTabChange}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
<Button
|
||||
className={Classes.MINIMAL}
|
||||
@@ -139,10 +149,8 @@ export default compose(
|
||||
withResourceDetail(({ resourceFields }) => ({
|
||||
resourceFields,
|
||||
})),
|
||||
|
||||
// withBills(({billsViews})=>({
|
||||
// billsViews
|
||||
// })),
|
||||
|
||||
withBills(({ billsViews }) => ({
|
||||
billsViews,
|
||||
})),
|
||||
withBillActions,
|
||||
)(BillActionsBar);
|
||||
|
||||
@@ -21,6 +21,9 @@ import withViewsActions from 'containers/Views/withViewsActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Bills list.
|
||||
*/
|
||||
function BillList({
|
||||
// #withDashboardActions
|
||||
changePageTitle,
|
||||
@@ -58,8 +61,8 @@ function BillList({
|
||||
(key, resourceName) => requestFetchResourceFields(resourceName),
|
||||
);
|
||||
|
||||
const fetchBills = useQuery(['bills-table', billsTableQuery], () =>
|
||||
requestFetchBillsTable(),
|
||||
const fetchBills = useQuery(['bills-table', billsTableQuery], (key, query) =>
|
||||
requestFetchBillsTable({ ...query }),
|
||||
);
|
||||
|
||||
//handle dalete Bill
|
||||
@@ -127,14 +130,7 @@ function BillList({
|
||||
);
|
||||
|
||||
// Handle filter change to re-fetch data-table.
|
||||
const handleFilterChanged = useCallback(
|
||||
(filterConditions) => {
|
||||
addBillsTableQueries({
|
||||
filter_roles: filterConditions || '',
|
||||
});
|
||||
},
|
||||
[fetchBills],
|
||||
);
|
||||
const handleFilterChanged = useCallback((filterConditions) => {}, []);
|
||||
|
||||
return (
|
||||
<DashboardInsider
|
||||
@@ -148,7 +144,10 @@ function BillList({
|
||||
/>
|
||||
<DashboardPageContent>
|
||||
<Switch>
|
||||
<Route exact={true}>
|
||||
<Route
|
||||
exact={true}
|
||||
path={['/bills/:custom_view_id/custom_view', '/bills']}
|
||||
>
|
||||
<BillViewTabs />
|
||||
<BillsDataTable
|
||||
onDeleteBill={handleDeleteBill}
|
||||
|
||||
@@ -38,51 +38,34 @@ function BillViewTabs({
|
||||
const { custom_view_id: customViewId = null } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
changeBillView(customViewId || -1);
|
||||
setTopbarEditView(customViewId);
|
||||
changePageSubtitle(customViewId && viewItem ? viewItem.name : '');
|
||||
|
||||
addBillsTableQueries({
|
||||
custom_view_id: customViewId,
|
||||
});
|
||||
return () => {
|
||||
setTopbarEditView(null);
|
||||
changePageSubtitle('');
|
||||
changeBillView(null);
|
||||
};
|
||||
}, [customViewId, addBillsTableQueries, changeBillView]);
|
||||
|
||||
useUpdateEffect(() => {
|
||||
onViewChanged && onViewChanged(customViewId);
|
||||
}, [customViewId]);
|
||||
|
||||
const debounceChangeHistory = useRef(
|
||||
debounce((toUrl) => {
|
||||
history.push(toUrl);
|
||||
}, 250),
|
||||
);
|
||||
// Handle click a new view tab.
|
||||
const handleClickNewView = () => {
|
||||
setTopbarEditView(null);
|
||||
history.push('/custom_views/invoices/new');
|
||||
};
|
||||
|
||||
const handleTabsChange = (viewId) => {
|
||||
const toPath = viewId ? `${viewId}/custom_view` : '';
|
||||
debounceChangeHistory.current(`/bills/${toPath}`);
|
||||
changeBillView(viewId || -1);
|
||||
addBillsTableQueries({
|
||||
custom_view_id: customViewId || null,
|
||||
});
|
||||
setTopbarEditView(viewId);
|
||||
};
|
||||
|
||||
const tabs = billsViews.map((view) => ({
|
||||
...pick(view, ['name', 'id']),
|
||||
}));
|
||||
|
||||
console.log(billsViews, 'billsViews');
|
||||
|
||||
return (
|
||||
<Navbar className={'navbar--dashboard-views'}>
|
||||
<NavbarGroup align={Alignment.LEFT}>
|
||||
<DashboardViewsTabs
|
||||
initialViewId={customViewId}
|
||||
baseUrl={'/bills'}
|
||||
resourceName={'bills'}
|
||||
tabs={tabs}
|
||||
onNewViewTabClick={handleClickNewView}
|
||||
onChange={handleTabsChange}
|
||||
|
||||
@@ -60,24 +60,9 @@ function BillsDataTable({
|
||||
onOpenBill,
|
||||
onSelectedRowsChange,
|
||||
}) {
|
||||
const { custom_view_id: customViewId } = useParams();
|
||||
const { formatMessage } = useIntl();
|
||||
const isLoadedBefore = useIsValuePassed(billsLoading, false);
|
||||
|
||||
useEffect(() => {
|
||||
if (customViewId) {
|
||||
changeCurrentView(customViewId);
|
||||
setTopbarEditView(customViewId);
|
||||
}
|
||||
changePageSubtitle(customViewId && viewMeta ? viewMeta.name : '');
|
||||
}, [
|
||||
customViewId,
|
||||
changeCurrentView,
|
||||
changePageSubtitle,
|
||||
setTopbarEditView,
|
||||
viewMeta,
|
||||
]);
|
||||
|
||||
const handleFetchData = useCallback(
|
||||
({ pageIndex, pageSize, sortBy }) => {
|
||||
const page = pageIndex + 1;
|
||||
|
||||
@@ -3,8 +3,6 @@ import Icon from 'components/Icon';
|
||||
import {
|
||||
Button,
|
||||
Classes,
|
||||
Menu,
|
||||
MenuItem,
|
||||
Popover,
|
||||
NavbarDivider,
|
||||
NavbarGroup,
|
||||
@@ -38,7 +36,7 @@ function EstimateActionsBar({
|
||||
|
||||
// #withEstimateActions
|
||||
addEstimatesTableQueries,
|
||||
|
||||
changeEstimateView,
|
||||
// #own Porps
|
||||
onFilterChanged,
|
||||
selectedRows = [],
|
||||
@@ -52,48 +50,25 @@ function EstimateActionsBar({
|
||||
history.push('/estimates/new');
|
||||
}, [history]);
|
||||
|
||||
// const filterDropdown = FilterDropdown({
|
||||
// fields: resourceFields,
|
||||
// initialCondition: {
|
||||
// fieldKey: 'estimate_number',
|
||||
// compatator: 'contains',
|
||||
// value: '',
|
||||
// },
|
||||
// onFilterChange: (filterConditions) => {
|
||||
// setFilterCount(filterConditions.length || 0);
|
||||
// addEstimatesTableQueries({
|
||||
// filter_roles: filterConditions || '',
|
||||
// });
|
||||
// onFilterChanged && onFilterChanged(filterConditions);
|
||||
// },
|
||||
// });
|
||||
|
||||
const hasSelectedRows = useMemo(() => selectedRows.length > 0, [
|
||||
selectedRows,
|
||||
]);
|
||||
|
||||
const viewsMenuItems = estimateViews.map((view) => {
|
||||
return (
|
||||
<MenuItem href={`${path}/${view.id}/custom_view`} text={view.name} />
|
||||
);
|
||||
});
|
||||
|
||||
const handleTabChange = (viewId) => {
|
||||
changeEstimateView(viewId.id || -1);
|
||||
addEstimatesTableQueries({
|
||||
custom_view_id: viewId.id || null,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
<Popover
|
||||
content={<Menu>{viewsMenuItems}</Menu>}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.HOVER}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button
|
||||
className={classNames(Classes.MINIMAL, 'button--table-views')}
|
||||
icon={<Icon icon="table-16" iconSize={16} />}
|
||||
text={<T id={'table_views'} />}
|
||||
rightIcon={'caret-down'}
|
||||
/>
|
||||
</Popover>
|
||||
<DashboardActionViewsList
|
||||
resourceName={'estimates'}
|
||||
views={estimateViews}
|
||||
onChange={handleTabChange}
|
||||
/>
|
||||
|
||||
<NavbarDivider />
|
||||
<Button
|
||||
@@ -151,7 +126,7 @@ function EstimateActionsBar({
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, props) => ({
|
||||
resourceName: 'sales_estimates',
|
||||
resourceName: 'sale_estimate',
|
||||
});
|
||||
const withEstimateActionsBar = connect(mapStateToProps);
|
||||
|
||||
|
||||
@@ -49,18 +49,19 @@ function EstimateList({
|
||||
|
||||
const [selectedRows, setSelectedRows] = useState([]);
|
||||
|
||||
// const fetchResourceViews = useQuery(
|
||||
// ['resource-views', 'sales_estimates'],
|
||||
// (key, resourceName) => requestFetchResourceViews(resourceName),
|
||||
// );
|
||||
const fetchResourceViews = useQuery(
|
||||
['resource-views', 'sale_estimate'],
|
||||
(key, resourceName) => requestFetchResourceViews(resourceName),
|
||||
);
|
||||
|
||||
// const fetchResourceFields = useQuery(
|
||||
// ['resource-fields', 'sales_estimates'],
|
||||
// (key, resourceName) => requestFetchResourceFields(resourceName),
|
||||
// );
|
||||
const fetchResourceFields = useQuery(
|
||||
['resource-fields', 'sale_estimate'],
|
||||
(key, resourceName) => requestFetchResourceFields(resourceName),
|
||||
);
|
||||
|
||||
const fetchEstimate = useQuery(['estimates-table', estimatesTableQuery], () =>
|
||||
requestFetchEstimatesTable(),
|
||||
const fetchEstimate = useQuery(
|
||||
['estimates-table', estimatesTableQuery],
|
||||
(key, _query) => requestFetchEstimatesTable({ ..._query }),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -117,7 +118,7 @@ function EstimateList({
|
||||
queryCache.invalidateQueries('estimates-table');
|
||||
})
|
||||
.catch((error) => {
|
||||
// setDeliverEstimate(false);
|
||||
setDeliverEstimate(false);
|
||||
});
|
||||
}, [deliverEstimate, requestDeliverdEstimate, formatMessage]);
|
||||
|
||||
@@ -145,7 +146,7 @@ function EstimateList({
|
||||
queryCache.invalidateQueries('estimates-table');
|
||||
})
|
||||
.catch((error) => {
|
||||
// setApproveEstimate(false);
|
||||
setApproveEstimate(false);
|
||||
});
|
||||
}, [approveEstimate, requestApproveEstimate, formatMessage]);
|
||||
|
||||
@@ -176,7 +177,7 @@ function EstimateList({
|
||||
}, [rejectEstimate, requestRejectEstimate, formatMessage]);
|
||||
|
||||
// Handle filter change to re-fetch data-table.
|
||||
const handleFilterChanged = useCallback(() => {}, [fetchEstimate]);
|
||||
const handleFilterChanged = useCallback(() => {}, []);
|
||||
|
||||
// Calculates the selected rows
|
||||
const selectedRowsCount = useMemo(() => Object.values(selectedRows).length, [
|
||||
@@ -198,8 +199,8 @@ function EstimateList({
|
||||
);
|
||||
return (
|
||||
<DashboardInsider
|
||||
// loading={fetchResourceViews.isFetching || fetchResourceFields.isFetching}
|
||||
name={'sales_estimates'}
|
||||
loading={fetchResourceViews.isFetching || fetchResourceFields.isFetching}
|
||||
name={'sale_estimate'}
|
||||
>
|
||||
<EstimateActionsBar
|
||||
// onBulkDelete={}
|
||||
|
||||
@@ -6,7 +6,6 @@ import { connect } from 'react-redux';
|
||||
import { pick, debounce } from 'lodash';
|
||||
|
||||
import { DashboardViewsTabs } from 'components';
|
||||
import { useUpdateEffect } from 'hooks';
|
||||
|
||||
import withEstimates from './withEstimates';
|
||||
import withEstimateActions from './withEstimateActions';
|
||||
@@ -15,6 +14,9 @@ import withViewDetails from 'containers/Views/withViewDetails';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Estimates views tabs.
|
||||
*/
|
||||
function EstimateViewTabs({
|
||||
// #withExpenses
|
||||
estimateViews,
|
||||
@@ -37,53 +39,35 @@ function EstimateViewTabs({
|
||||
const { custom_view_id: customViewId = null } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
changeEstimateView(customViewId || -1);
|
||||
setTopbarEditView(customViewId);
|
||||
changePageSubtitle(customViewId && viewItem ? viewItem.name : '');
|
||||
|
||||
addEstimatesTableQueries({
|
||||
custom_view_id: customViewId,
|
||||
});
|
||||
return () => {
|
||||
setTopbarEditView(null);
|
||||
changePageSubtitle('');
|
||||
changeEstimateView(null);
|
||||
};
|
||||
}, [customViewId, addEstimatesTableQueries, changeEstimateView]);
|
||||
|
||||
useUpdateEffect(() => {
|
||||
onViewChanged && onViewChanged(customViewId);
|
||||
}, [customViewId]);
|
||||
|
||||
const debounceChangeHistory = useRef(
|
||||
debounce((toUrl) => {
|
||||
history.push(toUrl);
|
||||
}, 250),
|
||||
);
|
||||
|
||||
const handleTabsChange = (viewId) => {
|
||||
const toPath = viewId ? `${viewId}/custom_view` : '';
|
||||
debounceChangeHistory.current(`/estimates/${toPath}`);
|
||||
setTopbarEditView(viewId);
|
||||
};
|
||||
const tabs = estimateViews.map((view) => ({
|
||||
...pick(view, ['name', 'id']),
|
||||
}));
|
||||
|
||||
const handleTabsChange = (viewId) => {
|
||||
changeEstimateView(viewId || -1);
|
||||
addEstimatesTableQueries({
|
||||
custom_view_id: viewId || null,
|
||||
});
|
||||
setTopbarEditView(viewId);
|
||||
};
|
||||
|
||||
// Handle click a new view tab.
|
||||
const handleClickNewView = () => {
|
||||
setTopbarEditView(null);
|
||||
history.push('/custom_views/estimates/new');
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<Navbar className={'navbar--dashboard-views'}>
|
||||
<NavbarGroup align={Alignment.LEFT}>
|
||||
<DashboardViewsTabs
|
||||
initialViewId={customViewId}
|
||||
baseUrl={'/estimates'}
|
||||
resourceName={'estimates'}
|
||||
tabs={tabs}
|
||||
onNewViewTabClick={handleClickNewView}
|
||||
onChange={handleTabsChange}
|
||||
/>
|
||||
</NavbarGroup>
|
||||
|
||||
@@ -20,7 +20,7 @@ export default (mapState) => {
|
||||
estimatesCurrentPage: getEstimatesItems(state, props, query),
|
||||
estimatesCurrentViewId: getEstimatesCurrentViewId(state, props),
|
||||
|
||||
estimateViews: getResourceViews(state, props, 'sales_estimates'),
|
||||
estimateViews: getResourceViews(state, props, 'sale_estimate'),
|
||||
estimateItems: state.salesEstimates.items,
|
||||
|
||||
estimatesTableQuery: query,
|
||||
|
||||
@@ -3,8 +3,6 @@ import Icon from 'components/Icon';
|
||||
import {
|
||||
Button,
|
||||
Classes,
|
||||
Menu,
|
||||
MenuItem,
|
||||
Popover,
|
||||
NavbarDivider,
|
||||
NavbarGroup,
|
||||
@@ -40,13 +38,12 @@ function InvoiceActionsBar({
|
||||
|
||||
// #withInvoiceActions
|
||||
addInvoiceTableQueries,
|
||||
|
||||
changeInvoiceView,
|
||||
// #own Porps
|
||||
onFilterChanged,
|
||||
selectedRows = [],
|
||||
}) {
|
||||
const history = useHistory();
|
||||
const { path } = useRouteMatch();
|
||||
const [filterCount, setFilterCount] = useState(0);
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
@@ -54,10 +51,21 @@ function InvoiceActionsBar({
|
||||
history.push('/invoices/new');
|
||||
}, [history]);
|
||||
|
||||
const hasSelectedRows = useMemo(() => selectedRows.length > 0, [
|
||||
selectedRows,
|
||||
]);
|
||||
|
||||
const handleTabChange = (viewId) => {
|
||||
changeInvoiceView(viewId.id || -1);
|
||||
addInvoiceTableQueries({
|
||||
custom_view_id: viewId.id || null,
|
||||
});
|
||||
};
|
||||
|
||||
// const filterDropdown = FilterDropdown({
|
||||
// initialCondition: {
|
||||
// fieldKey: 'reference_no',
|
||||
// compatator: 'contains',
|
||||
// fieldKey: '',
|
||||
// compatator: '',
|
||||
// value: '',
|
||||
// },
|
||||
// fields: resourceFields,
|
||||
@@ -69,16 +77,13 @@ function InvoiceActionsBar({
|
||||
// },
|
||||
// });
|
||||
|
||||
const hasSelectedRows = useMemo(() => selectedRows.length > 0, [
|
||||
selectedRows,
|
||||
]);
|
||||
|
||||
return (
|
||||
<DashboardActionsBar>
|
||||
<NavbarGroup>
|
||||
<DashboardActionViewsList
|
||||
resourceName={'sales_invoices'}
|
||||
resourceName={'invoices'}
|
||||
views={invoicesViews}
|
||||
onChange={handleTabChange}
|
||||
/>
|
||||
<NavbarDivider />
|
||||
<Button
|
||||
|
||||
@@ -51,18 +51,19 @@ function InvoiceList({
|
||||
changePageTitle(formatMessage({ id: 'invoice_list' }));
|
||||
}, [changePageTitle, formatMessage]);
|
||||
|
||||
// const fetchResourceViews = useQuery(
|
||||
// ['resource-views', 'sales_invoices'],
|
||||
// (key, resourceName) => requestFetchResourceViews(resourceName),
|
||||
// );
|
||||
const fetchResourceViews = useQuery(
|
||||
['resource-views', 'sale_invoice'],
|
||||
(key, resourceName) => requestFetchResourceViews(resourceName),
|
||||
);
|
||||
|
||||
// const fetchResourceFields = useQuery(
|
||||
// ['resource-fields', 'sales_invoices'],
|
||||
// (key, resourceName) => requestFetchResourceFields(resourceName),
|
||||
// );
|
||||
const fetchResourceFields = useQuery(
|
||||
['resource-fields', 'sale_invoice'],
|
||||
(key, resourceName) => requestFetchResourceFields(resourceName),
|
||||
);
|
||||
|
||||
const fetchInvoices = useQuery(['invoices-table', invoicesTableQuery], () =>
|
||||
requestFetchInvoiceTable(),
|
||||
const fetchInvoices = useQuery(
|
||||
['invoices-table', invoicesTableQuery],
|
||||
(key, query) => requestFetchInvoiceTable({ ...query }),
|
||||
);
|
||||
//handle dalete Invoice
|
||||
const handleDeleteInvoice = useCallback(
|
||||
@@ -139,7 +140,7 @@ function InvoiceList({
|
||||
);
|
||||
return (
|
||||
<DashboardInsider
|
||||
// loading={fetchResourceViews.isFetching || fetchResourceFields.isFetching}
|
||||
loading={fetchResourceViews.isFetching || fetchResourceFields.isFetching}
|
||||
name={'sales_invoices'}
|
||||
>
|
||||
<InvoiceActionsBar
|
||||
|
||||
@@ -15,6 +15,9 @@ import withViewDetails from 'containers/Views/withViewDetails';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Invoices views tabs.
|
||||
*/
|
||||
function InvoiceViewTabs({
|
||||
//#withInvoices
|
||||
invoicesViews,
|
||||
@@ -38,54 +41,34 @@ function InvoiceViewTabs({
|
||||
const { custom_view_id: customViewId = null } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
changeInvoiceView(customViewId || -1);
|
||||
setTopbarEditView(customViewId);
|
||||
changePageSubtitle(customViewId && viewItem ? viewItem.name : '');
|
||||
|
||||
addInvoiceTableQueries({
|
||||
custom_view_id: customViewId,
|
||||
});
|
||||
return () => {
|
||||
setTopbarEditView(null);
|
||||
changePageSubtitle('');
|
||||
changeInvoiceView(null);
|
||||
};
|
||||
}, [customViewId, addInvoiceTableQueries, changeInvoiceView]);
|
||||
|
||||
useUpdateEffect(() => {
|
||||
onViewChanged && onViewChanged(customViewId);
|
||||
}, [customViewId]);
|
||||
|
||||
|
||||
|
||||
const debounceChangeHistory = useRef(
|
||||
debounce((toUrl) => {
|
||||
history.push(toUrl);
|
||||
}, 250),
|
||||
);
|
||||
|
||||
const handleTabsChange = (viewId) => {
|
||||
const toPath = viewId ? `${viewId}/custom_view` : '';
|
||||
debounceChangeHistory.current(`/invoices/${toPath}`);
|
||||
setTopbarEditView(viewId);
|
||||
};
|
||||
const tabs = invoicesViews.map((view) => ({
|
||||
...pick(view, ['name', 'id']),
|
||||
}));
|
||||
|
||||
const handleTabsChange = (viewId) => {
|
||||
changeInvoiceView(viewId || -1);
|
||||
addInvoiceTableQueries({
|
||||
custom_view_id: customViewId || null,
|
||||
});
|
||||
setTopbarEditView(viewId);
|
||||
};
|
||||
|
||||
// Handle click a new view tab.
|
||||
const handleClickNewView = () => {
|
||||
setTopbarEditView(null);
|
||||
history.push('/custom_views/invoices/new');
|
||||
};
|
||||
console.log(invoicesViews, 'invoicesViews');
|
||||
|
||||
return (
|
||||
<Navbar className={'navbar--dashboard-views'}>
|
||||
<NavbarGroup align={Alignment.LEFT}>
|
||||
<DashboardViewsTabs
|
||||
initialViewId={customViewId}
|
||||
baseUrl={'/invoices'}
|
||||
resourceName={'invoices'}
|
||||
tabs={tabs}
|
||||
onNewViewTabClick={handleClickNewView}
|
||||
onChange={handleTabsChange}
|
||||
|
||||
@@ -25,7 +25,7 @@ export default (mapState) => {
|
||||
invoicesCurrentPage: getInvoicesItems(state, props, query),
|
||||
invoicesCurrentViewId: getInvoicesCurrentViewId(state, props),
|
||||
|
||||
invoicesViews: getResourceViews(state, props, 'sales_invoices'),
|
||||
invoicesViews: getResourceViews(state, props, 'sale_invoice'),
|
||||
invoicesItems: state.salesInvoices.items,
|
||||
invoicesTableQuery: query,
|
||||
invoicesPageination: getInvoicesPaginationMeta(state, props, query),
|
||||
|
||||
@@ -21,7 +21,8 @@ export const fetchBillsTable = ({ query = {} }) => {
|
||||
payload: {
|
||||
bills: response.data.bills,
|
||||
pagination: response.data.pagination,
|
||||
customViewId: response.data.customViewId || -1,
|
||||
customViewId:
|
||||
response.data?.filter_meta?.view?.custom_view_id || -1,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
@@ -34,7 +35,8 @@ export const fetchBillsTable = ({ query = {} }) => {
|
||||
type: t.BILLS_PAGINATION_SET,
|
||||
payload: {
|
||||
pagination: response.data.pagination,
|
||||
customViewId: response.data.customViewId || -1,
|
||||
customViewId:
|
||||
response.data?.filter_meta?.view?.custom_view_id || -1,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
@@ -118,27 +120,32 @@ export const editBill = (id, form) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchDueBills = ({ vendorId }) => (dispatch) => new Promise((resolve, reject) => {
|
||||
const params = { vendor_id: vendorId };
|
||||
export const fetchDueBills = ({ vendorId }) => (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const params = { vendor_id: vendorId };
|
||||
|
||||
ApiService.get(`purchases/bills/due`, { params }).then((response) => {
|
||||
dispatch({
|
||||
type: t.BILLS_ITEMS_SET,
|
||||
payload: {
|
||||
bills: response.data.bills,
|
||||
},
|
||||
});
|
||||
if ( vendorId ) {
|
||||
dispatch({
|
||||
type: t.BILLS_PAYABLE_BY_VENDOR_ID,
|
||||
payload: {
|
||||
bills: response.data.bills,
|
||||
ApiService.get(`purchases/bills/due`, { params })
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.BILLS_ITEMS_SET,
|
||||
payload: {
|
||||
bills: response.data.bills,
|
||||
},
|
||||
});
|
||||
if (vendorId) {
|
||||
dispatch({
|
||||
type: t.BILLS_PAYABLE_BY_VENDOR_ID,
|
||||
payload: {
|
||||
bills: response.data.bills,
|
||||
},
|
||||
});
|
||||
}
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
}
|
||||
resolve(response);
|
||||
}).catch(error => { reject(error) });
|
||||
});
|
||||
});
|
||||
|
||||
export const openBill = ({ id }) => {
|
||||
return (dispatch) => ApiService.post(`purchases/bills/${id}/open`);
|
||||
|
||||
@@ -92,7 +92,8 @@ export const fetchEstimatesTable = ({ query = {} }) => {
|
||||
payload: {
|
||||
sales_estimates: response.data.sales_estimates,
|
||||
pagination: response.data.pagination,
|
||||
customViewId: response.data.customViewId || -1,
|
||||
customViewId:
|
||||
response.data?.filter_meta?.view?.custom_view_id || -1,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
@@ -105,7 +106,8 @@ export const fetchEstimatesTable = ({ query = {} }) => {
|
||||
type: t.ESTIMATES_PAGINATION_SET,
|
||||
payload: {
|
||||
pagination: response.data.pagination,
|
||||
customViewId: response.data.customViewId || -1,
|
||||
customViewId:
|
||||
response.data?.filter_meta?.view?.custom_view_id || -1,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
|
||||
@@ -69,7 +69,8 @@ export const fetchInvoicesTable = ({ query } = {}) => {
|
||||
payload: {
|
||||
sales_invoices: response.data.sales_invoices,
|
||||
pagination: response.data.pagination,
|
||||
customViewId: response.data.customViewId || -1,
|
||||
customViewId:
|
||||
response.data?.filter_meta?.view?.custom_view_id || -1,
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
@@ -82,7 +83,7 @@ export const fetchInvoicesTable = ({ query } = {}) => {
|
||||
type: t.INVOICES_PAGINATION_SET,
|
||||
payload: {
|
||||
pagination: response.data.pagination,
|
||||
customViewId: response.data.customViewId || -1,
|
||||
customViewId: response.data?.filter_meta?.view?.custom_view_id ||-1
|
||||
},
|
||||
});
|
||||
dispatch({
|
||||
|
||||
Reference in New Issue
Block a user