mirror of
https://github.com/ditkrg/AuthorizationServerDemos.git
synced 2026-01-23 06:36:43 +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 Heading3 from "./Heading3";
|
||||||
import Button from "./Button";
|
import Button from "./Button";
|
||||||
import InputText from "./inputs/InputText";
|
import InputText from "./inputs/InputText";
|
||||||
|
import InputSelect from "./inputs/InputSelect";
|
||||||
|
|
||||||
const VehicleRegisterForm = () => {
|
const VehicleRegisterForm = () => {
|
||||||
const [model, setModel] = useState("");
|
const [model, setModel] = useState("");
|
||||||
@ -50,19 +51,18 @@ const VehicleRegisterForm = () => {
|
|||||||
name="color"
|
name="color"
|
||||||
onChangeEvent={(e) => setColor(e.target.value)}
|
onChangeEvent={(e) => setColor(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
<InputSelect
|
||||||
<label>Type: </label>
|
label="Type"
|
||||||
<select
|
|
||||||
value={type}
|
value={type}
|
||||||
name="type"
|
name="type"
|
||||||
onChange={(e) => setType(e.target.value)}
|
onChangeEvent={(e) => setType(e.target.value)}
|
||||||
>
|
options={[
|
||||||
<option value="1">Sedan</option>
|
{ value: "1", text: "Sedan" },
|
||||||
<option value="2">SUV</option>
|
{ value: "2", text: "SUV" },
|
||||||
<option value="3">Pickup</option>
|
{ value: "3", text: "Pickup" },
|
||||||
</select>
|
]}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button text="Register" onClickEvent={registerVehicle} />
|
<Button text="Register" onClickEvent={registerVehicle} />
|
||||||
</form>
|
</form>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@ -1,7 +1,18 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const InputSelect = () => {
|
const InputSelect = ({ label, value, name, onChangeEvent, options }) => {
|
||||||
return <div></div>;
|
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;
|
export default InputSelect;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user