import React from 'react'; import { useNavigate } from 'react-router-dom'; import RebuMKService from "../../repository/rebuRepository"; import CenteredContainer from '../UtilComponents/CenteredContainer'; import '../UtilComponents/App.css' const Login = (props) => { const navigate = useNavigate(); const [formData, updateFormData] = React.useState({ username: "", password: "" }) const handleChange = (e) => { updateFormData({ ...formData, [e.target.name]: e.target.value.trim() }) } const onFormSubmit = (e) => { e.preventDefault(); RebuMKService.login(formData.username, formData.password).then(resp => { if(resp.data.typeOfLoggedUser === "Driver"){ localStorage.setItem("driverId", resp.data.idOfLoggedUser) props.onLogin(); props.onLoadRequests(resp.data.idOfLoggedUser) navigate("/home"); } else if(resp.data.typeOfLoggedUser === "Passenger"){ localStorage.setItem("passengerId", resp.data.idOfLoggedUser) props.onLogin(); navigate("/home"); } else if(resp.data.typeOfLoggedUser === "Admin"){ localStorage.setItem("adminId", resp.data.idOfLoggedUser) props.onLogin(); navigate("/home"); } else { alert("Login unsucessfull, wrong password or email, try again.") } }) } return (

RebuMK

Login to your account





) } export default Login;