Confirm card deletion

This commit is contained in:
Tanner Collin 2020-02-28 01:32:53 +00:00
parent 1db63c9615
commit a3f113de6d

View File

@ -12,6 +12,7 @@ function AdminCardDetail(props) {
const [error, setError] = useState(false); const [error, setError] = useState(false);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [success, setSuccess] = useState(false); const [success, setSuccess] = useState(false);
const [yousure, setYousure] = useState(false);
const id = card.id; const id = card.id;
const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value }); const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value });
@ -41,13 +42,17 @@ function AdminCardDetail(props) {
const handleDelete = (e) => { const handleDelete = (e) => {
e.preventDefault(); e.preventDefault();
requester('/cards/'+id+'/', 'DELETE', token) if (yousure) {
.then(res => { requester('/cards/'+id+'/', 'DELETE', token)
setInput(false); .then(res => {
}) setInput(false);
.catch(err => { })
console.log(err); .catch(err => {
}); console.log(err);
});
} else {
setYousure(true);
}
}; };
const makeProps = (name) => ({ const makeProps = (name) => ({
@ -92,7 +97,7 @@ function AdminCardDetail(props) {
color='red' color='red'
onClick={handleDelete} onClick={handleDelete}
> >
Delete {yousure ? 'You Sure?' : 'Delete'}
</Form.Button> </Form.Button>
</Form.Group> </Form.Group>
</Form.Group> </Form.Group>