Begin addign loading state to mutations BOD-134
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Button, notification } from "antd";
|
||||
import React from "react";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import axios from "axios";
|
||||
import { useMutation } from "@apollo/react-hooks";
|
||||
@@ -13,9 +13,10 @@ export default function JobsDocumentsDeleteButton({
|
||||
const { t } = useTranslation();
|
||||
const [deleteDocument] = useMutation(DELETE_DOCUMENT);
|
||||
const imagesToDelete = galleryImages.filter((image) => image.isSelected);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const handleDelete = () => {
|
||||
logImEXEvent("job_documents_delete", { count: imagesToDelete.length });
|
||||
|
||||
setLoading(true);
|
||||
imagesToDelete.forEach((image) => {
|
||||
let timestamp = Math.floor(Date.now() / 1000);
|
||||
let public_id = image.key;
|
||||
@@ -65,10 +66,15 @@ export default function JobsDocumentsDeleteButton({
|
||||
});
|
||||
});
|
||||
});
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Button disabled={imagesToDelete.length < 1} onClick={handleDelete}>
|
||||
<Button
|
||||
disabled={imagesToDelete.length < 1}
|
||||
loading={loading}
|
||||
onClick={handleDelete}
|
||||
>
|
||||
{t("documents.actions.delete")}
|
||||
</Button>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user