- Merge client update into test-beta
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -1,44 +1,44 @@
|
||||
import { useMutation } from "@apollo/client";
|
||||
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";
|
||||
import {useMutation} from "@apollo/client";
|
||||
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";
|
||||
import queryString from "query-string";
|
||||
import { useHistory, useLocation } from "react-router-dom";
|
||||
import {useLocation, useNavigate} from "react-router-dom";
|
||||
|
||||
export default function ProductionRemoveButton({ jobId }) {
|
||||
const [removeJobFromProduction] = useMutation(UPDATE_JOB);
|
||||
const { t } = useTranslation();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const history = useHistory();
|
||||
export default function ProductionRemoveButton({jobId}) {
|
||||
const [removeJobFromProduction] = useMutation(UPDATE_JOB);
|
||||
const {t} = useTranslation();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const history = useNavigate();
|
||||
|
||||
const handleRemoveFromProd = async () => {
|
||||
logImEXEvent("production_remove_job");
|
||||
setLoading(true);
|
||||
const result = await removeJobFromProduction({
|
||||
variables: { jobId: jobId, job: { inproduction: false } },
|
||||
});
|
||||
const handleRemoveFromProd = async () => {
|
||||
logImEXEvent("production_remove_job");
|
||||
setLoading(true);
|
||||
const result = await removeJobFromProduction({
|
||||
variables: {jobId: jobId, job: {inproduction: false}},
|
||||
});
|
||||
|
||||
if (!!!result.errors) {
|
||||
notification["success"]({ message: t("production.successes.removed") });
|
||||
delete search.selected;
|
||||
history.push({ search: queryString.stringify(search) });
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("production.errors.removing", {
|
||||
error: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
}
|
||||
if (!!!result.errors) {
|
||||
notification["success"]({message: t("production.successes.removed")});
|
||||
delete search.selected;
|
||||
history({search: queryString.stringify(search)});
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("production.errors.removing", {
|
||||
error: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Button loading={loading} onClick={handleRemoveFromProd} type={"danger"}>
|
||||
{t("production.actions.remove")}
|
||||
</Button>
|
||||
);
|
||||
return (
|
||||
<Button loading={loading} onClick={handleRemoveFromProd} type={"danger"}>
|
||||
{t("production.actions.remove")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user