mirror of
https://github.com/ditkrg/AuthorizationServerDemos.git
synced 2026-01-23 03:36:52 +00:00
Abstracts away the input texts
This commit is contained in:
parent
8ee28188ac
commit
be69a64474
@ -1,8 +1,11 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const Card = ({ children }) => {
|
const Card = ({ children, styles = {} }) => {
|
||||||
return (
|
return (
|
||||||
<div className="xl:w-1/3 lg:w-5/12 md:w-2/4 sm:w-9/12 w-11/12 flex flex-col justify-center shadow md:px-32 sm:px-28 md:py-36 sm:py-36 px-20 py-16 mt-20">
|
<div
|
||||||
|
style={{ ...styles }}
|
||||||
|
className="xl:w-1/3 lg:w-5/12 md:w-2/4 sm:w-9/12 w-11/12 flex flex-col justify-center shadow md:px-32 sm:px-28 md:py-36 sm:py-36 px-20 py-16 my-20"
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
14
React/src/pages/components/Heading3.js
Normal file
14
React/src/pages/components/Heading3.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const Heading3 = ({ children, styles = {} }) => {
|
||||||
|
return (
|
||||||
|
<h3
|
||||||
|
style={{ ...styles }}
|
||||||
|
className="font-light font-inter text-black-custom my-20 self-start"
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</h3>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Heading3;
|
||||||
@ -4,6 +4,12 @@ import { useSelector } from "react-redux";
|
|||||||
// Services
|
// Services
|
||||||
import * as apiService from "../../services/apiService";
|
import * as apiService from "../../services/apiService";
|
||||||
|
|
||||||
|
// Components
|
||||||
|
import Card from "./Card";
|
||||||
|
import Heading3 from "./Heading3";
|
||||||
|
import Button from "./Button";
|
||||||
|
import InputText from "./inputs/InputText";
|
||||||
|
|
||||||
const VehicleRegisterForm = () => {
|
const VehicleRegisterForm = () => {
|
||||||
const [model, setModel] = useState("");
|
const [model, setModel] = useState("");
|
||||||
const [licensePlate, setlicensePlate] = useState("");
|
const [licensePlate, setlicensePlate] = useState("");
|
||||||
@ -21,46 +27,45 @@ const VehicleRegisterForm = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={(e) => e.preventDefault()}>
|
<Card styles={{ padding: "60px" }}>
|
||||||
<h3>Register Vehicle:</h3>
|
<form onSubmit={(e) => e.preventDefault()} className="m-0 flex flex-col">
|
||||||
<div className="form-group">
|
<Heading3 styles={{ marginTop: "0" }}>Register A Vehicle</Heading3>
|
||||||
<label>Model: </label>
|
|
||||||
<input
|
|
||||||
value={model}
|
|
||||||
type="text"
|
|
||||||
name="model"
|
|
||||||
onChange={(e) => setModel(e.target.value)}
|
|
||||||
/>
|
|
||||||
<label>License Plate: </label>
|
|
||||||
<input
|
|
||||||
value={licensePlate}
|
|
||||||
type="text"
|
|
||||||
name="licensePlate"
|
|
||||||
onChange={(e) => setlicensePlate(e.target.value)}
|
|
||||||
/>
|
|
||||||
<label>Color: </label>
|
|
||||||
<input
|
|
||||||
value={color}
|
|
||||||
type="text"
|
|
||||||
name="color"
|
|
||||||
onChange={(e) => setColor(e.target.value)}
|
|
||||||
/>
|
|
||||||
<label>Type: </label>
|
|
||||||
<select
|
|
||||||
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>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button className="btn" onClick={() => registerVehicle()}>
|
<div className="flex flex-col">
|
||||||
Register
|
<InputText
|
||||||
</button>
|
label="Model"
|
||||||
</form>
|
value={model}
|
||||||
|
name="model"
|
||||||
|
onChangeEvent={(e) => setModel(e.target.value)}
|
||||||
|
/>
|
||||||
|
<InputText
|
||||||
|
label="License Plate"
|
||||||
|
value={licensePlate}
|
||||||
|
name="licensePlate"
|
||||||
|
onChangeEvent={(e) => setlicensePlate(e.target.value)}
|
||||||
|
/>
|
||||||
|
<InputText
|
||||||
|
label="Color"
|
||||||
|
value={color}
|
||||||
|
name="color"
|
||||||
|
onChangeEvent={(e) => setColor(e.target.value)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<label>Type: </label>
|
||||||
|
<select
|
||||||
|
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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Button text="Register" onClickEvent={registerVehicle} />
|
||||||
|
</form>
|
||||||
|
</Card>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
|
// Services
|
||||||
import * as apiService from "../../services/apiService";
|
import * as apiService from "../../services/apiService";
|
||||||
|
|
||||||
|
// Components
|
||||||
import Heading1 from "./Heading1";
|
import Heading1 from "./Heading1";
|
||||||
|
import Heading3 from "./Heading3";
|
||||||
import Button from "./Button";
|
import Button from "./Button";
|
||||||
import Table from "./table/Table";
|
import Table from "./table/Table";
|
||||||
|
|
||||||
@ -70,10 +75,7 @@ const VehiclesMain = () => {
|
|||||||
{/* <p>Hello, {user.profile.given_name}.</p> */}
|
{/* <p>Hello, {user.profile.given_name}.</p> */}
|
||||||
{vehicleData ? (
|
{vehicleData ? (
|
||||||
<>
|
<>
|
||||||
<h3 className="font-light font-inter text-black-custom my-20 self-start">
|
<Heading3>Your Vehicles:</Heading3>
|
||||||
Your Vehicles:
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<Table vehicleData={vehicleData} />
|
<Table vehicleData={vehicleData} />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
7
React/src/pages/components/inputs/InputSelect.js
Normal file
7
React/src/pages/components/inputs/InputSelect.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const InputSelect = () => {
|
||||||
|
return <div></div>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default InputSelect;
|
||||||
12
React/src/pages/components/inputs/InputText.js
Normal file
12
React/src/pages/components/inputs/InputText.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const InputText = ({ label, value, name, onChangeEvent }) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<label>{label}</label>
|
||||||
|
<input value={value} type="text" name={name} onChange={onChangeEvent} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default InputText;
|
||||||
Loading…
Reference in New Issue
Block a user