import { Alert, AlertTitle, Card, CardContent, CardHeader, Collapse, Grid, IconButton, } from '@mui/material'; import MoreVertIcon from '@mui/icons-material/MoreVert'; import * as React from 'react'; import {EncryptStorage} from 'storage-encryption'; import {Delete, Download} from "@mui/icons-material"; import MDEditor from "@uiw/react-md-editor"; import {PropPage} from "../../interfaces/PropPage"; const Page = function({page, url, passphrase, settings, remove}: PropPage) { const [more, setMore] = React.useState(false); const handleMoreClick = () => { setMore(!more); }; const encryptStorage = new EncryptStorage(passphrase); try { const [title, setTitle] = React.useState(encryptStorage.decrypt(page.id + "title")); const [content, setContent] = React.useState(encryptStorage.decrypt(page.id + "text")); const onLoad = async () => { if (localStorage.getItem(page.id + "text") === null) { const response = await fetch(url.replace("replace_me", page.id)); const json = await response.json(); localStorage.setItem(page.id + "title", json.metadata.title); localStorage.setItem(page.id + "text", json.content); } setTitle(encryptStorage.decrypt(page.id + "title")); setContent(encryptStorage.decrypt(page.id + "text")); } let icons; if (content === null || content === "") { icons = (
); } else { icons = ( ); } return ( {remove(page.id)}} > ); } catch (e) { console.error(e); return ( Erreur Cette page ne peut pas être décodée — Réindiquez votre clef! ); } } export default React.forwardRef(Page);