1 | import React from "react";
|
---|
2 | import { useLocation, useNavigate } from 'react-router-dom'
|
---|
3 | import axios from "../../custom-axios/axios";
|
---|
4 | import '../UtilComponents/App.css'
|
---|
5 |
|
---|
6 | const UnapprovedDrivers = (props) => {
|
---|
7 |
|
---|
8 | const location = useLocation();
|
---|
9 | const navigate = useNavigate();
|
---|
10 |
|
---|
11 | const checkDriversCar = async (driverId) => {
|
---|
12 | const carResponse = await axios.get(`/car/driver/${driverId}`).catch(function (error) {
|
---|
13 | if (error.response) {
|
---|
14 | alert("There is no car registered for that driver.")
|
---|
15 | }
|
---|
16 | })
|
---|
17 | navigate("/car", {state: {car: carResponse.data}})
|
---|
18 | }
|
---|
19 |
|
---|
20 | return(
|
---|
21 | <div className={"container mm-4 mt-5"} style={{width: "85%", margin: 'auto'}}>
|
---|
22 | <h2 style={{textAlign: "center", color: "darkcyan"}}>Unapproved Drivers</h2>
|
---|
23 | <hr></hr>
|
---|
24 | <div className={"row table-responsive"}>
|
---|
25 | <div className={"row"} style={{margin: 'auto'}}>
|
---|
26 | <table className={"table table-hover"}>
|
---|
27 | <thead>
|
---|
28 | <tr>
|
---|
29 | <th scope={"col"}>Name</th>
|
---|
30 | <th scope={"col"}>Surname</th>
|
---|
31 | <th scope={"col"}>Price per kilometer</th>
|
---|
32 | <th scope={"col"}>Status</th>
|
---|
33 | <th scope={"col"}>Level</th>
|
---|
34 | <th scope={"col"}>Number of grades</th>
|
---|
35 | <th scope={"col"}>Grade</th>
|
---|
36 | <th scope={"col"}></th>
|
---|
37 | <th scope={"col"}></th>
|
---|
38 | <th scope={"col"}></th>
|
---|
39 | </tr>
|
---|
40 |
|
---|
41 | </thead>
|
---|
42 | <tbody>
|
---|
43 | {props.drivers.map((term) => {
|
---|
44 | return(
|
---|
45 | <tr>
|
---|
46 | <td>{term.name}</td>
|
---|
47 | <td>{term.surname}</td>
|
---|
48 | <td>{term.pricePerKm}</td>
|
---|
49 | <td>{term.status}</td>
|
---|
50 | <td>{term.level}</td>
|
---|
51 | <td>{term.numGrades}</td>
|
---|
52 | <td>{term.grade}</td>
|
---|
53 | <td className={"text-right"}>
|
---|
54 | <a title={"Approve Driver"} className={"myButton btn btn-primary"}
|
---|
55 | style={{backgroundColor: "cyan", borderColor: "black", color: 'black'}}
|
---|
56 | onClick={() => props.onApproveDriver(term.id)}>Approve</a>
|
---|
57 | </td>
|
---|
58 | <td className={"text-right"}>
|
---|
59 | <a title={"Check driver's car"} className="myButton btn btn-primary"
|
---|
60 | style={{backgroundColor: "coral", borderColor: "black", borderColor: 'black', color: 'black'}}
|
---|
61 | onClick={() => checkDriversCar(term.id)}>Check car</a>
|
---|
62 | </td>
|
---|
63 | <td className={"text-right"}>
|
---|
64 | <a title={"Check driver's car"} className="myButton btn btn-primary"
|
---|
65 | style={{backgroundColor: "red", borderColor: "black", borderColor: 'black', color: 'black'}}
|
---|
66 | onClick={() => props.onDenyDriver(term.id)}>Deny</a>
|
---|
67 | </td>
|
---|
68 | </tr>
|
---|
69 | )
|
---|
70 | })}
|
---|
71 | </tbody>
|
---|
72 | </table>
|
---|
73 | </div>
|
---|
74 | </div>
|
---|
75 | </div>
|
---|
76 | )
|
---|
77 | }
|
---|
78 |
|
---|
79 | export default UnapprovedDrivers; |
---|