-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from HENRYKC24/missions-branch
Display Rockets
- Loading branch information
Showing
7 changed files
with
189 additions
and
16 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
"react" | ||
], | ||
"rules": { | ||
"react/prop-types": 0, | ||
"react/jsx-filename-extension": [ | ||
"warn", | ||
{ | ||
|
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,5 +1,6 @@ | ||
import React from 'react'; | ||
import ReservedRockets from './ReservedRockets'; | ||
|
||
const MyProfile = () => <div>Welcome to the profile page!</div>; | ||
const MyProfile = () => <div><ReservedRockets /></div>; | ||
|
||
export default MyProfile; |
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,17 @@ | ||
import { useSelector } from 'react-redux'; | ||
|
||
const ReservedRockets = () => { | ||
const rockets = useSelector((state) => state.rockets.filter((rocket) => rocket.reserved)); | ||
|
||
return ( | ||
<div> | ||
<ul className="profile-rockets"> | ||
{rockets.length > 0 ? rockets.map((rocket) => ( | ||
<li key={rocket.id} rocket={rocket}><b>{rocket.rocketName}</b></li> | ||
)) : 'No Rockets Reserved'} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ReservedRockets; |
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,5 +1,18 @@ | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import SingleRocket from './SingleRocket'; | ||
|
||
const Rockets = () => <div>Welcome to the rockets page!</div>; | ||
const Rockets = () => { | ||
const rockets = useSelector((state) => state.rockets); | ||
|
||
return ( | ||
<div> | ||
<ul> | ||
{rockets.length > 0 ? rockets.map((rocket) => ( | ||
<SingleRocket key={rocket.id} rocket={rocket} /> | ||
)) : 'No Rockets'} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Rockets; |
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,35 @@ | ||
import { useDispatch } from 'react-redux'; | ||
import { addRevervation } from '../redux/rockets/rockets'; | ||
|
||
const SingleRocket = ({ rocket }) => { | ||
const dispatch = useDispatch(); | ||
const { | ||
rocketImage, rocketName, reserved, description, | ||
} = rocket; | ||
|
||
return ( | ||
<li className="single-rocket"> | ||
<div className="rocket-image-section"> | ||
<img src={rocketImage} alt={rocket.rocketName} className="rocket-image" /> | ||
</div> | ||
<div className="rocket-desc"> | ||
<span><b>{rocketName}</b></span> | ||
<span> | ||
{reserved && <small className="rocket-reserved">Reserved</small>} | ||
{description} | ||
</span> | ||
<span> | ||
<button | ||
onClick={() => dispatch(addRevervation(rocket.id))} | ||
type="button" | ||
className={reserved ? 'rocket-btn-reserved' : 'rocket-btn'} | ||
> | ||
{reserved ? 'Cancel Reservation' : 'Reserve Rocket'} | ||
</button> | ||
</span> | ||
</div> | ||
</li> | ||
); | ||
}; | ||
|
||
export default SingleRocket; |
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