-
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.
Update the redirection routes for signin, signup.
- Loading branch information
1 parent
e0387eb
commit 98a84b1
Showing
12 changed files
with
93 additions
and
38 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,35 +1,59 @@ | ||
import React, {useEffect} from 'react'; | ||
import React, { useEffect } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { fetchCarReservations } from '../../redux/thunk'; | ||
|
||
const MyReservationsList = () => { | ||
const dispatch = useDispatch(); | ||
const myReservations = useSelector((state) => state.reservation.reservations); | ||
const status = useSelector((state) => state.reservation.status); | ||
const error = useSelector((state) => state.reservation.error); | ||
const mockData = [ | ||
{ | ||
id: 1, | ||
car: { | ||
id: 3, | ||
name: "Car1" | ||
}, | ||
date: "2023-01-02", | ||
city: "No Peace" | ||
}, | ||
{ | ||
id: 2, | ||
car: { | ||
id: 4, | ||
name: "Car2" | ||
}, | ||
date: "2023-01-03", | ||
city: "Tranquil Town" | ||
}, | ||
// Add more mock data as needed | ||
]; | ||
const dispatch = useDispatch(); | ||
// const myReservations = useSelector((state) => state.reservation.reservations); | ||
const myReservations = mockData; | ||
const status = useSelector((state) => state.reservation.status); | ||
const error = useSelector((state) => state.reservation.error); | ||
|
||
useEffect(() => { | ||
dispatch(fetchCarReservations()); | ||
}, [dispatch]); | ||
useEffect(() => { | ||
dispatch(fetchCarReservations()); | ||
}, [dispatch]); | ||
|
||
if (status === 'loading') { | ||
if (status === 'loading') { | ||
return <p>Loading...</p>; | ||
} | ||
} | ||
|
||
if (status === 'failed') { | ||
if (status === 'failed') { | ||
return <p>Error: {error}</p>; | ||
} | ||
} | ||
|
||
return ( | ||
<div> | ||
<h1>My Reservations</h1> | ||
{myReservations.map((reservation) => ( | ||
<div key={reservation.id}> | ||
<p>{`Car: ${reservation.car.name}, Date: ${reservation.date}, City: ${reservation.city}`}</p> | ||
return ( | ||
<div className='my-reservations-inner'> | ||
<h1>My Reservations</h1> | ||
{myReservations && myReservations.map((reservation) => ( | ||
<div key={reservation.id} className='each-reservation-div'> | ||
<span>{`Car: ${reservation.car.name}`}</span> | ||
<span>{`Date: ${reservation.date}`}</span> | ||
<span>{`City: ${reservation.city}`}</span> | ||
</div> | ||
))} | ||
))} | ||
</div> | ||
); | ||
); | ||
}; | ||
|
||
export default MyReservationsList; |
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 was deleted.
Oops, something went wrong.
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