import type { FormikHelpers } from 'formik'; import { Form, Formik } from 'formik'; import { useRef } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import tw from 'twin.macro'; import { object } from 'yup'; import createEgg from '@/api/admin/eggs/createEgg'; import AdminContentBlock from '@/components/admin/AdminContentBlock'; import type { EggProcessContainerRef } from '@/components/admin/nests/eggs/EggSettingsContainer'; import { EggImageContainer, EggInformationContainer, EggLifecycleContainer, EggProcessContainer, EggStartupContainer, } from '@/components/admin/nests/eggs/EggSettingsContainer'; import { Button } from '@/components/elements/button'; import FlashMessageRender from '@/components/FlashMessageRender'; import useFlash from '@/plugins/useFlash'; interface Values { name: string; description: string; startup: string; dockerImages: string; configStop: string; configStartup: string; configFiles: string; } export default () => { const navigate = useNavigate(); const params = useParams<{ nestId: string }>(); const { clearFlashes, clearAndAddHttpError } = useFlash(); const ref = useRef(); const submit = async (values: Values, { setSubmitting }: FormikHelpers) => { clearFlashes('egg:create'); const nestId = Number(params.nestId); values.configStartup = (await ref.current?.getStartupConfiguration()) || ''; values.configFiles = (await ref.current?.getFilesConfiguration()) || ''; const dockerImages: Record = {}; values.dockerImages.split('\n').forEach(v => { dockerImages[v] = v; }); createEgg({ ...values, dockerImages, nestId, }) .then(egg => navigate(`/admin/nests/${nestId}/eggs/${egg.id}`)) .catch(error => { console.error(error); clearAndAddHttpError({ key: 'egg:create', error }); }) .then(() => setSubmitting(false)); }; return (

New Egg

Add a new egg to the panel.

{({ isSubmitting, isValid }) => (
)}
); };