Files
bigcapital/client/src/containers/Sales/PaymentReceive/PaymentReceiveFormPage.js
Ahmed Bouhuolia 011542e2a3 feat: expand sidebar once open form editor page.
feat: rounding money amount.
feat: optimize page form structure.
feat: refactoring make journal and expense form with FastField component.
2020-11-29 00:10:18 +02:00

96 lines
2.5 KiB
JavaScript

import React, { useEffect } from 'react';
import { useParams } from 'react-router-dom';
import { useIntl } from 'react-intl';
import { useQuery } from 'react-query';
import DashboardInsider from 'components/Dashboard/DashboardInsider';
import PaymentReceiveForm from './PaymentReceiveForm';
import withDashboardActions from "containers/Dashboard/withDashboardActions";
import withAccountsActions from 'containers/Accounts/withAccountsActions';
import withSettingsActions from 'containers/Settings/withSettingsActions';
import withPaymentReceivesActions from './withPaymentReceivesActions';
import withCustomersActions from 'containers/Customers/withCustomersActions';
import { compose } from 'utils';
/**
* Payment receive form page.
*/
function PaymentReceiveFormPage({
// #withDashboardAction
changePageTitle,
// #withAccountsActions
requestFetchAccounts,
// #withSettingsActions
requestFetchOptions,
// #withPaymentReceivesActions
requestFetchPaymentReceive,
// #withCustomersActions
requestFetchCustomers,
// #withDashboardActions
setSidebarShrink,
resetSidebarPreviousExpand,
}) {
const { id: paymentReceiveId } = useParams();
useEffect(() => {
// Shrink the sidebar by foce.
setSidebarShrink();
return () => {
// Reset the sidebar to the previous status.
resetSidebarPreviousExpand();
};
}, [resetSidebarPreviousExpand, setSidebarShrink]);
// 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) =>
requestFetchAccounts(),
);
// Fetch payment made settings.
const fetchSettings = useQuery(['settings'], () => requestFetchOptions({}));
// Fetches customers list.
const fetchCustomers = useQuery(
['customers-list'], () => requestFetchCustomers(),
);
return (
<DashboardInsider
loading={
fetchPaymentReceive.isFetching ||
fetchAccounts.isFetching ||
// fetchSettings.isFetching ||
fetchCustomers.isFetching
}
name={'payment-receive-form'}
>
<PaymentReceiveForm
paymentReceiveId={paymentReceiveId}
/>
</DashboardInsider>
)
}
export default compose(
withDashboardActions,
withAccountsActions,
withSettingsActions,
withPaymentReceivesActions,
withCustomersActions,
)(PaymentReceiveFormPage);