mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
Merge branch 'master' of https://github.com/abouolia/Bigcapital
This commit is contained in:
@@ -54,7 +54,7 @@ function ContactDuplicateForm({
|
||||
{({ isSubmitting }) => (
|
||||
<Form>
|
||||
<div className={Classes.DIALOG_BODY}>
|
||||
<p>
|
||||
<p class="paragraph">
|
||||
<T id={'are_you_sure_want_to_duplicate'} />
|
||||
</p>
|
||||
|
||||
@@ -66,7 +66,6 @@ function ContactDuplicateForm({
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
intent={inputIntent({ error, touched })}
|
||||
className={'form-group--select-list'}
|
||||
inline={true}
|
||||
helperText={<ErrorMessage name="contact_type" />}
|
||||
>
|
||||
<ListSelect
|
||||
|
||||
@@ -6,41 +6,52 @@ import ReferenceNumberForm from 'containers/JournalNumber/ReferenceNumberForm';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
|
||||
import { compose, optionsMapToArray, saveInvoke } from 'utils';
|
||||
import { compose, saveInvoke } from 'utils';
|
||||
import {
|
||||
transformFormToSettings,
|
||||
transformSettingsToForm,
|
||||
} from 'containers/JournalNumber/utils';
|
||||
|
||||
/**
|
||||
* Estimate number dialog's content.
|
||||
*/
|
||||
|
||||
function EstimateNumberDialogContent({
|
||||
// #withSettings
|
||||
nextNumber,
|
||||
numberPrefix,
|
||||
autoIncrement,
|
||||
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
|
||||
// #ownProps
|
||||
initialValues,
|
||||
onConfirm,
|
||||
}) {
|
||||
// Fetches the estimates settings.
|
||||
const { isLoading: isSettingsLoading } = useSettingsEstimates();
|
||||
|
||||
// Mutates the settings.
|
||||
const { mutateAsync: saveSettingsMutate } = useSaveSettings();
|
||||
|
||||
// Handle the submit form.
|
||||
const handleSubmitForm = (values, { setSubmitting }) => {
|
||||
const options = optionsMapToArray(values).map((option) => ({
|
||||
key: option.key,
|
||||
...option,
|
||||
group: 'sales_estimates',
|
||||
}));
|
||||
saveSettingsMutate({ options })
|
||||
.then(() => {
|
||||
setSubmitting(false);
|
||||
closeDialog('estimate-number-form');
|
||||
saveInvoke(onConfirm, values);
|
||||
})
|
||||
.catch(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
// Transformes the form values to settings to save it.
|
||||
const options = transformFormToSettings(values, 'sales_estimates');
|
||||
|
||||
const handleSuccess = () => {
|
||||
setSubmitting(false);
|
||||
closeDialog('estimate-number-form');
|
||||
saveInvoke(onConfirm, values);
|
||||
};
|
||||
const handleErrors = () => {
|
||||
setSubmitting(false);
|
||||
};
|
||||
if (values.incrementMode === 'manual-transaction') {
|
||||
handleSuccess();
|
||||
return;
|
||||
}
|
||||
saveSettingsMutate({ options }).then(handleSuccess).catch(handleErrors);
|
||||
};
|
||||
|
||||
const handleClose = useCallback(() => {
|
||||
@@ -50,8 +61,14 @@ function EstimateNumberDialogContent({
|
||||
return (
|
||||
<DialogContent isLoading={isSettingsLoading}>
|
||||
<ReferenceNumberForm
|
||||
initialNumber={nextNumber}
|
||||
initialPrefix={numberPrefix}
|
||||
initialValues={{
|
||||
...transformSettingsToForm({
|
||||
nextNumber,
|
||||
numberPrefix,
|
||||
autoIncrement,
|
||||
}),
|
||||
...initialValues,
|
||||
}}
|
||||
onSubmit={handleSubmitForm}
|
||||
onClose={handleClose}
|
||||
/>
|
||||
@@ -64,5 +81,6 @@ export default compose(
|
||||
withSettings(({ estimatesSettings }) => ({
|
||||
nextNumber: estimatesSettings?.nextNumber,
|
||||
numberPrefix: estimatesSettings?.numberPrefix,
|
||||
autoIncrement: estimatesSettings?.autoIncrement,
|
||||
})),
|
||||
)(EstimateNumberDialogContent);
|
||||
|
||||
@@ -8,12 +8,19 @@ const EstimateNumberDialogContent = lazy(() =>
|
||||
import('./EstimateNumberDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Estimate number dialog.
|
||||
*/
|
||||
function EstimateNumberDialog({
|
||||
dialogName,
|
||||
paylaod = { id: null },
|
||||
payload: { initialFormValues },
|
||||
isOpen,
|
||||
onConfirm
|
||||
}) {
|
||||
const handleConfirm = (values) => {
|
||||
saveInvoke(onConfirm, values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
@@ -25,8 +32,8 @@ function EstimateNumberDialog({
|
||||
>
|
||||
<DialogSuspense>
|
||||
<EstimateNumberDialogContent
|
||||
estimateNumberId={paylaod.id}
|
||||
onConfirm={(values) => saveInvoke(onConfirm, values)}/>
|
||||
initialValues={{ ...initialFormValues }}
|
||||
onConfirm={handleConfirm}/>
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback } from 'react';
|
||||
import React from 'react';
|
||||
import { useSaveSettings } from 'hooks/query';
|
||||
|
||||
import { InvoiceNumberDialogProvider } from './InvoiceNumberDialogProvider';
|
||||
@@ -7,57 +7,69 @@ import ReferenceNumberForm from 'containers/JournalNumber/ReferenceNumberForm';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
import withSettingsActions from 'containers/Settings/withSettingsActions';
|
||||
// import withInvoicesActions from 'containers/Sales/Invoice/withInvoiceActions';
|
||||
|
||||
import { compose, optionsMapToArray } from 'utils';
|
||||
import { compose } from 'utils';
|
||||
import {
|
||||
transformFormToSettings,
|
||||
transformSettingsToForm,
|
||||
} from 'containers/JournalNumber/utils';
|
||||
|
||||
/**
|
||||
* invoice number dialog's content.
|
||||
*/
|
||||
|
||||
function InvoiceNumberDialogContent({
|
||||
// #ownProps
|
||||
initialValues,
|
||||
onConfirm,
|
||||
|
||||
// #withSettings
|
||||
nextNumber,
|
||||
numberPrefix,
|
||||
autoIncrement,
|
||||
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
const { mutateAsync: saveSettings } = useSaveSettings();
|
||||
|
||||
// Handle the submit form.
|
||||
const handleSubmitForm = (values, { setSubmitting }) => {
|
||||
const { mode, ...autoModeValues } = values;
|
||||
// Handle the form success.
|
||||
const handleSuccess = () => {
|
||||
setSubmitting(false);
|
||||
closeDialog('invoice-number-form');
|
||||
onConfirm(values);
|
||||
};
|
||||
// Handle the form errors.
|
||||
const handleErrors = () => {
|
||||
setSubmitting(false);
|
||||
};
|
||||
if (values.incrementMode === 'manual-transaction') {
|
||||
handleSuccess();
|
||||
return;
|
||||
}
|
||||
// Transformes the form values to settings to save it.
|
||||
const options = transformFormToSettings(values, 'sales_invoices');
|
||||
|
||||
const options = optionsMapToArray(autoModeValues).map((option) => ({
|
||||
key: option.key,
|
||||
...option,
|
||||
group: 'sales_invoices',
|
||||
}));
|
||||
|
||||
saveSettings({ options })
|
||||
.then(() => {
|
||||
setSubmitting(false);
|
||||
closeDialog('invoice-number-form');
|
||||
onConfirm(values);
|
||||
})
|
||||
.catch(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
// Save the goddamn settings.
|
||||
saveSettings({ options }).then(handleSuccess).catch(handleErrors);
|
||||
};
|
||||
|
||||
// Handle the dialog close.
|
||||
const handleClose = useCallback(() => {
|
||||
const handleClose = () => {
|
||||
closeDialog('invoice-number-form');
|
||||
}, [closeDialog]);
|
||||
};
|
||||
|
||||
return (
|
||||
<InvoiceNumberDialogProvider>
|
||||
<ReferenceNumberForm
|
||||
initialNumber={nextNumber}
|
||||
initialPrefix={numberPrefix}
|
||||
initialValues={{
|
||||
...transformSettingsToForm({
|
||||
nextNumber,
|
||||
numberPrefix,
|
||||
autoIncrement,
|
||||
}),
|
||||
...initialValues,
|
||||
}}
|
||||
onSubmit={handleSubmitForm}
|
||||
onClose={handleClose}
|
||||
/>
|
||||
@@ -71,5 +83,6 @@ export default compose(
|
||||
withSettings(({ invoiceSettings }) => ({
|
||||
nextNumber: invoiceSettings?.nextNumber,
|
||||
numberPrefix: invoiceSettings?.numberPrefix,
|
||||
autoIncrement: invoiceSettings?.autoIncrement,
|
||||
})),
|
||||
)(InvoiceNumberDialogContent);
|
||||
|
||||
@@ -8,24 +8,32 @@ const InvoiceNumberDialogContent = lazy(() =>
|
||||
import('./InvoiceNumberDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Invoice number dialog.
|
||||
*/
|
||||
function InvoiceNumberDialog({
|
||||
dialogName,
|
||||
payload = { id: null },
|
||||
payload: { initialFormValues },
|
||||
isOpen,
|
||||
onConfirm,
|
||||
}) {
|
||||
const handleConfirm = (values) => {
|
||||
saveInvoke(onConfirm, values);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
title={<T id={'invoice_number_settings'} />}
|
||||
name={dialogName}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
isOpen={isOpen}
|
||||
title={<T id={'invoice_number_settings'} />}
|
||||
name={dialogName}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
isOpen={isOpen}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<InvoiceNumberDialogContent
|
||||
InvoiceNumberId={payload.id}
|
||||
onConfirm={(values) => saveInvoke(onConfirm, values)} />
|
||||
initialValues={{ ...initialFormValues }}
|
||||
onConfirm={handleConfirm}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
@@ -8,43 +8,50 @@ import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withSettingsActions from 'containers/Settings/withSettingsActions';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
|
||||
import { saveInvoke, compose, optionsMapToArray } from 'utils';
|
||||
import { saveInvoke, compose } from 'utils';
|
||||
import {
|
||||
transformFormToSettings,
|
||||
transformSettingsToForm,
|
||||
} from 'containers/JournalNumber/utils';
|
||||
|
||||
/**
|
||||
* payment receive number dialog's content.
|
||||
* Payment receive number dialog's content.
|
||||
*/
|
||||
|
||||
function PaymentNumberDialogContent({
|
||||
// #withSettings
|
||||
nextNumber,
|
||||
numberPrefix,
|
||||
autoIncrement,
|
||||
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
|
||||
// #ownProps
|
||||
onConfirm,
|
||||
initialValues
|
||||
}) {
|
||||
const { isLoading: isSettingsLoading } = useSettingsPaymentReceives();
|
||||
const { mutateAsync: saveSettingsMutate } = useSaveSettings();
|
||||
|
||||
// Handle submit form.
|
||||
const handleSubmitForm = (values, { setSubmitting }) => {
|
||||
const options = optionsMapToArray(values).map((option) => ({
|
||||
key: option.key,
|
||||
...option,
|
||||
group: 'payment_receives',
|
||||
}));
|
||||
// Transformes the form values to settings to save it.
|
||||
const options = transformFormToSettings(values, 'payment_receives');
|
||||
|
||||
saveSettingsMutate({ options })
|
||||
.then(() => {
|
||||
setSubmitting(false);
|
||||
closeDialog('payment-receive-number-form');
|
||||
const handleSuccess = () => {
|
||||
setSubmitting(false);
|
||||
closeDialog('payment-receive-number-form');
|
||||
|
||||
saveInvoke(onConfirm, values);
|
||||
})
|
||||
.catch(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
saveInvoke(onConfirm, values);
|
||||
};
|
||||
const handleErrors = () => {
|
||||
setSubmitting(false);
|
||||
};
|
||||
if (values.incrementMode === 'manual-transaction') {
|
||||
handleSuccess();
|
||||
return;
|
||||
}
|
||||
saveSettingsMutate({ options }).then(handleSuccess).catch(handleErrors);
|
||||
};
|
||||
|
||||
const handleClose = useCallback(() => {
|
||||
@@ -54,8 +61,14 @@ function PaymentNumberDialogContent({
|
||||
return (
|
||||
<DialogContent isLoading={isSettingsLoading}>
|
||||
<ReferenceNumberForm
|
||||
initialNumber={nextNumber}
|
||||
initialPrefix={numberPrefix}
|
||||
initialValues={{
|
||||
...transformSettingsToForm({
|
||||
nextNumber,
|
||||
numberPrefix,
|
||||
autoIncrement,
|
||||
}),
|
||||
...initialValues,
|
||||
}}
|
||||
onSubmit={handleSubmitForm}
|
||||
onClose={handleClose}
|
||||
/>
|
||||
@@ -69,5 +82,6 @@ export default compose(
|
||||
withSettings(({ paymentReceiveSettings }) => ({
|
||||
nextNumber: paymentReceiveSettings?.nextNumber,
|
||||
numberPrefix: paymentReceiveSettings?.numberPrefix,
|
||||
autoIncrement: paymentReceiveSettings?.autoIncrement,
|
||||
})),
|
||||
)(PaymentNumberDialogContent);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Dialog, DialogSuspense } from 'components';
|
||||
import withDialogRedux from 'components/DialogReduxConnect';
|
||||
import { saveInvoke, compose } from 'utils';
|
||||
|
||||
const PaymentReceiveNumbereDialogConetnet = lazy(() =>
|
||||
const PaymentReceiveNumbereDialogContent = lazy(() =>
|
||||
import('./PaymentReceiveNumberDialogContent'),
|
||||
);
|
||||
|
||||
@@ -13,7 +13,7 @@ const PaymentReceiveNumbereDialogConetnet = lazy(() =>
|
||||
*/
|
||||
function PaymentReceiveNumberDialog({
|
||||
dialogName,
|
||||
payload = { id: null },
|
||||
payload: { initialFormValues },
|
||||
isOpen,
|
||||
onConfirm
|
||||
}) {
|
||||
@@ -26,8 +26,8 @@ function PaymentReceiveNumberDialog({
|
||||
isOpen={isOpen}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<PaymentReceiveNumbereDialogConetnet
|
||||
paymentReceiveNumberId={payload.id}
|
||||
<PaymentReceiveNumbereDialogContent
|
||||
initialValues={initialFormValues}
|
||||
onConfirm={(values) => saveInvoke(onConfirm, values)}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
|
||||
@@ -7,20 +7,25 @@ import ReferenceNumberForm from 'containers/JournalNumber/ReferenceNumberForm';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
|
||||
import { compose, optionsMapToArray, saveInvoke } from 'utils';
|
||||
import { compose, saveInvoke } from 'utils';
|
||||
import {
|
||||
transformFormToSettings,
|
||||
transformSettingsToForm,
|
||||
} from 'containers/JournalNumber/utils';
|
||||
|
||||
/**
|
||||
* Receipt number dialog's content.
|
||||
*/
|
||||
|
||||
function ReceiptNumberDialogContent({
|
||||
// #ownProps
|
||||
receiptId,
|
||||
receiptId,
|
||||
onConfirm,
|
||||
initialValues,
|
||||
|
||||
// #withSettings
|
||||
nextNumber,
|
||||
numberPrefix,
|
||||
autoIncrement,
|
||||
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
@@ -28,22 +33,24 @@ function ReceiptNumberDialogContent({
|
||||
const { isLoading: isSettingsLoading } = useSettingsReceipts();
|
||||
const { mutateAsync: saveSettingsMutate } = useSaveSettings();
|
||||
|
||||
// Handle the form submit.
|
||||
const handleSubmitForm = (values, { setSubmitting }) => {
|
||||
const options = optionsMapToArray(values).map((option) => ({
|
||||
key: option.key,
|
||||
...option,
|
||||
group: 'sales_receipts',
|
||||
}));
|
||||
const handleSuccess = () => {
|
||||
setSubmitting(false);
|
||||
closeDialog('receipt-number-form');
|
||||
saveInvoke(onConfirm, values);
|
||||
};
|
||||
const handleErrors = () => {
|
||||
setSubmitting(false);
|
||||
};
|
||||
if (values.incrementMode === 'manual-transaction') {
|
||||
handleSuccess();
|
||||
return;
|
||||
}
|
||||
// Transformes the form values to settings to save it.
|
||||
const options = transformFormToSettings(values, 'sales_receipts');
|
||||
|
||||
saveSettingsMutate({ options })
|
||||
.then(() => {
|
||||
setSubmitting(false);
|
||||
closeDialog('receipt-number-form');
|
||||
saveInvoke(onConfirm, values)
|
||||
})
|
||||
.catch(() => {
|
||||
setSubmitting(false);
|
||||
});
|
||||
saveSettingsMutate({ options }).then(handleSuccess).catch(handleErrors);
|
||||
};
|
||||
|
||||
const handleClose = useCallback(() => {
|
||||
@@ -53,8 +60,14 @@ function ReceiptNumberDialogContent({
|
||||
return (
|
||||
<DialogContent isLoading={isSettingsLoading}>
|
||||
<ReferenceNumberForm
|
||||
initialNumber={nextNumber}
|
||||
initialPrefix={numberPrefix}
|
||||
initialValues={{
|
||||
...transformSettingsToForm({
|
||||
nextNumber,
|
||||
numberPrefix,
|
||||
autoIncrement,
|
||||
}),
|
||||
...initialValues,
|
||||
}}
|
||||
onSubmit={handleSubmitForm}
|
||||
onClose={handleClose}
|
||||
/>
|
||||
@@ -67,5 +80,6 @@ export default compose(
|
||||
withSettings(({ receiptSettings }) => ({
|
||||
nextNumber: receiptSettings?.nextNumber,
|
||||
numberPrefix: receiptSettings?.numberPrefix,
|
||||
autoIncrement: receiptSettings?.autoIncrement,
|
||||
})),
|
||||
)(ReceiptNumberDialogContent);
|
||||
|
||||
@@ -13,7 +13,7 @@ const ReceiptNumberDialogContent = lazy(() =>
|
||||
*/
|
||||
function ReceiptNumberDialog({
|
||||
dialogName,
|
||||
paylaod = { id: null },
|
||||
payload: { initialFormValues = {} },
|
||||
isOpen,
|
||||
onConfirm,
|
||||
}) {
|
||||
@@ -31,7 +31,7 @@ function ReceiptNumberDialog({
|
||||
>
|
||||
<DialogSuspense>
|
||||
<ReceiptNumberDialogContent
|
||||
receiptId={paylaod.id}
|
||||
initialValues={{ ...initialFormValues }}
|
||||
onConfirm={handleConfirm}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
|
||||
Reference in New Issue
Block a user