ui(admin): start work on server startup settings

This commit is contained in:
Matthew Penner 2021-09-12 23:50:12 -06:00
parent 6362731d55
commit a615b7fa70
No known key found for this signature in database
GPG key ID: 030E4AB751DC756F
7 changed files with 239 additions and 157 deletions

View 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>
</>
);
};