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

@@ -32,7 +32,8 @@ function MakeJournalEntriesPage({
// #withDashboardActions
setSidebarShrink,
resetSidebarPreviousExpand
resetSidebarPreviousExpand,
setDashboardBackLink
}) {
const history = useHistory();
const { id } = useParams();
@@ -40,10 +41,14 @@ function MakeJournalEntriesPage({
useEffect(() => {
// Shrink the sidebar by foce.
setSidebarShrink();
// Show the back link on dashboard topbar.
setDashboardBackLink('/manual-journals');
return () => {
// Reset the sidebar to the previous status.
resetSidebarPreviousExpand();
// Hide the back link on dashboard topbar.
setDashboardBackLink(false);
};
}, [resetSidebarPreviousExpand, setSidebarShrink]);

View File

@@ -10,6 +10,7 @@ export default (mapState) => {
editViewId: state.dashboard.topbarEditViewId,
sidebarExpended: state.dashboard.sidebarExpended,
preferencesPageTitle: state.dashboard.preferencesPageTitle,
dashboardBackLink: state.dashboard.backLink,
};
return mapState ? mapState(mapped, state, props) : mapped;
};

View File

@@ -57,6 +57,11 @@ const mapActionsToProps = (dispatch) => ({
recordSidebarPreviousExpand: () => dispatch({
type: t.RECORD_SIDEBAR_PREVIOUS_EXPAND,
}),
setDashboardBackLink: (backLink) => dispatch({
type: t.SET_DASHBOARD_BACK_LINK,
payload: { backLink }
})
});
export default connect(null, mapActionsToProps);

View File

@@ -30,6 +30,7 @@ function Expenses({
// #withDashboardActions
setSidebarShrink,
resetSidebarPreviousExpand,
setDashboardBackLink,
}) {
const history = useHistory();
const { id } = useParams();
@@ -37,12 +38,16 @@ function Expenses({
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 fetchAccounts = useQuery('accounts-list', (key) =>
requestFetchAccounts(),

View File

@@ -33,6 +33,7 @@ function Bills({
// #withDashboardActions
setSidebarShrink,
resetSidebarPreviousExpand,
setDashboardBackLink
}) {
const history = useHistory();
const { id } = useParams();
@@ -40,12 +41,16 @@ function Bills({
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]);
// Handle fetch accounts
const fetchAccounts = useQuery('accounts-list', (key) =>

View File

@@ -36,6 +36,7 @@ function PaymentMade({
changePageTitle,
setSidebarShrink,
resetSidebarPreviousExpand,
setDashboardBackLink
}) {
const { id: paymentMadeId } = useParams();
const { formatMessage } = useIntl();
@@ -43,12 +44,16 @@ function PaymentMade({
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]);
// Handle page title change in new and edit mode.
useEffect(() => {

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);