Added additional precuations for users that do not exist and verified auth access.

This commit is contained in:
Patrick Fic
2020-10-19 16:26:51 -07:00
parent 64f6d549d1
commit 0749404d59
10 changed files with 124 additions and 32 deletions

View File

@@ -0,0 +1,46 @@
import { DeleteFilled } from "@ant-design/icons";
import { useMutation } from "@apollo/client";
import { Button, message, Popconfirm } from "antd";
import React, { useState } from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { DELETE_JOB } from "../../../graphql/jobs.queries";
import { setSelectedJobId } from "../../../redux/application/application.actions";
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
});
const mapDispatchToProps = (dispatch) => ({
setSelectedJobId: (id) => dispatch(setSelectedJobId(id)),
});
export function DeleteJobAtom({ setSelectedJobId, jobId }) {
const [deleteJob] = useMutation(DELETE_JOB);
const [loading, setLoading] = useState(false);
const handleDelete = async () => {
setLoading(true);
const result = await deleteJob({
variables: { jobId: jobId },
});
if (result.errors) {
message.error(result.errors.toString());
} else {
message.success("Job deleted.");
setSelectedJobId(null);
}
setLoading(false);
};
return (
<div>
<Popconfirm
title="Are you sure you want to delete this job? This cannot be undone."
onConfirm={handleDelete}
>
<Button loading={loading}>
<DeleteFilled />
</Button>
</Popconfirm>
</div>
);
}
export default connect(mapStateToProps, mapDispatchToProps)(DeleteJobAtom);