import { useContext, useState } from 'react'; import { toast } from 'react-toastify'; import CommentIcon from '@mui/icons-material/CommentTwoTone'; import DownloadIcon from '@mui/icons-material/GetApp'; import GitHubIcon from '@mui/icons-material/GitHub'; import MenuBookIcon from '@mui/icons-material/MenuBookTwoTone'; import { Avatar, Box, Button, Divider, Link, List, ListItem, ListItemAvatar, ListItemButton, ListItemText, Stack, Typography } from '@mui/material'; import { useRequest } from 'alova/client'; import { SectionContent, useLayoutTitle } from 'components'; import { AuthenticatedContext } from 'contexts/authentication'; import { useI18nContext } from 'i18n/i18n-react'; import { saveFile } from 'utils'; import { API, callAction } from '../../api/app'; import type { APIcall } from './types'; const Help = () => { const { LL } = useI18nContext(); useLayoutTitle(LL.HELP()); const { me } = useContext(AuthenticatedContext); const [customSupportIMG, setCustomSupportIMG] = useState(null); const [customSupportHTML, setCustomSupportHTML] = useState(null); useRequest(() => callAction({ action: 'customSupport' })).onSuccess((event) => { if (event && event.data && Object.keys(event.data).length !== 0) { const data = event.data.Support; if (data.img_url) { setCustomSupportIMG(data.img_url); } if (data.html) { setCustomSupportHTML(data.html.join('
')); } } }); const { send: sendExportAllValues } = useRequest( () => callAction({ action: 'export', param: 'allvalues' }), { immediate: false } ) .onSuccess((event) => { saveFile(event.data, 'allvalues', '.txt'); toast.info(LL.DOWNLOAD_SUCCESSFUL()); }) .onError((error) => { toast.error(error.message); }); const { send: sendAPI } = useRequest((data: APIcall) => API(data), { immediate: false }) .onSuccess((event) => { saveFile(event.data, 'system_info', '.json'); toast.info(LL.DOWNLOAD_SUCCESSFUL()); }) .onError((error) => { toast.error(error.message); }); return ( } sx={{ borderRadius: 3, border: '2px solid grey', justifyContent: 'space-evenly', alignItems: 'center' }} > {customSupportHTML ? (
) : ( LL.HELP_INFORMATION_5() )} {me.admin && ( )} {LL.HELP_INFORMATION_4()} ©  {'emsesp.org'} ); }; export default Help;