import { LanguageDescription } from '@codemirror/language'; import { json } from '@codemirror/lang-json'; import { useEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; import tw from 'twin.macro'; import { exportEgg } from '@/api/admin/egg'; import FlashMessageRender from '@/components/FlashMessageRender'; import { Button } from '@/components/elements/button'; import { Variant } from '@/components/elements/button/types'; import { Editor } from '@/components/elements/editor'; import Modal from '@/components/elements/Modal'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; import useFlash from '@/plugins/useFlash'; export default ({ className }: { className?: string }) => { const params = useParams<'id'>(); const { clearAndAddHttpError, clearFlashes } = useFlash(); const [visible, setVisible] = useState(false); const [loading, setLoading] = useState(true); const [content, setContent] = useState(undefined); useEffect(() => { if (!visible) { return; } clearFlashes('egg:export'); setLoading(true); exportEgg(Number(params.id)) .then(setContent) .catch(error => clearAndAddHttpError({ key: 'egg:export', error })) .then(() => setLoading(false)); }, [visible]); return ( <> { setVisible(false); }} css={tw`relative`} >

Export Egg

setVisible(false)} > Close
setVisible(true)} > Export ); };