|
1 | | -import { useState } from "react"; |
2 | | -import { createPortal } from "react-dom"; |
3 | 1 | import Icon from "./Icon"; |
4 | 2 | import WeChatQRCodeView from "./WeChatQRCodeView"; |
5 | | -import ClearDataConfirmModal from "./ClearDataConfirmModal"; |
| 3 | +import ClearDataButton from "./ClearDataButton"; |
6 | 4 |
|
7 | 5 | interface Props { |
8 | 6 | show: boolean; |
9 | 7 | close: () => void; |
10 | 8 | } |
11 | 9 |
|
12 | | -interface State { |
13 | | - showClearDataConfirmModal: boolean; |
14 | | -} |
15 | | - |
16 | 10 | const SettingModal = (props: Props) => { |
17 | 11 | const { show, close } = props; |
18 | | - const [state, setState] = useState<State>({ |
19 | | - showClearDataConfirmModal: false, |
20 | | - }); |
21 | | - |
22 | | - const toggleClearDataConfirmModal = (show = true) => { |
23 | | - setState({ |
24 | | - ...state, |
25 | | - showClearDataConfirmModal: show, |
26 | | - }); |
27 | | - }; |
28 | 12 |
|
29 | 13 | return ( |
30 | | - <> |
31 | | - <div className={`modal modal-middle ${show && "modal-open"}`}> |
32 | | - <div className="modal-box relative"> |
33 | | - <h3 className="font-bold text-lg">Setting</h3> |
34 | | - <button className="btn btn-sm btn-circle absolute right-4 top-4" onClick={close}> |
35 | | - <Icon.IoMdClose className="w-5 h-auto" /> |
36 | | - </button> |
37 | | - <div className="w-full flex flex-col justify-start items-start space-y-3 pt-4"> |
38 | | - <div className="w-full flex flex-row justify-start items-start flex-wrap"> |
39 | | - <a |
40 | | - href="https://discord.gg/6R3qb32h" |
41 | | - className="w-auto px-4 py-2 rounded-full bg-indigo-600 text-white text-sm font-medium flex flex-row justify-center items-center mr-2 mb-2 hover:underline hover:shadow" |
42 | | - target="_blank" |
43 | | - > |
44 | | - <Icon.BsDiscord className="w-4 h-auto mr-1" /> |
45 | | - Join Discord Channel |
46 | | - </a> |
47 | | - <WeChatQRCodeView /> |
48 | | - </div> |
| 14 | + <div className={`modal modal-middle ${show && "modal-open"}`}> |
| 15 | + <div className="modal-box relative"> |
| 16 | + <h3 className="font-bold text-lg">Setting</h3> |
| 17 | + <button className="btn btn-sm btn-circle absolute right-4 top-4" onClick={close}> |
| 18 | + <Icon.IoMdClose className="w-5 h-auto" /> |
| 19 | + </button> |
| 20 | + <div className="w-full flex flex-col justify-start items-start space-y-3 pt-4"> |
| 21 | + <div className="w-full flex flex-row justify-start items-start flex-wrap"> |
| 22 | + <a |
| 23 | + href="https://discord.gg/6R3qb32h" |
| 24 | + className="w-auto px-4 py-2 rounded-full bg-indigo-600 text-white text-sm font-medium flex flex-row justify-center items-center mr-2 mb-2 hover:underline hover:shadow" |
| 25 | + target="_blank" |
| 26 | + > |
| 27 | + <Icon.BsDiscord className="w-4 h-auto mr-1" /> |
| 28 | + Join Discord Channel |
| 29 | + </a> |
| 30 | + <WeChatQRCodeView /> |
| 31 | + </div> |
49 | 32 |
|
50 | | - <h3>Danger Zone</h3> |
51 | | - <div className="w-full border border-red-200 p-4 rounded-lg"> |
52 | | - <div className="w-full flex flex-row justify-between items-center gap-2"> |
53 | | - <span>Clear all data</span> |
54 | | - <button className="btn btn-sm btn-error" onClick={() => toggleClearDataConfirmModal(true)}> |
55 | | - Clear |
56 | | - </button> |
57 | | - </div> |
| 33 | + <h3>Danger Zone</h3> |
| 34 | + <div className="w-full border border-red-200 p-4 rounded-lg"> |
| 35 | + <div className="w-full flex flex-row justify-between items-center gap-2"> |
| 36 | + <span>Clear all data</span> |
| 37 | + <ClearDataButton /> |
58 | 38 | </div> |
59 | 39 | </div> |
60 | 40 | </div> |
61 | 41 | </div> |
62 | | - |
63 | | - {state.showClearDataConfirmModal && |
64 | | - createPortal(<ClearDataConfirmModal close={() => toggleClearDataConfirmModal(false)} />, document.body)} |
65 | | - </> |
| 42 | + </div> |
66 | 43 | ); |
67 | 44 | }; |
68 | 45 |
|
|
0 commit comments