Added remove from production button to kanban card. BOD-261

This commit is contained in:
Patrick Fic
2020-08-24 11:00:52 -07:00
parent 2acef8f726
commit 2cb8ae1359
10 changed files with 205 additions and 92 deletions

View File

@@ -1,28 +1,36 @@
import React from "react";
import { useMutation } from "@apollo/react-hooks";
import { UPDATE_JOB } from "../../graphql/jobs.queries";
import { Button, notification } from "antd";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { logImEXEvent } from "../../firebase/firebase.utils";
import { UPDATE_JOB } from "../../graphql/jobs.queries";
export default function ProductionRemoveButton({ jobId }) {
const [removeJobFromProduction] = useMutation(UPDATE_JOB);
const { t } = useTranslation();
const handleRemoveFromProd = () => {
logImEXEvent("production_remove_job");
const [loading, setLoading] = useState(false);
removeJobFromProduction({
const handleRemoveFromProd = async () => {
logImEXEvent("production_remove_job");
setLoading(true);
const result = await removeJobFromProduction({
variables: { jobId: jobId, job: { inproduction: false } },
}).catch((error) => {
});
if (!!!result.errors) {
notification["success"]({ message: t("production.successes.removed") });
} else {
notification["error"]({
message: t("production.errors.removing", {
error: JSON.stringify(error),
error: JSON.stringify(result.errors),
}),
});
});
}
setLoading(false);
};
return (
<Button onClick={handleRemoveFromProd} type={"danger"}>
<Button loading={loading} onClick={handleRemoveFromProd} type={"danger"}>
{t("production.actions.remove")}
</Button>
);