feat: dashboard back link in expand mode.

This commit is contained in:
Ahmed Bouhuolia
2020-11-30 10:59:10 +02:00
parent 0acc998283
commit fe55c84941
19 changed files with 131 additions and 25 deletions

View File

@@ -28,7 +28,8 @@ function Estimates({
// #withDashboardActions
setSidebarShrink,
resetSidebarPreviousExpand
resetSidebarPreviousExpand,
setDashboardBackLink,
}) {
const history = useHistory();
const { id } = useParams();
@@ -36,12 +37,16 @@ function Estimates({
useEffect(() => {
// Shrink the sidebar by foce.
setSidebarShrink();
// Show the back link on dashboard topbar.
setDashboardBackLink(true);
return () => {
// Reset the sidebar to the previous status.
resetSidebarPreviousExpand();
// Hide the back link on dashboard topbar.
setDashboardBackLink(false);
};
}, [resetSidebarPreviousExpand, setSidebarShrink]);
}, [resetSidebarPreviousExpand, setSidebarShrink, setDashboardBackLink]);
const fetchEstimate = useQuery(
['estimate', id],

View File

@@ -29,6 +29,7 @@ function Invoices({
// #withDashboardActions
setSidebarShrink,
resetSidebarPreviousExpand,
setDashboardBackLink,
}) {
const history = useHistory();
const { id } = useParams();
@@ -36,18 +37,22 @@ function Invoices({
useEffect(() => {
// Shrink the sidebar by foce.
setSidebarShrink();
// Show the back link on dashboard topbar.
setDashboardBackLink(true);
return () => {
// Reset the sidebar to the previous status.
resetSidebarPreviousExpand();
// Hide the back link on dashboard topbar.
setDashboardBackLink(false);
};
}, [resetSidebarPreviousExpand, setSidebarShrink]);
}, [resetSidebarPreviousExpand, setSidebarShrink, setDashboardBackLink]);
const fetchInvoice = useQuery(
['invoice', id],
(key, _id) => requsetFetchInvoice(_id),
{ enabled: !!id },
);
);
const fetchSettings = useQuery(['settings'], () => requestFetchOptions({}));

View File

@@ -6,7 +6,7 @@ import { useQuery } from 'react-query';
import DashboardInsider from 'components/Dashboard/DashboardInsider';
import PaymentReceiveForm from './PaymentReceiveForm';
import withDashboardActions from "containers/Dashboard/withDashboardActions";
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import withAccountsActions from 'containers/Accounts/withAccountsActions';
import withSettingsActions from 'containers/Settings/withSettingsActions';
import withPaymentReceivesActions from './withPaymentReceivesActions';
@@ -18,7 +18,6 @@ import { compose } from 'utils';
* Payment receive form page.
*/
function PaymentReceiveFormPage({
// #withDashboardAction
changePageTitle,
@@ -37,25 +36,30 @@ function PaymentReceiveFormPage({
// #withDashboardActions
setSidebarShrink,
resetSidebarPreviousExpand,
setDashboardBackLink,
}) {
const { id: paymentReceiveId } = useParams();
useEffect(() => {
// Shrink the sidebar by foce.
setSidebarShrink();
// Show the back link on dashboard topbar.
setDashboardBackLink(true);
return () => {
// Reset the sidebar to the previous status.
resetSidebarPreviousExpand();
// Hide the back link on dashboard topbar.
setDashboardBackLink(false);
};
}, [resetSidebarPreviousExpand, setSidebarShrink]);
}, [resetSidebarPreviousExpand, setSidebarShrink, setDashboardBackLink]);
// Fetches payment recevie details.
const fetchPaymentReceive = useQuery(
['payment-receive', paymentReceiveId],
(key, _id) => requestFetchPaymentReceive(_id),
{ enabled: paymentReceiveId },
)
);
// Handle fetch accounts data.
const fetchAccounts = useQuery('accounts-list', (key) =>
@@ -66,8 +70,8 @@ function PaymentReceiveFormPage({
const fetchSettings = useQuery(['settings'], () => requestFetchOptions({}));
// Fetches customers list.
const fetchCustomers = useQuery(
['customers-list'], () => requestFetchCustomers(),
const fetchCustomers = useQuery(['customers-list'], () =>
requestFetchCustomers(),
);
return (
@@ -75,16 +79,14 @@ function PaymentReceiveFormPage({
loading={
fetchPaymentReceive.isFetching ||
fetchAccounts.isFetching ||
// fetchSettings.isFetching ||
// fetchSettings.isFetching ||
fetchCustomers.isFetching
}
name={'payment-receive-form'}
>
<PaymentReceiveForm
paymentReceiveId={paymentReceiveId}
/>
<PaymentReceiveForm paymentReceiveId={paymentReceiveId} />
</DashboardInsider>
)
);
}
export default compose(
@@ -93,4 +95,4 @@ export default compose(
withSettingsActions,
withPaymentReceivesActions,
withCustomersActions,
)(PaymentReceiveFormPage);
)(PaymentReceiveFormPage);

View File

@@ -33,6 +33,7 @@ function Receipts({
// #withDashboardActions
setSidebarShrink,
resetSidebarPreviousExpand,
setDashboardBackLink,
}) {
const history = useHistory();
const { id } = useParams();
@@ -40,12 +41,16 @@ function Receipts({
useEffect(() => {
// Shrink the sidebar by foce.
setSidebarShrink();
// Show the back link on dashboard topbar.
setDashboardBackLink(true);
return () => {
// Reset the sidebar to the previous status.
resetSidebarPreviousExpand();
// Hide the back link on dashboard topbar.
setDashboardBackLink(false);
};
}, [resetSidebarPreviousExpand, setSidebarShrink]);
}, [resetSidebarPreviousExpand, setSidebarShrink, setDashboardBackLink]);
const fetchReceipt = useQuery(
['receipt', id],
@@ -101,5 +106,5 @@ export default compose(
withItemsActions,
withAccountsActions,
withSettingsActions,
withDashboardActions
withDashboardActions,
)(Receipts);