Ability to delete job checklist IO-464

This commit is contained in:
Patrick Fic
2021-02-02 12:21:06 -08:00
parent 8fcb488b3b
commit d1280e8680
4 changed files with 58 additions and 5 deletions

View File

@@ -0,0 +1,49 @@
import { useMutation } from "@apollo/react-hooks";
import { Button, notification } from "antd";
import gql from "graphql-tag";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
export default function JobAdminDeleteIntake({ job }) {
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
const [updateJob] = useMutation(gql`
mutation UPDATE_JOB($jobId: uuid!) {
update_jobs_by_pk(
pk_columns: { id: $jobId }
_set: { intakechecklist: null }
) {
id
intakechecklist
}
}
`);
const handleDelete = async (values) => {
setLoading(true);
const result = await updateJob({
variables: { jobId: job.id },
});
if (!!!result.errors) {
notification["success"]({ message: t("jobs.successes.save") });
} else {
notification["error"]({
message: t("jobs.errors.saving", {
error: JSON.stringify(result.errors),
}),
});
}
setLoading(false);
//Get the owner details, populate it all back into the job.
};
return (
<div>
<div>{t("jobs.labels.deleteintake")}</div>
<Button loading={loading} onClick={handleDelete}>
{t("general.actions.delete")}
</Button>
</div>
);
}