Added confirm modal and added confirmation for deleting and resetting maps and tokens

This commit is contained in:
Mitchell McCaffrey
2020-10-10 15:32:59 +11:00
parent f7ba35ec29
commit 8d85f6e347
4 changed files with 95 additions and 22 deletions

View File

@@ -1,6 +1,5 @@
import React, { useState, useContext } from "react";
import {
Box,
Label,
Flex,
Button,
@@ -17,6 +16,8 @@ import DatabaseContext from "../contexts/DatabaseContext";
import useSetting from "../helpers/useSetting";
import ConfirmModal from "./ConfirmModal";
function SettingsModal({ isOpen, onRequestClose }) {
const { database } = useContext(DatabaseContext);
const { userId } = useContext(AuthContext);
@@ -103,26 +104,14 @@ function SettingsModal({ isOpen, onRequestClose }) {
</Flex>
</Flex>
</Modal>
<Modal
<ConfirmModal
isOpen={isDeleteModalOpen}
onRequestClose={() => setIsDeleteModalOpen(false)}
>
<Box>
<Label py={2}>Are you sure?</Label>
<Flex py={2}>
<Button
sx={{ flexGrow: 1 }}
m={1}
onClick={() => setIsDeleteModalOpen(false)}
>
Cancel
</Button>
<Button m={1} sx={{ flexGrow: 1 }} onClick={handleEraseAllData}>
Erase
</Button>
</Flex>
</Box>
</Modal>
onConfirm={handleEraseAllData}
label="Erase All Content?"
description="This will remove all data including saved maps and tokens."
confirmText="Erase"
/>
</>
);
}