import type { FC } 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, Link, List, ListItem, ListItemAvatar, ListItemButton, ListItemText, Typography } from '@mui/material'; import * as EMSESP from 'project/api'; import { useRequest } from 'alova'; import { SectionContent, useLayoutTitle } from 'components'; import { useI18nContext } from 'i18n/i18n-react'; import type { APIcall } from './types'; const Help: FC = () => { const { LL } = useI18nContext(); useLayoutTitle(LL.HELP_OF('')); const { send: getAPI, onSuccess: onGetAPI } = useRequest( (data: APIcall) => EMSESP.API(data), { immediate: false } ); onGetAPI((event) => { const anchor = document.createElement('a'); anchor.href = URL.createObjectURL( new Blob([JSON.stringify(event.data, null, 2)], { type: 'text/plain' }) ); anchor.download = 'emsesp_' + event.sendArgs[0].device + '_' + event.sendArgs[0].entity + '.txt'; anchor.click(); URL.revokeObjectURL(anchor.href); toast.info(LL.DOWNLOAD_SUCCESSFUL()); }); const callAPI = async (device: string, entity: string) => { await getAPI({ device, entity, id: 0 }).catch((error: Error) => { toast.error(error.message); }); }; return ( {LL.HELP_INFORMATION_4()} {LL.HELP_INFORMATION_5()} {'github.com/emsesp/EMS-ESP32'} @proddy @MichaelDvP ); }; export default Help;