ui(admin): start work on server startup settings
This commit is contained in:
parent
6362731d55
commit
a615b7fa70
7 changed files with 239 additions and 157 deletions
32
resources/scripts/components/admin/servers/EggSelect.tsx
Normal file
32
resources/scripts/components/admin/servers/EggSelect.tsx
Normal file
|
@ -0,0 +1,32 @@
|
|||
import Label from '@/components/elements/Label';
|
||||
import Select from '@/components/elements/Select';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Egg } from '@/api/admin/eggs/getEgg';
|
||||
import searchEggs from '@/api/admin/nests/searchEggs';
|
||||
|
||||
export default ({ nestId, eggId }: { nestId: number | null; eggId?: number }) => {
|
||||
const [ eggs, setEggs ] = useState<Egg[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (nestId === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
searchEggs(nestId, {})
|
||||
.then(eggs => setEggs(eggs))
|
||||
.catch(error => console.error(error));
|
||||
}, [ nestId ]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Label>Egg</Label>
|
||||
<Select defaultValue={eggId || undefined} id={'eggId'} name={'eggId'}>
|
||||
{eggs.map(v => (
|
||||
<option key={v.id} value={v.id.toString()}>
|
||||
{v.name}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue