mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 07:40:32 +00:00
feat (*) : add referch button.
This commit is contained in:
@@ -9,11 +9,13 @@ import {
|
|||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Position,
|
Position,
|
||||||
Intent,
|
Intent,
|
||||||
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { FormattedMessage as T } from 'components';
|
import { FormattedMessage as T } from 'components';
|
||||||
|
|
||||||
|
import { useRefreshJournals } from 'hooks/query/manualJournals';
|
||||||
import { useManualJournalsContext } from './ManualJournalsListProvider';
|
import { useManualJournalsContext } from './ManualJournalsListProvider';
|
||||||
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
@@ -36,6 +38,9 @@ function ManualJournalActionsBar({
|
|||||||
// Manual journals context.
|
// Manual journals context.
|
||||||
const { journalsViews } = useManualJournalsContext();
|
const { journalsViews } = useManualJournalsContext();
|
||||||
|
|
||||||
|
// Manual journals refresh action.
|
||||||
|
const { refresh } = useRefreshJournals();
|
||||||
|
|
||||||
// Handle click a new manual journal.
|
// Handle click a new manual journal.
|
||||||
const onClickNewManualJournal = () => {
|
const onClickNewManualJournal = () => {
|
||||||
history.push('/make-journal-entry');
|
history.push('/make-journal-entry');
|
||||||
@@ -49,6 +54,11 @@ function ManualJournalActionsBar({
|
|||||||
setManualJournalsTableState({ customViewId: customView.id || null });
|
setManualJournalsTableState({ customViewId: customView.id || null });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle click a refresh Journals
|
||||||
|
const handleRefreshBtnClick = () => {
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -106,6 +116,13 @@ function ManualJournalActionsBar({
|
|||||||
text={<T id={'export'} />}
|
text={<T id={'export'} />}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
onClick={handleRefreshBtnClick}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
Position,
|
Position,
|
||||||
Intent,
|
Intent,
|
||||||
Switch,
|
Switch,
|
||||||
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FormattedMessage as T } from 'components';
|
import { FormattedMessage as T } from 'components';
|
||||||
@@ -20,6 +21,7 @@ import { If, DashboardActionViewsList } from 'components';
|
|||||||
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
||||||
import FilterDropdown from 'components/FilterDropdown';
|
import FilterDropdown from 'components/FilterDropdown';
|
||||||
|
|
||||||
|
import { useRefreshAccounts } from 'hooks/query/accounts';
|
||||||
import { useAccountsChartContext } from 'containers/Accounts/AccountsChartProvider';
|
import { useAccountsChartContext } from 'containers/Accounts/AccountsChartProvider';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
import withAccounts from 'containers/Accounts/withAccounts';
|
import withAccounts from 'containers/Accounts/withAccounts';
|
||||||
@@ -54,6 +56,9 @@ function AccountsActionsBar({
|
|||||||
openDialog('account-form', {});
|
openDialog('account-form', {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Accounts refresh action.
|
||||||
|
const { refresh } = useRefreshAccounts();
|
||||||
|
|
||||||
// Handle bulk accounts delete.
|
// Handle bulk accounts delete.
|
||||||
const handleBulkDelete = () => {
|
const handleBulkDelete = () => {
|
||||||
openAlert('accounts-bulk-delete', { accountsIds: accountsSelectedRows });
|
openAlert('accounts-bulk-delete', { accountsIds: accountsSelectedRows });
|
||||||
@@ -82,6 +87,11 @@ function AccountsActionsBar({
|
|||||||
setAccountsTableState({ inactiveMode: checked });
|
setAccountsTableState({ inactiveMode: checked });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle click a refresh accounts
|
||||||
|
const handleRefreshBtnClick = () => {
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -163,6 +173,13 @@ function AccountsActionsBar({
|
|||||||
onChange={handleInactiveSwitchChange}
|
onChange={handleInactiveSwitchChange}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
onClick={handleRefreshBtnClick}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import {
|
|||||||
Popover,
|
Popover,
|
||||||
Position,
|
Position,
|
||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Switch
|
Switch,
|
||||||
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T } from 'components';
|
import { FormattedMessage as T } from 'components';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
@@ -19,6 +20,7 @@ import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
|||||||
import { If, Icon, DashboardActionViewsList } from 'components';
|
import { If, Icon, DashboardActionViewsList } from 'components';
|
||||||
|
|
||||||
import { useCustomersListContext } from './CustomersListProvider';
|
import { useCustomersListContext } from './CustomersListProvider';
|
||||||
|
import { useRefreshCustomers } from 'hooks/query/customers';
|
||||||
|
|
||||||
import withCustomers from './withCustomers';
|
import withCustomers from './withCustomers';
|
||||||
import withCustomersActions from './withCustomersActions';
|
import withCustomersActions from './withCustomersActions';
|
||||||
@@ -46,6 +48,9 @@ function CustomerActionsBar({
|
|||||||
// Customers list context.
|
// Customers list context.
|
||||||
const { customersViews } = useCustomersListContext();
|
const { customersViews } = useCustomersListContext();
|
||||||
|
|
||||||
|
// Customers refresh action.
|
||||||
|
const { refresh } = useRefreshCustomers();
|
||||||
|
|
||||||
const onClickNewCustomer = () => {
|
const onClickNewCustomer = () => {
|
||||||
history.push('/customers/new');
|
history.push('/customers/new');
|
||||||
};
|
};
|
||||||
@@ -66,6 +71,11 @@ function CustomerActionsBar({
|
|||||||
setCustomersTableState({ inactiveMode: checked });
|
setCustomersTableState({ inactiveMode: checked });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle click a refresh customers
|
||||||
|
const handleRefreshBtnClick = () => {
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -120,9 +130,16 @@ function CustomerActionsBar({
|
|||||||
onChange={handleInactiveSwitchChange}
|
onChange={handleInactiveSwitchChange}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
onClick={handleRefreshBtnClick}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(
|
||||||
withCustomersActions,
|
withCustomersActions,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
Popover,
|
Popover,
|
||||||
Position,
|
Position,
|
||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FormattedMessage as T } from 'components';
|
import { FormattedMessage as T } from 'components';
|
||||||
@@ -19,6 +20,7 @@ import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
|||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import FilterDropdown from 'components/FilterDropdown';
|
import FilterDropdown from 'components/FilterDropdown';
|
||||||
|
|
||||||
|
import { useRefreshExchangeRate } from 'hooks/query/exchangeRates';
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
import withResourceDetail from 'containers/Resources/withResourceDetails';
|
import withResourceDetail from 'containers/Resources/withResourceDetails';
|
||||||
import withExchangeRatesActions from './withExchangeRatesActions';
|
import withExchangeRatesActions from './withExchangeRatesActions';
|
||||||
@@ -44,30 +46,23 @@ function ExchangeRateActionsBar({
|
|||||||
onBulkDelete,
|
onBulkDelete,
|
||||||
}) {
|
}) {
|
||||||
const [filterCount, setFilterCount] = useState(0);
|
const [filterCount, setFilterCount] = useState(0);
|
||||||
|
|
||||||
|
|
||||||
const onClickNewExchangeRate = () => {
|
const onClickNewExchangeRate = () => {
|
||||||
openDialog('exchangeRate-form', {});
|
openDialog('exchangeRate-form', {});
|
||||||
};
|
};
|
||||||
|
|
||||||
// const filterDropdown = FilterDropdown({
|
// Exchange rates refresh action.
|
||||||
// initialCondition: {
|
const { refresh } = useRefreshExchangeRate();
|
||||||
// fieldKey: '',
|
|
||||||
// compatator: 'contains',
|
|
||||||
// value: '',
|
|
||||||
// },
|
|
||||||
// fields: resourceFields,
|
|
||||||
// onFilterChange: (filterConditions) => {
|
|
||||||
// addExchangeRatesTableQueries({
|
|
||||||
// filter_roles: filterConditions || '',
|
|
||||||
// });
|
|
||||||
// onFilterChanged && onFilterChanged(filterConditions);
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
const hasSelectedRows = useMemo(() => selectedRows.length > 0, [
|
// Handle click a refresh sale estimates
|
||||||
selectedRows,
|
const handleRefreshBtnClick = () => {
|
||||||
]);
|
refresh();
|
||||||
|
};
|
||||||
|
|
||||||
|
const hasSelectedRows = useMemo(
|
||||||
|
() => selectedRows.length > 0,
|
||||||
|
[selectedRows],
|
||||||
|
);
|
||||||
|
|
||||||
const handelBulkDelete = useCallback(() => {
|
const handelBulkDelete = useCallback(() => {
|
||||||
onBulkDelete && onBulkDelete(selectedRows.map((r) => r.id));
|
onBulkDelete && onBulkDelete(selectedRows.map((r) => r.id));
|
||||||
@@ -124,6 +119,13 @@ function ExchangeRateActionsBar({
|
|||||||
text={<T id={'export'} />}
|
text={<T id={'export'} />}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
onClick={handleRefreshBtnClick}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Position,
|
Position,
|
||||||
Intent,
|
Intent,
|
||||||
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
@@ -19,6 +20,7 @@ import withDialogActions from 'containers/Dialog/withDialogActions';
|
|||||||
|
|
||||||
import { If, DashboardActionViewsList } from 'components';
|
import { If, DashboardActionViewsList } from 'components';
|
||||||
|
|
||||||
|
import { useRefreshExpenses } from 'hooks/query/expenses';
|
||||||
import { useExpensesListContext } from './ExpensesListProvider';
|
import { useExpensesListContext } from './ExpensesListProvider';
|
||||||
import withExpensesActions from './withExpensesActions';
|
import withExpensesActions from './withExpensesActions';
|
||||||
|
|
||||||
@@ -39,15 +41,16 @@ function ExpensesActionsBar({
|
|||||||
// Expenses list context.
|
// Expenses list context.
|
||||||
const { expensesViews } = useExpensesListContext();
|
const { expensesViews } = useExpensesListContext();
|
||||||
|
|
||||||
|
// Expenses refresh action.
|
||||||
|
const { refresh } = useRefreshExpenses();
|
||||||
|
|
||||||
// Handles the new expense buttn click.
|
// Handles the new expense buttn click.
|
||||||
const onClickNewExpense = () => {
|
const onClickNewExpense = () => {
|
||||||
history.push('/expenses/new');
|
history.push('/expenses/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle delete button click.
|
// Handle delete button click.
|
||||||
const handleBulkDelete = () => {
|
const handleBulkDelete = () => {};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// Handles the tab chaning.
|
// Handles the tab chaning.
|
||||||
const handleTabChange = (viewId) => {
|
const handleTabChange = (viewId) => {
|
||||||
@@ -55,6 +58,11 @@ function ExpensesActionsBar({
|
|||||||
customViewId: viewId.id || null,
|
customViewId: viewId.id || null,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle click a refresh
|
||||||
|
const handleRefreshBtnClick = () => {
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -81,7 +89,7 @@ function ExpensesActionsBar({
|
|||||||
className={classNames(Classes.MINIMAL, 'button--filter', {
|
className={classNames(Classes.MINIMAL, 'button--filter', {
|
||||||
'has-active-filters': filterCount > 0,
|
'has-active-filters': filterCount > 0,
|
||||||
})}
|
})}
|
||||||
text={<T id={'filter'}/>}
|
text={<T id={'filter'} />}
|
||||||
icon={<Icon icon="filter-16" iconSize={16} />}
|
icon={<Icon icon="filter-16" iconSize={16} />}
|
||||||
/>
|
/>
|
||||||
</Popover>
|
</Popover>
|
||||||
@@ -112,6 +120,13 @@ function ExpensesActionsBar({
|
|||||||
text={<T id={'export'} />}
|
text={<T id={'export'} />}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
onClick={handleRefreshBtnClick}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Position,
|
Position,
|
||||||
Intent,
|
Intent,
|
||||||
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
@@ -21,7 +22,7 @@ import { If, DashboardActionViewsList } from 'components';
|
|||||||
|
|
||||||
import withBillsActions from './withBillsActions';
|
import withBillsActions from './withBillsActions';
|
||||||
import { useBillsListContext } from './BillsListProvider';
|
import { useBillsListContext } from './BillsListProvider';
|
||||||
|
import { useRefreshBills } from 'hooks/query/bills';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,8 +34,8 @@ function BillActionsBar({
|
|||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
// React intl.
|
// Bills refresh action.
|
||||||
|
const { refresh } = useRefreshBills();
|
||||||
|
|
||||||
// Bills list context.
|
// Bills list context.
|
||||||
const { billsViews } = useBillsListContext();
|
const { billsViews } = useBillsListContext();
|
||||||
@@ -53,6 +54,11 @@ function BillActionsBar({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle click a refresh bills
|
||||||
|
const handleRefreshBtnClick = () => {
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -111,6 +117,13 @@ function BillActionsBar({
|
|||||||
text={<T id={'export'} />}
|
text={<T id={'export'} />}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
onClick={handleRefreshBtnClick}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Position,
|
Position,
|
||||||
Intent,
|
Intent,
|
||||||
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
@@ -21,7 +22,7 @@ import { If, DashboardActionViewsList } from 'components';
|
|||||||
|
|
||||||
import withPaymentMadeActions from './withPaymentMadeActions';
|
import withPaymentMadeActions from './withPaymentMadeActions';
|
||||||
import { usePaymentMadesListContext } from './PaymentMadesListProvider';
|
import { usePaymentMadesListContext } from './PaymentMadesListProvider';
|
||||||
|
import { useRefreshPaymentMades } from 'hooks/query/paymentMades';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +33,6 @@ function PaymentMadeActionsBar({
|
|||||||
setPaymentMadesTableState,
|
setPaymentMadesTableState,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
|
|
||||||
// Payment receives list context.
|
// Payment receives list context.
|
||||||
const { paymentMadesViews } = usePaymentMadesListContext();
|
const { paymentMadesViews } = usePaymentMadesListContext();
|
||||||
@@ -42,11 +42,18 @@ function PaymentMadeActionsBar({
|
|||||||
history.push('/payment-mades/new');
|
history.push('/payment-mades/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Payment receive refresh action.
|
||||||
|
const { refresh } = useRefreshPaymentMades();
|
||||||
|
|
||||||
// Handle tab changing.
|
// Handle tab changing.
|
||||||
const handleTabChange = (customView) => {
|
const handleTabChange = (customView) => {
|
||||||
setPaymentMadesTableState({ customViewId: customView.id || null });
|
setPaymentMadesTableState({ customViewId: customView.id || null });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle click a refresh payment receives.
|
||||||
|
const handleRefreshBtnClick = () => {
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -71,11 +78,7 @@ function PaymentMadeActionsBar({
|
|||||||
<Button
|
<Button
|
||||||
className={classNames(Classes.MINIMAL)}
|
className={classNames(Classes.MINIMAL)}
|
||||||
text={
|
text={
|
||||||
true ? (
|
true ? <T id={'filter'} /> : `${0} ${intl.get('filters_applied')}`
|
||||||
<T id={'filter'} />
|
|
||||||
) : (
|
|
||||||
`${0} ${intl.get('filters_applied')}`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
icon={<Icon icon={'filter-16'} iconSize={16} />}
|
icon={<Icon icon={'filter-16'} iconSize={16} />}
|
||||||
/>
|
/>
|
||||||
@@ -105,6 +108,13 @@ function PaymentMadeActionsBar({
|
|||||||
text={<T id={'export'} />}
|
text={<T id={'export'} />}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
onClick={handleRefreshBtnClick}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Position,
|
Position,
|
||||||
Intent,
|
Intent,
|
||||||
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
@@ -20,6 +21,7 @@ import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
|||||||
|
|
||||||
import withEstimatesActions from './withEstimatesActions';
|
import withEstimatesActions from './withEstimatesActions';
|
||||||
import { useEstimatesListContext } from './EstimatesListProvider';
|
import { useEstimatesListContext } from './EstimatesListProvider';
|
||||||
|
import { useRefreshEstimates } from 'hooks/query/estimates';
|
||||||
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
@@ -31,7 +33,6 @@ function EstimateActionsBar({
|
|||||||
setEstimatesTableState,
|
setEstimatesTableState,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
|
|
||||||
const [filterCount, setFilterCount] = useState(0);
|
const [filterCount, setFilterCount] = useState(0);
|
||||||
|
|
||||||
@@ -43,6 +44,9 @@ function EstimateActionsBar({
|
|||||||
history.push('/estimates/new');
|
history.push('/estimates/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Estimates refresh action.
|
||||||
|
const { refresh } = useRefreshEstimates();
|
||||||
|
|
||||||
// Handle tab change.
|
// Handle tab change.
|
||||||
const handleTabChange = (customView) => {
|
const handleTabChange = (customView) => {
|
||||||
setEstimatesTableState({
|
setEstimatesTableState({
|
||||||
@@ -50,8 +54,13 @@ function EstimateActionsBar({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle click a refresh sale estimates
|
||||||
|
const handleRefreshBtnClick = () => {
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
<DashboardActionViewsList
|
<DashboardActionViewsList
|
||||||
resourceName={'estimates'}
|
resourceName={'estimates'}
|
||||||
@@ -108,10 +117,15 @@ function EstimateActionsBar({
|
|||||||
text={<T id={'export'} />}
|
text={<T id={'export'} />}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
onClick={handleRefreshBtnClick}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default compose(
|
export default compose(withEstimatesActions)(EstimateActionsBar);
|
||||||
withEstimatesActions,
|
|
||||||
)(EstimateActionsBar);
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Position,
|
Position,
|
||||||
Intent,
|
Intent,
|
||||||
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
@@ -20,6 +21,7 @@ import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
|||||||
|
|
||||||
import { If, DashboardActionViewsList } from 'components';
|
import { If, DashboardActionViewsList } from 'components';
|
||||||
|
|
||||||
|
import { useRefreshInvoices } from 'hooks/query/invoices';
|
||||||
import { useInvoicesListContext } from './InvoicesListProvider';
|
import { useInvoicesListContext } from './InvoicesListProvider';
|
||||||
import withInvoiceActions from './withInvoiceActions';
|
import withInvoiceActions from './withInvoiceActions';
|
||||||
|
|
||||||
@@ -33,7 +35,6 @@ function InvoiceActionsBar({
|
|||||||
setInvoicesTableState,
|
setInvoicesTableState,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
|
|
||||||
const [filterCount, setFilterCount] = useState(0);
|
const [filterCount, setFilterCount] = useState(0);
|
||||||
|
|
||||||
@@ -45,11 +46,19 @@ function InvoiceActionsBar({
|
|||||||
history.push('/invoices/new');
|
history.push('/invoices/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Invoices refresh action.
|
||||||
|
const { refresh } = useRefreshInvoices();
|
||||||
|
|
||||||
// Handle views tab change.
|
// Handle views tab change.
|
||||||
const handleTabChange = (customView) => {
|
const handleTabChange = (customView) => {
|
||||||
setInvoicesTableState({ customViewId: customView.id || null });
|
setInvoicesTableState({ customViewId: customView.id || null });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle click a refresh sale invoices
|
||||||
|
const handleRefreshBtnClick = () => {
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -108,6 +117,13 @@ function InvoiceActionsBar({
|
|||||||
text={<T id={'export'} />}
|
text={<T id={'export'} />}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
onClick={handleRefreshBtnClick}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Position,
|
Position,
|
||||||
Intent,
|
Intent,
|
||||||
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
@@ -24,6 +25,7 @@ import withPaymentReceives from './withPaymentReceives';
|
|||||||
|
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
import { usePaymentReceivesListContext } from './PaymentReceiptsListProvider';
|
import { usePaymentReceivesListContext } from './PaymentReceiptsListProvider';
|
||||||
|
import { useRefreshPaymentReceive } from 'hooks/query/paymentReceives';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Payment receives actions bar.
|
* Payment receives actions bar.
|
||||||
@@ -43,11 +45,19 @@ function PaymentReceiveActionsBar({
|
|||||||
history.push('/payment-receives/new');
|
history.push('/payment-receives/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Payment receive refresh action.
|
||||||
|
const { refresh } = useRefreshPaymentReceive();
|
||||||
|
|
||||||
// Handle tab changing.
|
// Handle tab changing.
|
||||||
const handleTabChange = (viewId) => {
|
const handleTabChange = (viewId) => {
|
||||||
setPaymentReceivesTableState({ customViewId: viewId.id || null });
|
setPaymentReceivesTableState({ customViewId: viewId.id || null });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle click a refresh payment receives
|
||||||
|
const handleRefreshBtnClick = () => {
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -100,6 +110,13 @@ function PaymentReceiveActionsBar({
|
|||||||
text={<T id={'export'} />}
|
text={<T id={'export'} />}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
onClick={handleRefreshBtnClick}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Position,
|
Position,
|
||||||
Intent,
|
Intent,
|
||||||
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
@@ -21,7 +22,7 @@ import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
|||||||
|
|
||||||
import withReceiptsActions from './withReceiptsActions';
|
import withReceiptsActions from './withReceiptsActions';
|
||||||
import { useReceiptsListContext } from './ReceiptsListProvider';
|
import { useReceiptsListContext } from './ReceiptsListProvider';
|
||||||
|
import { useRefreshReceipts } from 'hooks/query/receipts';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +33,6 @@ function ReceiptActionsBar({
|
|||||||
setReceiptsTableState,
|
setReceiptsTableState,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
|
|
||||||
const [filterCount, setFilterCount] = useState(0);
|
const [filterCount, setFilterCount] = useState(0);
|
||||||
|
|
||||||
@@ -44,12 +44,20 @@ function ReceiptActionsBar({
|
|||||||
history.push('/receipts/new');
|
history.push('/receipts/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Sale receipt refresh action.
|
||||||
|
const { refresh } = useRefreshReceipts();
|
||||||
|
|
||||||
const handleTabChange = (customView) => {
|
const handleTabChange = (customView) => {
|
||||||
setReceiptsTableState({
|
setReceiptsTableState({
|
||||||
customViewId: customView.id || null,
|
customViewId: customView.id || null,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle click a refresh sale estimates
|
||||||
|
const handleRefreshBtnClick = () => {
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -109,6 +117,13 @@ function ReceiptActionsBar({
|
|||||||
text={<T id={'export'} />}
|
text={<T id={'export'} />}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
onClick={handleRefreshBtnClick}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ import {
|
|||||||
Popover,
|
Popover,
|
||||||
Position,
|
Position,
|
||||||
PopoverInteractionKind,
|
PopoverInteractionKind,
|
||||||
Switch
|
Switch,
|
||||||
|
Alignment,
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T } from 'components';
|
import { FormattedMessage as T } from 'components';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
@@ -18,6 +19,7 @@ import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
|||||||
import Icon from 'components/Icon';
|
import Icon from 'components/Icon';
|
||||||
import { If, DashboardActionViewsList } from 'components';
|
import { If, DashboardActionViewsList } from 'components';
|
||||||
|
|
||||||
|
import { useRefreshVendors } from 'hooks/query/vendors';
|
||||||
import { useVendorsListContext } from './VendorsListProvider';
|
import { useVendorsListContext } from './VendorsListProvider';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
@@ -32,19 +34,21 @@ import { compose } from 'utils';
|
|||||||
function VendorActionsBar({
|
function VendorActionsBar({
|
||||||
// #withVendorActions
|
// #withVendorActions
|
||||||
setVendorsTableState,
|
setVendorsTableState,
|
||||||
vendorsInactiveMode
|
vendorsInactiveMode,
|
||||||
}) {
|
}) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
|
|
||||||
// Vendors list context.
|
// Vendors list context.
|
||||||
const { vendorsViews } = useVendorsListContext();
|
const { vendorsViews } = useVendorsListContext();
|
||||||
|
|
||||||
// Handles new vendor button click.
|
// Handles new vendor button click.
|
||||||
const onClickNewVendor = () => {
|
const onClickNewVendor = () => {
|
||||||
history.push('/vendors/new');
|
history.push('/vendors/new');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Vendors refresh action.
|
||||||
|
const { refresh } = useRefreshVendors();
|
||||||
|
|
||||||
// Handle the active tab change.
|
// Handle the active tab change.
|
||||||
const handleTabChange = (customView) => {
|
const handleTabChange = (customView) => {
|
||||||
setVendorsTableState({ customViewId: customView.id || null });
|
setVendorsTableState({ customViewId: customView.id || null });
|
||||||
@@ -55,7 +59,12 @@ function VendorActionsBar({
|
|||||||
const checked = event.target.checked;
|
const checked = event.target.checked;
|
||||||
setVendorsTableState({ inactiveMode: checked });
|
setVendorsTableState({ inactiveMode: checked });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle click a refresh sale estimates
|
||||||
|
const handleRefreshBtnClick = () => {
|
||||||
|
refresh();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardActionsBar>
|
<DashboardActionsBar>
|
||||||
<NavbarGroup>
|
<NavbarGroup>
|
||||||
@@ -80,11 +89,7 @@ function VendorActionsBar({
|
|||||||
<Button
|
<Button
|
||||||
className={classNames(Classes.MINIMAL, 'button--filter')}
|
className={classNames(Classes.MINIMAL, 'button--filter')}
|
||||||
text={
|
text={
|
||||||
true ? (
|
true ? <T id={'filter'} /> : `${9} ${intl.get('filters_applied')}`
|
||||||
<T id={'filter'} />
|
|
||||||
) : (
|
|
||||||
`${9} ${intl.get('filters_applied')}`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
icon={<Icon icon="filter-16" iconSize={16} />}
|
icon={<Icon icon="filter-16" iconSize={16} />}
|
||||||
/>
|
/>
|
||||||
@@ -113,6 +118,13 @@ function VendorActionsBar({
|
|||||||
onChange={handleInactiveSwitchChange}
|
onChange={handleInactiveSwitchChange}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
<NavbarGroup align={Alignment.RIGHT}>
|
||||||
|
<Button
|
||||||
|
className={Classes.MINIMAL}
|
||||||
|
icon={<Icon icon="refresh-16" iconSize={14} />}
|
||||||
|
onClick={handleRefreshBtnClick}
|
||||||
|
/>
|
||||||
|
</NavbarGroup>
|
||||||
</DashboardActionsBar>
|
</DashboardActionsBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,3 +160,13 @@ export function useAccountTransactions(id, props) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRefreshAccounts() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries(t.ACCOUNTS);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export function useDeleteBill(props) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const transformBillsResponse = (response) => ({
|
const transformBillsResponse = (response) => ({
|
||||||
bills: response.data.bills,
|
bills: response.data.bills,
|
||||||
pagination: transformPagination(response.data.pagination),
|
pagination: transformPagination(response.data.pagination),
|
||||||
filterMeta: response.data.filter_meta,
|
filterMeta: response.data.filter_meta,
|
||||||
@@ -131,7 +131,7 @@ export function useBills(query, props) {
|
|||||||
export function useBill(id, props) {
|
export function useBill(id, props) {
|
||||||
return useRequestQuery(
|
return useRequestQuery(
|
||||||
[t.BILL, id],
|
[t.BILL, id],
|
||||||
{ method: 'get', url: `/purchases/bills/${id}`, },
|
{ method: 'get', url: `/purchases/bills/${id}` },
|
||||||
{
|
{
|
||||||
select: (res) => res.data.bill,
|
select: (res) => res.data.bill,
|
||||||
defaultData: {},
|
defaultData: {},
|
||||||
@@ -159,3 +159,13 @@ export function useDueBills(vendorId, props) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRefreshBills() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries(t.BILLS);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const commonInvalidateQueries = (queryClient) => {
|
|||||||
const customersSelector = (response) => ({
|
const customersSelector = (response) => ({
|
||||||
customers: response.data.customers,
|
customers: response.data.customers,
|
||||||
pagination: transformPagination(response.data.pagination),
|
pagination: transformPagination(response.data.pagination),
|
||||||
filterMeta: response.data.filter_meta,
|
filterMeta: response.data.filter_meta,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,7 +66,7 @@ export function useEditCustomer(props) {
|
|||||||
// Common invalidate queries.
|
// Common invalidate queries.
|
||||||
commonInvalidateQueries(queryClient);
|
commonInvalidateQueries(queryClient);
|
||||||
},
|
},
|
||||||
...props
|
...props,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -78,19 +78,16 @@ export function useDeleteCustomer(props) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation((id) => apiRequest.delete(`customers/${id}`), {
|
||||||
(id) => apiRequest.delete(`customers/${id}`),
|
onSuccess: (res, id) => {
|
||||||
{
|
// Invalidate specific customer.
|
||||||
onSuccess: (res, id) => {
|
queryClient.invalidateQueries([t.CUSTOMER, id]);
|
||||||
// Invalidate specific customer.
|
|
||||||
queryClient.invalidateQueries([t.CUSTOMER, id]);
|
|
||||||
|
|
||||||
// Common invalidate queries.
|
// Common invalidate queries.
|
||||||
commonInvalidateQueries(queryClient);
|
commonInvalidateQueries(queryClient);
|
||||||
},
|
},
|
||||||
...props,
|
...props,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,15 +97,13 @@ export function useCreateCustomer(props) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation((values) => apiRequest.post('customers', values), {
|
||||||
(values) => apiRequest.post('customers', values),
|
onSuccess: () => {
|
||||||
{
|
// Common invalidate queries.
|
||||||
onSuccess: () => {
|
commonInvalidateQueries(queryClient);
|
||||||
// Common invalidate queries.
|
},
|
||||||
commonInvalidateQueries(queryClient);
|
...props,
|
||||||
},
|
});
|
||||||
...props
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,7 +116,17 @@ export function useCustomer(id, props) {
|
|||||||
{
|
{
|
||||||
select: (res) => res.data.customer,
|
select: (res) => res.data.customer,
|
||||||
defaultData: {},
|
defaultData: {},
|
||||||
...props
|
...props,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRefreshCustomers() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries(t.CUSTOMERS);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import useApiRequest from '../useRequest';
|
|||||||
import { transformPagination } from 'utils';
|
import { transformPagination } from 'utils';
|
||||||
import t from './types';
|
import t from './types';
|
||||||
|
|
||||||
|
|
||||||
const commonInvalidateQueries = (queryClient) => {
|
const commonInvalidateQueries = (queryClient) => {
|
||||||
// Invalidate estimates.
|
// Invalidate estimates.
|
||||||
queryClient.invalidateQueries(t.SALE_ESTIMATES);
|
queryClient.invalidateQueries(t.SALE_ESTIMATES);
|
||||||
@@ -69,7 +68,7 @@ export function useEstimate(id, props) {
|
|||||||
const transformEstimates = (res) => ({
|
const transformEstimates = (res) => ({
|
||||||
estimates: res.data.sales_estimates,
|
estimates: res.data.sales_estimates,
|
||||||
pagination: transformPagination(res.data.pagination),
|
pagination: transformPagination(res.data.pagination),
|
||||||
filterMeta: res.data.filter_meta,
|
filterMeta: res.data.filter_meta,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,19 +120,16 @@ export function useDeliverEstimate(props) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation((id) => apiRequest.post(`sales/estimates/${id}/deliver`), {
|
||||||
(id) => apiRequest.post(`sales/estimates/${id}/deliver`),
|
onSuccess: (res, id) => {
|
||||||
{
|
// Common invalidate queries.
|
||||||
onSuccess: (res, id) => {
|
commonInvalidateQueries(queryClient);
|
||||||
// Common invalidate queries.
|
|
||||||
commonInvalidateQueries(queryClient);
|
|
||||||
|
|
||||||
// Invalidate specific sale estimate.
|
// Invalidate specific sale estimate.
|
||||||
queryClient.invalidateQueries([t.SALE_ESTIMATE, id]);
|
queryClient.invalidateQueries([t.SALE_ESTIMATE, id]);
|
||||||
},
|
|
||||||
...props,
|
|
||||||
},
|
},
|
||||||
);
|
...props,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,19 +139,16 @@ export function useApproveEstimate(props) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation((id) => apiRequest.post(`sales/estimates/${id}/approve`), {
|
||||||
(id) => apiRequest.post(`sales/estimates/${id}/approve`),
|
onSuccess: (res, id) => {
|
||||||
{
|
// Common invalidate queries.
|
||||||
onSuccess: (res, id) => {
|
commonInvalidateQueries(queryClient);
|
||||||
// Common invalidate queries.
|
|
||||||
commonInvalidateQueries(queryClient);
|
|
||||||
|
|
||||||
// Invalidate specific sale estimate.
|
// Invalidate specific sale estimate.
|
||||||
queryClient.invalidateQueries([t.SALE_ESTIMATE, id]);
|
queryClient.invalidateQueries([t.SALE_ESTIMATE, id]);
|
||||||
},
|
|
||||||
...props,
|
|
||||||
},
|
},
|
||||||
);
|
...props,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -165,17 +158,24 @@ export function useRejectEstimate(props) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation((id) => apiRequest.post(`sales/estimates/${id}/reject`), {
|
||||||
(id) => apiRequest.post(`sales/estimates/${id}/reject`),
|
onSuccess: (res, id) => {
|
||||||
{
|
// Common invalidate queries.
|
||||||
onSuccess: (res, id) => {
|
commonInvalidateQueries(queryClient);
|
||||||
// Common invalidate queries.
|
|
||||||
commonInvalidateQueries(queryClient);
|
|
||||||
|
|
||||||
// Invalidate specific sale estimate.
|
// Invalidate specific sale estimate.
|
||||||
queryClient.invalidateQueries([t.SALE_ESTIMATE, id]);
|
queryClient.invalidateQueries([t.SALE_ESTIMATE, id]);
|
||||||
},
|
|
||||||
...props,
|
|
||||||
},
|
},
|
||||||
);
|
...props,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRefreshEstimates() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries(t.SALE_ESTIMATES);
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,3 +89,13 @@ export function useExchangeRates(query, props) {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRefreshExchangeRate() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries('EXCHANGES_RATES');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -146,3 +146,13 @@ export function usePublishExpense(props) {
|
|||||||
...props,
|
...props,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRefreshExpenses() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries(t.EXPENSES);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -176,3 +176,13 @@ export function useDueInvoices(customerId, props) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRefreshInvoices() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries(t.SALE_INVOICES);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,16 +31,13 @@ export function useCreateJournal(props) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation((values) => apiRequest.post('manual-journals', values), {
|
||||||
(values) => apiRequest.post('manual-journals', values),
|
onSuccess: () => {
|
||||||
{
|
// Common invalidate queries.
|
||||||
onSuccess: () => {
|
commonInvalidateQueries(queryClient);
|
||||||
// Common invalidate queries.
|
|
||||||
commonInvalidateQueries(queryClient);
|
|
||||||
},
|
|
||||||
...props
|
|
||||||
},
|
},
|
||||||
);
|
...props,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,7 +57,7 @@ export function useEditJournal(props) {
|
|||||||
// Common invalidate queries.
|
// Common invalidate queries.
|
||||||
commonInvalidateQueries(queryClient);
|
commonInvalidateQueries(queryClient);
|
||||||
},
|
},
|
||||||
...props
|
...props,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -72,18 +69,15 @@ export function useDeleteJournal(props) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation((id) => apiRequest.delete(`manual-journals/${id}`), {
|
||||||
(id) => apiRequest.delete(`manual-journals/${id}`),
|
onSuccess: (res, id) => {
|
||||||
{
|
// Invalidate specific manual journal.
|
||||||
onSuccess: (res, id) => {
|
queryClient.invalidateQueries(t.MANUAL_JOURNAL, id);
|
||||||
// Invalidate specific manual journal.
|
|
||||||
queryClient.invalidateQueries(t.MANUAL_JOURNAL, id);
|
|
||||||
|
|
||||||
commonInvalidateQueries(queryClient);
|
commonInvalidateQueries(queryClient);
|
||||||
},
|
|
||||||
...props
|
|
||||||
},
|
},
|
||||||
);
|
...props,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,24 +87,21 @@ export function usePublishJournal(props) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation((id) => apiRequest.post(`manual-journals/${id}/publish`), {
|
||||||
(id) => apiRequest.post(`manual-journals/${id}/publish`),
|
onSuccess: (res, id) => {
|
||||||
{
|
// Invalidate specific manual journal.
|
||||||
onSuccess: (res, id) => {
|
queryClient.invalidateQueries(t.MANUAL_JOURNAL, id);
|
||||||
// Invalidate specific manual journal.
|
|
||||||
queryClient.invalidateQueries(t.MANUAL_JOURNAL, id);
|
|
||||||
|
|
||||||
commonInvalidateQueries(queryClient);
|
commonInvalidateQueries(queryClient);
|
||||||
},
|
|
||||||
...props
|
|
||||||
},
|
},
|
||||||
);
|
...props,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const transformJournals = (response) => ({
|
const transformJournals = (response) => ({
|
||||||
manualJournals: response.data.manual_journals,
|
manualJournals: response.data.manual_journals,
|
||||||
pagination: transformPagination(response.data.pagination),
|
pagination: transformPagination(response.data.pagination),
|
||||||
filterMeta: response.data.filter_meta
|
filterMeta: response.data.filter_meta,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,3 +137,13 @@ export function useJournal(id, props) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRefreshJournals() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries(t.MANUAL_JOURNALS);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,11 +4,10 @@ import { transformPagination } from 'utils';
|
|||||||
import useApiRequest from '../useRequest';
|
import useApiRequest from '../useRequest';
|
||||||
import t from './types';
|
import t from './types';
|
||||||
|
|
||||||
|
|
||||||
const commonInvalidateQueries = (client) => {
|
const commonInvalidateQueries = (client) => {
|
||||||
// Invalidate payment mades.
|
// Invalidate payment mades.
|
||||||
client.invalidateQueries(t.PAYMENT_MADES);
|
client.invalidateQueries(t.PAYMENT_MADES);
|
||||||
|
|
||||||
// Invalidate payment made new entries.
|
// Invalidate payment made new entries.
|
||||||
client.invalidateQueries(t.PAYMENT_MADE_NEW_ENTRIES);
|
client.invalidateQueries(t.PAYMENT_MADE_NEW_ENTRIES);
|
||||||
client.invalidateQueries(t.PAYMENT_MADE_EDIT_PAGE);
|
client.invalidateQueries(t.PAYMENT_MADE_EDIT_PAGE);
|
||||||
@@ -158,3 +157,13 @@ export function usePaymentMadeNewPageEntries(vendorId, props) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRefreshPaymentMades() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries(t.PAYMENT_MADES);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -30,7 +30,7 @@ const commonInvalidateQueries = (client) => {
|
|||||||
const transformPaymentReceives = (res) => ({
|
const transformPaymentReceives = (res) => ({
|
||||||
paymentReceives: res.data.payment_receives,
|
paymentReceives: res.data.payment_receives,
|
||||||
pagination: transformPagination(res.data.pagination),
|
pagination: transformPagination(res.data.pagination),
|
||||||
filterMeta: res.data.filter_meta,
|
filterMeta: res.data.filter_meta,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,3 +160,13 @@ export function usePaymentReceiveEditPage(id, props) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRefreshPaymentReceive() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries(t.PAYMENT_RECEIVES);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ export function useCloseReceipt(props) {
|
|||||||
return useMutation((id) => apiRequest.post(`sales/receipts/${id}/close`), {
|
return useMutation((id) => apiRequest.post(`sales/receipts/${id}/close`), {
|
||||||
onSuccess: (res, id) => {
|
onSuccess: (res, id) => {
|
||||||
queryClient.invalidateQueries([t.SALE_RECEIPT, id]);
|
queryClient.invalidateQueries([t.SALE_RECEIPT, id]);
|
||||||
|
|
||||||
// Invalidate queries.
|
// Invalidate queries.
|
||||||
commonInvalidateQueries(queryClient);
|
commonInvalidateQueries(queryClient);
|
||||||
},
|
},
|
||||||
@@ -141,3 +141,13 @@ export function useReceipt(id, props) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRefreshReceipts() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries(t.SALE_RECEIPTS);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -114,3 +114,13 @@ export function useVendor(id, props) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useRefreshVendors() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
return {
|
||||||
|
refresh: () => {
|
||||||
|
queryClient.invalidateQueries(t.VENDORS);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user