source: RebuMKReact/src/Components/Drive/pay-drive.js

Last change on this file was 364f27d, checked in by MetodiMladenovski <meto.18@…>, 14 months ago

added projects and db scripts

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[364f27d]1import React from "react";
2import { useLocation, useNavigate } from 'react-router-dom'
3import CenteredContainer from "../UtilComponents/CenteredContainer";
4import axios from "../../custom-axios/axios";
5import '../UtilComponents/App.css'
6
7const PayDrive = (props) => {
8 const location = useLocation();
9 const navigate = useNavigate();
10
11 const payDrive = async () => {
12 const driveId = location.state.driveId
13 const totalPriceToPay = location.state.totalSumToPay
14 const response = await axios.post(`/drive/pay/${driveId}`, null, { params: {
15 totalPriceToPay
16 }
17 });
18 const paymentId = response.data;
19 navigate("/tip-driver", {state: {paymentId: paymentId}})
20 }
21
22 return (
23 <CenteredContainer>
24 <div className="card text-center">
25 <h4>You have travelled <br></br>
26 {location.state.kmTravelled} km <br></br>
27 with a price per km <br></br>
28 {location.state.driverPricePerKm} MKD</h4>
29 <br></br>
30 <h3 style={{color: "green"}}>Your total price to pay is <br></br>
31 {(Math.round(location.state.totalSumToPay * 100) / 100).toFixed(2)} MKD</h3>
32 <hr></hr>
33 <p style={{textAlign: 'center'}}>
34 <a type="submit" className="myButton btn btn-primary" style={{backgroundColor: "darkcyan", borderColor: 'black', color: 'white', width: '90%'}} onClick={() => payDrive()}>Pay Drive</a>
35 </p>
36 </div>
37 </CenteredContainer>
38 )
39}
40
41export default PayDrive;
Note: See TracBrowser for help on using the repository browser.