import React from 'react'; import { useFormikContext } from 'formik'; import SelectField, { AsyncSelectField, Option } from '@/components/elements/SelectField'; import getAllocations from '@/api/admin/nodes/getAllocations'; import AdminBox from '@/components/admin/AdminBox'; import { faNetworkWired } from '@fortawesome/free-solid-svg-icons'; import tw from 'twin.macro'; import Label from '@/components/elements/Label'; import Select from '@/components/elements/Select'; import { useServerFromRoute } from '@/api/admin/server'; export default () => { const { isSubmitting } = useFormikContext(); const { data: server } = useServerFromRoute(); const loadOptions = async (inputValue: string, callback: (options: Option[]) => void) => { if (!server) { // eslint-disable-next-line node/no-callback-literal callback([] as Option[]); return; } const allocations = await getAllocations(server.nodeId, { ip: inputValue, server_id: '0' }); callback(allocations.map(a => { return { value: a.id.toString(), label: a.getDisplayText() }; })); }; return (
{ return { value: a.id.toString(), label: a.getDisplayText() }; }) || []} isMulti isSearchable />
); };