Begin addign loading state to mutations BOD-134
This commit is contained in:
@@ -2,7 +2,7 @@ import { useMutation, useQuery } from "@apollo/react-hooks";
|
||||
import { Form, Button } from "antd";
|
||||
import moment from "moment";
|
||||
import queryString from "query-string";
|
||||
import React, { useEffect } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { useLocation } from "react-router-dom";
|
||||
@@ -26,6 +26,7 @@ export function InvoiceDetailEditContainer({ bodyshop }) {
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const { t } = useTranslation();
|
||||
const [form] = Form.useForm();
|
||||
const [updateLoading, setUpdateLoading] = useState(false);
|
||||
const [updateInvoice] = useMutation(UPDATE_INVOICE);
|
||||
const [updateInvoiceLine] = useMutation(UPDATE_INVOICE_LINE);
|
||||
|
||||
@@ -35,9 +36,9 @@ export function InvoiceDetailEditContainer({ bodyshop }) {
|
||||
});
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
setUpdateLoading(true);
|
||||
const { invoicelines, upload, ...invoice } = values;
|
||||
const updates = [];
|
||||
console.log("Start");
|
||||
updates.push(
|
||||
updateInvoice({
|
||||
variables: { invoiceId: search.invoiceid, invoice: invoice },
|
||||
@@ -54,6 +55,7 @@ export function InvoiceDetailEditContainer({ bodyshop }) {
|
||||
});
|
||||
|
||||
await Promise.all(updates);
|
||||
setUpdateLoading(false);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -99,7 +101,7 @@ export function InvoiceDetailEditContainer({ bodyshop }) {
|
||||
: {}
|
||||
}
|
||||
>
|
||||
<Button htmlType="submit" type="primary">
|
||||
<Button htmlType="submit" loading={updateLoading} type="primary">
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
<InvoiceFormContainer form={form} invoiceEdit />
|
||||
|
||||
Reference in New Issue
Block a user