Creates some Table components

This commit is contained in:
Vazhin Tayeb 2021-01-15 08:48:23 +03:00
parent 2993db6e54
commit 25b732111f
7 changed files with 84 additions and 2 deletions

View File

@ -10628,6 +10628,11 @@
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.2.tgz", "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.2.tgz",
"integrity": "sha512-DHRuRk3K4Lg9obI6J4Y+nKvtwjasYRU9CFL3ud42x9YJG1HbQjSNublapC/WBJOA726gNUbqbj0U2df9+uzspQ==" "integrity": "sha512-DHRuRk3K4Lg9obI6J4Y+nKvtwjasYRU9CFL3ud42x9YJG1HbQjSNublapC/WBJOA726gNUbqbj0U2df9+uzspQ=="
}, },
"react-icons": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.1.0.tgz",
"integrity": "sha512-FCXBg1JbbR0vWALXIxmFAfozHdVIJmmwCD81Jk0EKOt7Ax4AdBNcaRkWhR0NaKy9ugJgoY3fFvo0PHpte55pXg=="
},
"react-is": { "react-is": {
"version": "16.9.0", "version": "16.9.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz",

View File

@ -8,6 +8,7 @@
"oidc-client": "^1.9.1", "oidc-client": "^1.9.1",
"react": "^16.10.0", "react": "^16.10.0",
"react-dom": "^16.10.0", "react-dom": "^16.10.0",
"react-icons": "^4.1.0",
"react-redux": "^7.1.1", "react-redux": "^7.1.1",
"react-router-dom": "^5.1.0", "react-router-dom": "^5.1.0",
"react-scripts": "3.1.2", "react-scripts": "3.1.2",

View File

@ -4,6 +4,7 @@ import * as apiService from "../../services/apiService";
import { prettifyJson } from "../../utils/jsonUtils"; import { prettifyJson } from "../../utils/jsonUtils";
import Heading1 from "./Heading1"; import Heading1 from "./Heading1";
import Button from "./Button"; import Button from "./Button";
import Table from "./table/Table";
const VehiclesMain = () => { const VehiclesMain = () => {
const user = useSelector((state) => state.auth.user); const user = useSelector((state) => state.auth.user);
@ -110,13 +111,15 @@ const VehiclesMain = () => {
Your Vehicles: Your Vehicles:
</h3> </h3>
<ul> <Table />
{/* <ul>
{vehicleData.map((v) => ( {vehicleData.map((v) => (
<li key={v.id}> <li key={v.id}>
{v.color} {v.model} ({v.licensePlate}) - {getType(v.type)} {v.color} {v.model} ({v.licensePlate}) - {getType(v.type)}
</li> </li>
))} ))}
</ul> </ul> */}
</> </>
) : ( ) : (
<h3 className="font-light font-inter text-black-custom my-32 self-center"> <h3 className="font-light font-inter text-black-custom my-32 self-center">

View File

@ -0,0 +1,12 @@
import React from "react";
const ColumnName = ({ text }) => (
<th
scope="col"
className="px-16 py-4 whitespace-nowrap text-2xl font-inter text-black-custom font-semibold"
>
{text}
</th>
);
export default ColumnName;

View File

@ -0,0 +1,15 @@
import React from "react";
import { FiSettings, FiTrash } from "react-icons/fi";
import { BsThreeDots } from "react-icons/bs";
const EditBtns = () => {
return (
<div className="flex">
<FiTrash className="mx-3" />
<FiSettings className="mx-3" />
<BsThreeDots className="mx-3 text-3xl" />
</div>
);
};
export default EditBtns;

View File

@ -0,0 +1,37 @@
import React from "react";
import ColumnName from "./ColumnName";
import EditBtns from "./EditBtns";
import TableData from "./TableData";
const Table = () => {
return (
<div className="shadow overflow-hidden border-b border-gray-200 sm:rounded">
<table className="min-w-full divide-y divide-gray-200">
<thead className="bg-gray-50">
<tr>
<ColumnName text={"Name"} />
<ColumnName text={"Title"} />
<ColumnName text={"Status"} />
<ColumnName text={"Role"} />
<th scope="col" className="relative px-6 py-3">
<span className="sr-only">Actions</span>
</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-gray-200">
<tr>
<TableData text={"Jane Cooper"} />
<TableData text={"Regional Paradigm Technician"} />
<TableData text={"Active"} />
<TableData text={"Admin"} />
<TableData Component={EditBtns} />
</tr>
{/* <!-- More items... --> */}
</tbody>
</table>
</div>
);
};
export default Table;

View File

@ -0,0 +1,9 @@
import React from "react";
const TableData = ({ text, Component }) => (
<td className="px-16 py-4 whitespace-nowrap text-2xl font-inter text-black-custom font-normal">
{text ? text : <Component />}
</td>
);
export default TableData;