-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
610 additions
and
21,731 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import axios from "axios"; | ||
|
||
export const createConnectAccount = async (token) => | ||
await axios.post( | ||
`http://localhost:8080/api/create-connect-account`, | ||
{}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
} | ||
); | ||
|
||
export const getAccountStatus = async (token) => | ||
await axios.post( | ||
`http://localhost:8080/api/get-account-status`, | ||
{}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
} | ||
); | ||
|
||
export const getAccountBalance = async (token) => | ||
await axios.post( | ||
`http://localhost:8080/api/get-account-balance`, | ||
{}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
} | ||
); | ||
|
||
export const currencyFormatter = (data) => { | ||
return (data.amount / 100).toLocaleString(data.currency, { | ||
style: "currency", | ||
currency: data.currency, | ||
}); | ||
}; | ||
|
||
export const payoutSetting = async (token) => | ||
await axios.post( | ||
`http://localhost:8080/api/payout-setting`, | ||
{}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
} | ||
); | ||
|
||
export const getSessionId = async (token, serviceId) => | ||
await axios.post( | ||
`http://localhost:8080/api/stripe-session-id`, | ||
{ | ||
serviceId, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
} | ||
); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,70 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { getUser } from "../../actions/auth"; | ||
import Map from "../Map"; | ||
import { getRide } from "../../actions/ride"; | ||
import {getUser} from '../../actions/auth' | ||
|
||
const CurrentRides = () => { | ||
const [rideState, setRideState] = useState("noRide"); | ||
const CurrentRides = ({ tD, fD}) => { | ||
|
||
const [rideState, setRideState] = useState(""); | ||
const [rideDetails, setRideDetails] = useState({}); | ||
useEffect(() => { | ||
const items = JSON.parse(localStorage.getItem("auth")); | ||
const userId = items.user._id; | ||
|
||
async function fetchUser() { | ||
let user = await getUser(userId); | ||
// if(user.) | ||
user = user.data; | ||
console.log("Fetch user: " , user); | ||
if(!user.rideId){ | ||
console.log("No ride"); | ||
setRideState("noRide"); | ||
return; | ||
} | ||
|
||
let ride = await getRide(user.rideId.toString()); | ||
console.log("Ride details ", ride); | ||
setRideDetails(ride.data); | ||
|
||
if(!ride.data.driverId){ | ||
setRideState("waiting"); | ||
return; | ||
} | ||
|
||
setRideState("confirmed"); | ||
|
||
|
||
} | ||
fetchUser(); | ||
}, []); | ||
|
||
return <div>CurrentRides</div>; | ||
return ( | ||
rideState == "noRide" || rideDetails.passengerStartingAddress == null || | ||
rideDetails.passengerStartingAddress == "" || | ||
rideDetails.passengerEndingAddress == null || | ||
rideDetails.passengerEndingAddress == "" ? (<div><h3>No ride currently</h3></div>) : | ||
rideState == "waiting" ? ( | ||
<div> | ||
<h3>Waiting for driver</h3> | ||
<Map tD={rideDetails.passengerStartingAddress} fD={rideDetails.passengerEndingAddress} /> | ||
</div> | ||
) : | ||
rideState == "confirmed" ? ( | ||
<div> | ||
<h3>Ride confirmed</h3> | ||
</div> | ||
) : ( | ||
<div> | ||
Loading... | ||
</div> | ||
|
||
) | ||
|
||
) | ||
}; | ||
|
||
export default CurrentRides; | ||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.