forked from sqlchat/sqlchat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClearDataConfirmModal.tsx
More file actions
44 lines (39 loc) · 1.23 KB
/
ClearDataConfirmModal.tsx
File metadata and controls
44 lines (39 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { toast } from "react-hot-toast";
import { useTranslation } from "react-i18next";
import Modal from "./kit/Modal";
interface Props {
close: () => void;
}
const ClearDataConfirmModal = (props: Props) => {
const { close } = props;
const { t } = useTranslation();
const handleClearData = () => {
window.localStorage.clear();
close();
toast.success("Data cleared. The page will be reloaded.");
setTimeout(() => {
window.location.reload();
}, 500);
};
return (
<Modal title="Clear all data" className="!w-96" onClose={close}>
<div>
<div className="w-full flex flex-col justify-start items-start mt-2">
<p className="text-gray-500">
SQL Chat saves all your data in your local browser. Are you sure to
clear all of them?
</p>
</div>
<div className="w-full flex flex-row justify-end items-center mt-4 space-x-2">
<button className="btn btn-outline" onClick={close}>
{t("common.close")}
</button>
<button className="btn btn-error" onClick={handleClearData}>
{t("common.clear")}
</button>
</div>
</div>
</Modal>
);
};
export default ClearDataConfirmModal;