import { useStoreActions } from 'easy-peasy'; import type { FormikHelpers } from 'formik'; import { Form, Formik } from 'formik'; import tw from 'twin.macro'; import { object } from 'yup'; import { useServerFromRoute } from '@/api/admin/server'; import type { Values } from '@/api/admin/servers/updateServer'; import updateServer from '@/api/admin/servers/updateServer'; import ServerDeleteButton from '@/components/admin/servers/ServerDeleteButton'; import BaseSettingsBox from '@/components/admin/servers/settings/BaseSettingsBox'; import FeatureLimitsBox from '@/components/admin/servers/settings/FeatureLimitsBox'; import NetworkingBox from '@/components/admin/servers/settings/NetworkingBox'; import ServerResourceBox from '@/components/admin/servers/settings/ServerResourceBox'; import { Button } from '@/components/elements/button'; export default () => { const { data: server } = useServerFromRoute(); const { clearFlashes, clearAndAddHttpError } = useStoreActions(actions => actions.flashes); if (!server) return null; const submit = (values: Values, { setSubmitting, setFieldValue }: FormikHelpers) => { clearFlashes('server'); // This value is inverted to have the switch be on when the // OOM Killer is enabled, rather than when disabled. values.limits.oomDisabled = !values.limits.oomDisabled; console.log(values); updateServer(server.id, values) .then(() => { // setServer({ ...server, ...s }); // TODO: Figure out how to properly clear react-selects for allocations. setFieldValue('addAllocations', []); setFieldValue('removeAllocations', []); }) .catch(error => { console.error(error); clearAndAddHttpError({ key: 'server', error }); }) .then(() => setSubmitting(false)); }; return ( {({ isSubmitting, isValid }) => (
)}
); };