Skip to content

Commit

Permalink
revert: form changes
Browse files Browse the repository at this point in the history
  • Loading branch information
abouolia committed Feb 21, 2024
1 parent 63708ae commit 4e40009
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function EstimateFloatingActions() {

// Handle submit & deliver button click.
const handleSubmitDeliverBtnClick = (event) => {
setSubmitPayload({ redirect: false, deliverViaMail: true });
setSubmitPayload({ redirect: true, deliver: true });
submitForm();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,11 @@ import {
handleErrors,
resetFormState,
} from './utils';
import { DialogsName } from '@/constants/dialogs';
import withDialogActions from '@/containers/Dialog/withDialogActions';

/**
* Estimate form.
*/
function EstimateForm({
// #withDialogActions
openDialog,

// #withSettings
estimateNextNumber,
estimateNumberPrefix,
Expand Down Expand Up @@ -113,7 +108,7 @@ function EstimateForm({
delivered: submitPayload.deliver,
};
// Handle the request success.
const onSuccess = (res) => {
const onSuccess = (response) => {
AppToaster.show({
message: intl.get(
isNewMode
Expand All @@ -131,11 +126,6 @@ function EstimateForm({
if (submitPayload.resetForm) {
resetFormState({ resetForm, initialValues, values });
}
if (submitPayload.deliverViaMail) {
openDialog(DialogsName.EstimateFormMailDeliver, {
estimateId: res.data.id,
});
}
};
// Handle the request error.
const onError = ({
Expand Down Expand Up @@ -190,7 +180,6 @@ function EstimateForm({
}

export default compose(
withDialogActions,
withSettings(({ estimatesSettings }) => ({
estimateNextNumber: estimatesSettings?.nextNumber,
estimateNumberPrefix: estimatesSettings?.numberPrefix,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ export default function InvoiceFloatingActions() {
const { setSubmitPayload, invoice } = useInvoiceFormContext();

// Handle submit & deliver button click.
const handleSubmitDeliverBtnClick = () => {
setSubmitPayload({ redirectToEdit: true, deliverViaMail: true });
const handleSubmitDeliverBtnClick = (event) => {
setSubmitPayload({ redirect: true, deliver: true });
submitForm();
};

// Handle submit, deliver & new button click.
const handleSubmitDeliverAndNewBtnClick = () => {
const handleSubmitDeliverAndNewBtnClick = (event) => {
setSubmitPayload({ redirect: false, deliver: true, resetForm: true });
submitForm();
};

// Handle submit, deliver & continue editing button click.
const handleSubmitDeliverContinueEditingBtnClick = () => {
const handleSubmitDeliverContinueEditingBtnClick = (event) => {
setSubmitPayload({ redirect: false, deliver: true });
submitForm();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,12 @@ import {
transformValueToRequest,
resetFormState,
} from './utils';
import {
InvoiceExchangeRateSync,
InvoiceNoSyncSettingsToForm,
} from './components';
import { DialogsName } from '@/constants/dialogs';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { InvoiceExchangeRateSync, InvoiceNoSyncSettingsToForm } from './components';

/**
* Invoice form.
*/
function InvoiceForm({
// #withDialogActions
openDialog,

// #withSettings
invoiceNextNumber,
invoiceNumberPrefix,
Expand Down Expand Up @@ -119,7 +111,7 @@ function InvoiceForm({
from_estimate_id: estimateId,
};
// Handle the request success.
const onSuccess = (res) => {
const onSuccess = () => {
AppToaster.show({
message: intl.get(
isNewMode
Expand All @@ -131,11 +123,6 @@ function InvoiceForm({
});
setSubmitting(false);

if (submitPayload.deliverViaMail) {
openDialog(DialogsName.InvoiceFormMailDeliver, {
invoiceId: res.data.id,
});
}
if (submitPayload.redirect) {
history.push('/invoices');
}
Expand Down Expand Up @@ -214,5 +201,4 @@ export default compose(
invoiceTermsConditions: invoiceSettings?.termsConditions,
})),
withCurrentOrganization(),
withDialogActions,
)(InvoiceForm);
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,12 @@ import {
transformFormValuesToRequest,
resetFormState,
} from './utils';
import {
ReceiptSyncAutoExRateToForm,
ReceiptSyncIncrementSettingsToForm,
} from './components';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import { DialogsName } from '@/constants/dialogs';
import { ReceiptSyncAutoExRateToForm, ReceiptSyncIncrementSettingsToForm } from './components';

/**
* Receipt form.
*/
function ReceiptForm({
// #withDialogActions
openDialog,

// #withSettings
receiptNextNumber,
receiptNumberPrefix,
Expand Down Expand Up @@ -92,7 +84,10 @@ function ReceiptForm({
}),
};
// Handle the form submit.
const handleFormSubmit = (values, { setErrors, setSubmitting }) => {
const handleFormSubmit = (
values,
{ setErrors, setSubmitting, resetForm },
) => {
const entries = values.entries.filter(
(item) => item.item_id && item.quantity,
);
Expand Down Expand Up @@ -129,11 +124,6 @@ function ReceiptForm({
if (submitPayload.resetForm) {
resetFormState();
}
if (submitPayload.deliverMail) {
openDialog(DialogsName.ReceiptFormMailDeliver, {
receiptId: response.data.id,
});
}
};

// Handle the request error.
Expand Down Expand Up @@ -189,7 +179,6 @@ function ReceiptForm({
}

export default compose(
withDialogActions,
withDashboardActions,
withSettings(({ receiptSettings }) => ({
receiptNextNumber: receiptSettings?.nextNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function ReceiptFormFloatingActions() {

// Handle submit & close button click.
const handleSubmitCloseBtnClick = (event) => {
setSubmitPayload({ redirect: false, deliverMail: true, status: true });
setSubmitPayload({ redirect: true, status: true });
submitForm();
};

Expand Down

0 comments on commit 4e40009

Please sign in to comment.