refactoring: invoice form.

refactoring: receipt form.
refactoring: bill form.
refactoring: estimate form.
This commit is contained in:
a.bouhuolia
2021-02-15 16:23:58 +02:00
parent 151bd9bc54
commit e8458e2b36
37 changed files with 410 additions and 903 deletions

View File

@@ -21,9 +21,6 @@ function EstimateApproveAlert({
isOpen,
payload: { estimateId },
// #withEstimateActions
requestApproveEstimate,
// #withAlertActions
closeAlert,
}) {
@@ -59,7 +56,6 @@ function EstimateApproveAlert({
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'approve'} />}
icon="trash"
intent={Intent.WARNING}
isOpen={isOpen}
loading={isLoading}

View File

@@ -31,12 +31,12 @@ function EstimateDeleteAlert({
const { mutateAsync: deleteEstimateMutate, isLoading } = useDeleteEstimate();
// handle cancel delete alert.
const handleCancelEstimateDelete = () => {
const handleAlertCancel = () => {
closeAlert(name);
};
// handle confirm delete estimate
const handleConfirmEstimateDelete = useCallback(() => {
const handleAlertConfirm = () => {
deleteEstimateMutate(estimateId)
.then(() => {
AppToaster.show({
@@ -50,7 +50,7 @@ function EstimateDeleteAlert({
.finally(() => {
closeAlert(name);
});
}, [deleteEstimateMutate, name, closeAlert, formatMessage, estimateId]);
};
return (
<Alert
@@ -60,8 +60,8 @@ function EstimateDeleteAlert({
intent={Intent.DANGER}
isOpen={isOpen}
loading={isLoading}
onCancel={handleCancelEstimateDelete}
onConfirm={handleConfirmEstimateDelete}
onCancel={handleAlertCancel}
onConfirm={handleAlertConfirm}
>
<p>
<FormattedHTMLMessage

View File

@@ -1,7 +1,6 @@
import React, { useCallback, useState } from 'react';
import React from 'react';
import { FormattedMessage as T, useIntl } from 'react-intl';
import { Intent, Alert } from '@blueprintjs/core';
import { queryCache } from 'react-query';
import { useDeliverEstimate } from 'hooks/query';
import { AppToaster } from 'components';
@@ -28,12 +27,12 @@ function EstimateDeliveredAlert({
const { mutateAsync: deliverEstimateMutate, isLoading } = useDeliverEstimate();
// Handle cancel delivered estimate alert.
const handleCancelDeliveredEstimate = () => {
const handleAlertCancel = () => {
closeAlert(name);
};
// Handle confirm estimate delivered.
const handleConfirmEstimateDelivered = useCallback(() => {
const handleAlertConfirm = () => {
deliverEstimateMutate(estimateId)
.then(() => {
AppToaster.show({
@@ -41,14 +40,13 @@ function EstimateDeliveredAlert({
id: 'the_estimate_has_been_delivered_successfully',
}),
intent: Intent.SUCCESS,
});
queryCache.invalidateQueries('estimates-table');
})
})
.catch((error) => {})
.finally(() => {
closeAlert(name);
});
}, [estimateId, deliverEstimateMutate, formatMessage]);
};
return (
<Alert
@@ -56,8 +54,8 @@ function EstimateDeliveredAlert({
confirmButtonText={<T id={'deliver'} />}
intent={Intent.WARNING}
isOpen={isOpen}
onCancel={handleCancelDeliveredEstimate}
onConfirm={handleConfirmEstimateDelivered}
onCancel={handleAlertCancel}
onConfirm={handleAlertConfirm}
loading={isLoading}
>
<p>