import React, { useState } from "react"; import { useNavigate, Link } from 'react-router-dom' import CenteredContainer from "../UtilComponents/CenteredContainer"; import axios from "../../custom-axios/axios"; import '../UtilComponents/App.css' const DriverProfile = (props) => { const navigate = useNavigate(); const [profilePicture, setProfilePicture] = useState(null) const uploadProfilePicture = async (driverId) => { await props.onChangeProfilePicture(driverId, profilePicture); navigate("/home"); } const onFileChange = (e) => { e.preventDefault(); const fileData = new FormData(); fileData.append('picture', e.target.files[0]); setProfilePicture(fileData); } const checkDriversCar = async () => { const driverId = localStorage.getItem("driverId") const carResponse = await axios.get(`/car/driver/${driverId}`).catch(function (error) { if (error.response) { alert("You haven't registered a car yet. Click on Add Car to do so.") } }) navigate("/car", {state: {car: carResponse.data}}) } const IMAGE_SRC = `http://localhost:8080/driver/${props.driver.id}/profile/picture`; return(

Welcome to your profile

NOT AVAILABLE
{props.driver.name} {props.driver.surname}

Status: {props.driver.status}

Price per kilometer: {props.driver.pricePerKm} MKD

Level: {props.driver.level}

Number of grades: {props.driver.numGrades}

Grade: {(Math.round(props.driver.grade * 100) / 100).toFixed(2)}


Upload or change your profile picture:

Supported files .png and .jpeg uploadProfilePicture(props.driver.id)}> Change picture
Add car checkDriversCar()}>Check car
) } export default DriverProfile;