(props: Props)
| 7 | } |
| 8 | |
| 9 | const ClearDataConfirmModal = (props: Props) => { |
| 10 | const { close } = props; |
| 11 | const { t } = useTranslation(); |
| 12 | |
| 13 | const handleClearData = () => { |
| 14 | window.localStorage.clear(); |
| 15 | close(); |
| 16 | toast.success("Data cleared. The page will be reloaded."); |
| 17 | setTimeout(() => { |
| 18 | window.location.reload(); |
| 19 | }, 500); |
| 20 | }; |
| 21 | |
| 22 | return ( |
| 23 | <Modal title="Clear all data" className="!w-96" onClose={close}> |
| 24 | <div> |
| 25 | <div className="w-full flex flex-col justify-start items-start mt-2"> |
| 26 | <p className="text-gray-500">SQL Chat saves all your data in your local browser. Are you sure to clear all of them?</p> |
| 27 | </div> |
| 28 | <div className="w-full flex flex-row justify-end items-center mt-4 space-x-2"> |
| 29 | <button className="btn btn-outline" onClick={close}> |
| 30 | {t("common.close")} |
| 31 | </button> |
| 32 | <button className="btn btn-error" onClick={handleClearData}> |
| 33 | {t("common.clear")} |
| 34 | </button> |
| 35 | </div> |
| 36 | </div> |
| 37 | </Modal> |
| 38 | ); |
| 39 | }; |
| 40 | |
| 41 | export default ClearDataConfirmModal; |
nothing calls this directly
no outgoing calls
no test coverage detected