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,6 +42,7 @@ function AdminCardDetail(props) {
const handleDelete = (e) => { const handleDelete = (e) => {
e.preventDefault(); e.preventDefault();
if (yousure) {
requester('/cards/'+id+'/', 'DELETE', token) requester('/cards/'+id+'/', 'DELETE', token)
.then(res => { .then(res => {
setInput(false); setInput(false);
@ -48,6 +50,9 @@ function AdminCardDetail(props) {
.catch(err => { .catch(err => {
console.log(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>