import type { Actions } from 'easy-peasy'; import { useStoreActions } from 'easy-peasy'; import type { FormikHelpers } from 'formik'; import { Form, Formik } from 'formik'; import { useNavigate } from 'react-router-dom'; import tw from 'twin.macro'; import { number, object, string } from 'yup'; import type { Values } from '@/api/admin/nodes/createNode'; import createNode from '@/api/admin/nodes/createNode'; import AdminContentBlock from '@/components/admin/AdminContentBlock'; import NodeLimitContainer from '@/components/admin/nodes/NodeLimitContainer'; import NodeListenContainer from '@/components/admin/nodes/NodeListenContainer'; import NodeSettingsContainer from '@/components/admin/nodes/NodeSettingsContainer'; import Button from '@/components/elements/Button'; import FlashMessageRender from '@/components/FlashMessageRender'; import type { ApplicationStore } from '@/state'; type Values2 = Omit, 'public'> & { behindProxy: string; public: string }; const initialValues: Values2 = { name: '', locationId: 0, databaseHostId: null, fqdn: '', scheme: 'https', behindProxy: 'false', public: 'true', daemonBase: '/var/lib/pterodactyl/volumes', listenPortHTTP: 8080, publicPortHTTP: 8080, listenPortSFTP: 2022, publicPortSFTP: 2022, memory: 0, memoryOverallocate: 0, disk: 0, diskOverallocate: 0, }; export default () => { const navigate = useNavigate(); const { clearFlashes, clearAndAddHttpError } = useStoreActions( (actions: Actions) => actions.flashes, ); const submit = (values2: Values2, { setSubmitting }: FormikHelpers) => { clearFlashes('node:create'); const values: Values = { ...values2, behindProxy: values2.behindProxy === 'true', public: values2.public === 'true', }; createNode(values) .then(node => navigate(`/admin/nodes/${node.id}`)) .catch(error => { console.error(error); clearAndAddHttpError({ key: 'node:create', error }); }) .then(() => setSubmitting(false)); }; return (

New Node

Add a new node to the panel.

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