import createEgg from '@/api/admin/eggs/createEgg'; import { EggImageContainer, EggInformationContainer, EggLifecycleContainer, EggProcessContainer, EggProcessContainerRef, EggStartupContainer } from '@/components/admin/nests/eggs/EggSettingsContainer'; import Button from '@/components/elements/Button'; import FlashMessageRender from '@/components/FlashMessageRender'; import useFlash from '@/plugins/useFlash'; import { Form, Formik, FormikHelpers } from 'formik'; import React, { useRef } from 'react'; import { useParams } from 'react-router'; import { useHistory } from 'react-router-dom'; import tw from 'twin.macro'; import AdminContentBlock from '@/components/admin/AdminContentBlock'; import { object } from 'yup'; interface Values { name: string; description: string; startup: string; dockerImages: string; configStop: string; configStartup: string; configFiles: string; } export default () => { const params = useParams<{ nestId: string }>(); const history = useHistory(); 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() || ''; createEgg({ ...values, dockerImages: values.dockerImages.split('\n'), nestId }) .then(egg => history.push(`/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 }) => (
)}
); };