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