import React, { useState, useEffect, useRef } from "react"; import { Link, useLocation, useNavigate } from "react-router-dom"; import Modal from "react-modal"; import { deleteCaches, setAccount, useAccount } from "@plebbit/plebbit-react-hooks"; import { StyledModal } from "./styled/SettingsModal.styled"; import useGeneralStore from "../hooks/stores/useGeneralStore"; import useError from "../hooks/useError"; import useSuccess from "../hooks/useSuccess"; const customOverlayStyles = { overlay: { backgroundColor: 'rgba(0,0,0,.25)' } }; const SettingsModal = ({ isOpen, closeModal }) => { const selectedStyle = useGeneralStore(state => state.selectedStyle); const navigate = useNavigate(); const location = useLocation(); const [expanded, setExpanded] = useState([]); const [errorMessage, setErrorMessage] = useState(null); const [successMessage, setSuccessMessage] = useState(null); useError(errorMessage, [errorMessage]); useSuccess(successMessage, [successMessage]); const account = useAccount(); const gatewayRef = useRef(); const ipfsRef = useRef(); const pubsubRef = useRef(); const dataPathRef = useRef(); const handleCloseModal = () => { closeModal(); if (location.pathname === "/settings") { navigate(-1, { replace: true }); } else { navigate("/settings", { state: { from: location } }); } }; const toggleExpanded = (index) => { setExpanded((prevExpanded) => { const newExpanded = [...prevExpanded]; if (newExpanded.includes(index)) { newExpanded.splice(newExpanded.indexOf(index), 1); } else { newExpanded.push(index); } return newExpanded; }); }; const expandAll = () => { if (expanded.length === 3) { setExpanded([]); } else { setExpanded([0, 1, 2]); } }; useEffect(() => { if (localStorage.getItem("cacheCleared") === "true") { setSuccessMessage("Cache Cleared"); localStorage.removeItem("cacheCleared"); } }, []); return (
Settings
[ ]
{/* */}