mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
scaffold create/edit beer form, scaffold beer page
This commit is contained in:
38
components/ui/forms/FormSelect.tsx
Normal file
38
components/ui/forms/FormSelect.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import { FunctionComponent } from 'react';
|
||||
import { UseFormRegisterReturn } from 'react-hook-form';
|
||||
|
||||
interface FormSelectProps {
|
||||
options: ReadonlyArray<{ value: string; text: string }>;
|
||||
id: string;
|
||||
formRegister: UseFormRegisterReturn<string>;
|
||||
error: boolean;
|
||||
placeholder: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
const FormSelect: FunctionComponent<FormSelectProps> = ({
|
||||
options,
|
||||
id,
|
||||
error,
|
||||
formRegister,
|
||||
placeholder,
|
||||
message,
|
||||
}) => (
|
||||
<select
|
||||
id={id}
|
||||
className={`select select-bordered block w-full rounded-lg ${
|
||||
error ? 'select-error' : ''
|
||||
}`}
|
||||
placeholder={placeholder}
|
||||
{...formRegister}
|
||||
>
|
||||
<option value="">{message}</option>
|
||||
{options.map(({ value, text }) => (
|
||||
<option key={value} value={value}>
|
||||
{text}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
);
|
||||
|
||||
export default FormSelect;
|
||||
Reference in New Issue
Block a user