refactor(web/dialog): Separate fields into individual components

This commit is contained in:
Luke
2022-05-03 15:08:28 +02:00
parent 64a1ad9343
commit 48dae99cc0
8 changed files with 153 additions and 75 deletions

View File

@@ -0,0 +1,32 @@
import { Box, Select } from "@chakra-ui/react";
import { Row } from "../../../interfaces/dialog";
interface Props {
row: Row;
index: number;
handleChange: (value: string | boolean, index: number) => void;
}
const SelectField: React.FC<Props> = (props) => {
return (
<>
<Box mb={3} key={`select-${props.index}`}>
<Select
onChange={(e) => props.handleChange(e.target.value, props.index)}
>
{/* Hacky workaround for selectable placeholder issue */}
<option value="" selected hidden disabled>
{props.row.label}
</option>
{props.row.options?.map((option, index) => (
<option key={`option-${index}`} value={option.value}>
{option.label}
</option>
))}
</Select>
</Box>
</>
);
};
export default SelectField;