mirror of
https://github.com/ditkrg/AuthorizationServerDemos.git
synced 2026-01-23 00:46:47 +00:00
Abstracts away the input select
This commit is contained in:
parent
be69a64474
commit
23d40dfada
@ -9,6 +9,7 @@ import Card from "./Card";
|
||||
import Heading3 from "./Heading3";
|
||||
import Button from "./Button";
|
||||
import InputText from "./inputs/InputText";
|
||||
import InputSelect from "./inputs/InputSelect";
|
||||
|
||||
const VehicleRegisterForm = () => {
|
||||
const [model, setModel] = useState("");
|
||||
@ -50,19 +51,18 @@ const VehicleRegisterForm = () => {
|
||||
name="color"
|
||||
onChangeEvent={(e) => setColor(e.target.value)}
|
||||
/>
|
||||
|
||||
<label>Type: </label>
|
||||
<select
|
||||
<InputSelect
|
||||
label="Type"
|
||||
value={type}
|
||||
name="type"
|
||||
onChange={(e) => setType(e.target.value)}
|
||||
>
|
||||
<option value="1">Sedan</option>
|
||||
<option value="2">SUV</option>
|
||||
<option value="3">Pickup</option>
|
||||
</select>
|
||||
onChangeEvent={(e) => setType(e.target.value)}
|
||||
options={[
|
||||
{ value: "1", text: "Sedan" },
|
||||
{ value: "2", text: "SUV" },
|
||||
{ value: "3", text: "Pickup" },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button text="Register" onClickEvent={registerVehicle} />
|
||||
</form>
|
||||
</Card>
|
||||
|
||||
@ -1,7 +1,18 @@
|
||||
import React from "react";
|
||||
|
||||
const InputSelect = () => {
|
||||
return <div></div>;
|
||||
const InputSelect = ({ label, value, name, onChangeEvent, options }) => {
|
||||
return (
|
||||
<div>
|
||||
<label>{label}</label>
|
||||
<select value={value} name={name} onChange={onChangeEvent}>
|
||||
{options.map((option, i) => (
|
||||
<option key={i} value={option.value}>
|
||||
{option.text}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default InputSelect;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user