mirror of
https://github.com/ditkrg/AuthorizationServerDemos.git
synced 2026-01-23 06:36:43 +00:00
Renders vehicleData into the Table
This commit is contained in:
parent
50777f9f30
commit
96c8ba64dd
@ -1,9 +1,9 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const Button = ({ onClickEvent, text }) => (
|
const Button = ({ onClickEvent, text, classes = "" }) => (
|
||||||
<button
|
<button
|
||||||
onClick={onClickEvent}
|
onClick={onClickEvent}
|
||||||
className="bg-blue-custom border-0 font-inter font-semibold rounded text-xl m-0"
|
className={`bg-blue-custom border-0 font-inter font-semibold rounded text-xl m-0 ${classes}`}
|
||||||
>
|
>
|
||||||
{text}
|
{text}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@ -46,35 +46,6 @@ const VehiclesMain = () => {
|
|||||||
licensePlate: "9956443",
|
licensePlate: "9956443",
|
||||||
type: 1,
|
type: 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
|
||||||
id: Math.floor(Math.random() * 200) + 1,
|
|
||||||
color: "White",
|
|
||||||
model: "Toyota Camry",
|
|
||||||
licensePlate: "9956443",
|
|
||||||
type: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: Math.floor(Math.random() * 200) + 1,
|
|
||||||
color: "White",
|
|
||||||
model: "Toyota Camry",
|
|
||||||
licensePlate: "9956443",
|
|
||||||
type: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: Math.floor(Math.random() * 200) + 1,
|
|
||||||
color: "White",
|
|
||||||
model: "Toyota Camry",
|
|
||||||
licensePlate: "9956443",
|
|
||||||
type: 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: Math.floor(Math.random() * 200) + 1,
|
|
||||||
color: "White",
|
|
||||||
model: "Toyota Camry",
|
|
||||||
licensePlate: "9956443",
|
|
||||||
type: 1,
|
|
||||||
},
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -87,22 +58,14 @@ const VehiclesMain = () => {
|
|||||||
setVehicleData(vehicles);
|
setVehicleData(vehicles);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType(type) {
|
|
||||||
switch (type) {
|
|
||||||
case 1:
|
|
||||||
return "Sedan";
|
|
||||||
case 2:
|
|
||||||
return "SUV";
|
|
||||||
case 3:
|
|
||||||
return "Pickup";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<Heading1
|
<Heading1
|
||||||
text={"Traffic Police Service"}
|
text={"Traffic Police Service"}
|
||||||
styles={{ marginBottom: "0", marginTop: "20%" }}
|
styles={{
|
||||||
|
marginBottom: "0",
|
||||||
|
...(!vehicleData && { marginTop: "10%" }),
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
{/* <p>Hello, {user.profile.given_name}.</p> */}
|
{/* <p>Hello, {user.profile.given_name}.</p> */}
|
||||||
{vehicleData ? (
|
{vehicleData ? (
|
||||||
@ -111,7 +74,7 @@ const VehiclesMain = () => {
|
|||||||
Your Vehicles:
|
Your Vehicles:
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<Table />
|
<Table vehicleData={vehicleData} />
|
||||||
|
|
||||||
{/* <ul>
|
{/* <ul>
|
||||||
{vehicleData.map((v) => (
|
{vehicleData.map((v) => (
|
||||||
@ -126,7 +89,10 @@ const VehiclesMain = () => {
|
|||||||
No vehicles yet.
|
No vehicles yet.
|
||||||
</h3>
|
</h3>
|
||||||
)}
|
)}
|
||||||
<Button text={"Register A Vehicle"} />
|
<Button
|
||||||
|
text="Register A Vehicle"
|
||||||
|
classes={vehicleData && "self-start mt-20"}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -3,29 +3,42 @@ import ColumnName from "./ColumnName";
|
|||||||
import EditBtns from "./EditBtns";
|
import EditBtns from "./EditBtns";
|
||||||
import TableData from "./TableData";
|
import TableData from "./TableData";
|
||||||
|
|
||||||
const Table = () => {
|
const Table = ({ vehicleData }) => {
|
||||||
|
function getType(type) {
|
||||||
|
switch (type) {
|
||||||
|
case 1:
|
||||||
|
return "Sedan";
|
||||||
|
case 2:
|
||||||
|
return "SUV";
|
||||||
|
case 3:
|
||||||
|
return "Pickup";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="shadow overflow-hidden border-b border-gray-200 sm:rounded">
|
<div className="shadow overflow-hidden border-b border-gray-200 sm:rounded">
|
||||||
<table className="min-w-full divide-y divide-gray-200">
|
<table className="min-w-full divide-y divide-gray-200 mb-0">
|
||||||
<thead className="bg-gray-50">
|
<thead className="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
<ColumnName text={"Name"} />
|
<ColumnName text={"Model"} />
|
||||||
<ColumnName text={"Title"} />
|
<ColumnName text={"License Plate"} />
|
||||||
<ColumnName text={"Status"} />
|
<ColumnName text={"Color"} />
|
||||||
<ColumnName text={"Role"} />
|
<ColumnName text={"Type"} />
|
||||||
<th scope="col" className="relative px-6 py-3">
|
<th scope="col" className="relative px-6 py-3">
|
||||||
<span className="sr-only">Actions</span>
|
<span className="sr-only">Actions</span>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="bg-white divide-y divide-gray-200">
|
<tbody className="bg-white divide-y divide-gray-200">
|
||||||
<tr>
|
{vehicleData.map((vehicle) => (
|
||||||
<TableData text={"Jane Cooper"} />
|
<tr key={vehicle.id}>
|
||||||
<TableData text={"Regional Paradigm Technician"} />
|
<TableData text={vehicle.model} />
|
||||||
<TableData text={"Active"} />
|
<TableData text={vehicle.licensePlate} />
|
||||||
<TableData text={"Admin"} />
|
<TableData text={vehicle.color} />
|
||||||
|
<TableData text={getType(vehicle.type)} />
|
||||||
<TableData Component={EditBtns} />
|
<TableData Component={EditBtns} />
|
||||||
</tr>
|
</tr>
|
||||||
|
))}
|
||||||
|
|
||||||
{/* <!-- More items... --> */}
|
{/* <!-- More items... --> */}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user