Successful 2tier and 3 tier export of invoices. BOD-83 BOD-131

This commit is contained in:
Patrick Fic
2020-06-02 09:19:46 -07:00
parent 5564b5dc4a
commit 73040064d4
16 changed files with 265 additions and 112 deletions

View File

@@ -18,6 +18,8 @@ export function JobsCloseSaveButton({
jobTotals,
labMatAllocations,
partsAllocations,
setInvoicedState,
disabled,
}) {
const [loading, setLoading] = useState(false);
const { t } = useTranslation();
@@ -38,9 +40,23 @@ export function JobsCloseSaveButton({
},
},
},
optimisticResponse: {
update_jobs: {
returning: {
id: jobId,
date_invoiced: new Date(),
status: bodyshop.md_ro_statuses.default_invoiced || "Invoiced*",
invoice_allocation: {
labMatAllocations,
partsAllocations,
},
},
},
},
});
if (!!!result.errors) {
notification["success"]({ message: t("jobs.successes.invoiced") });
setInvoicedState(true);
} else {
notification["error"]({
message: t("jobs.errors.invoicing", {
@@ -50,14 +66,14 @@ export function JobsCloseSaveButton({
}
setLoading(false);
};
return (
<Button
onClick={handleSave}
disabled={suspenseAmount > 0}
disabled={suspenseAmount > 0 || disabled}
loading={loading}
>
{t("general.actions.close")}
{t("general.actions.save")}
</Button>
);
}