-
Notifications
You must be signed in to change notification settings - Fork 1
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 #34 from NitBravoA92/render-rockets-list
Render the Rockets lists in the UI
- Loading branch information
Showing
7 changed files
with
128 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.rocket-item { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1.2rem; | ||
width: 100%; | ||
padding: 1rem 0; | ||
} | ||
|
||
.rocket-image { | ||
width: 100%; | ||
height: auto; | ||
} | ||
|
||
.rocket-image img { | ||
width: 100%; | ||
} | ||
|
||
.rocket-details { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1rem; | ||
width: 100%; | ||
} | ||
|
||
.rocket-details .title { | ||
font-size: 1.5rem; | ||
font-weight: 700; | ||
color: #333; | ||
} | ||
|
||
.rocket-details .description { | ||
font-size: 1rem; | ||
color: #333; | ||
line-height: 1.5; | ||
} |
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,27 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
const RocketItem = ({ rocket }) => ( | ||
<div className="rocket-item"> | ||
<div className="rocket-image"> | ||
<img src={rocket.image} alt={rocket.name} /> | ||
</div> | ||
<div className="rocket-details"> | ||
<h2 className="title">{rocket.name}</h2> | ||
<p className="description">{rocket.description}</p> | ||
<div className="reserve"> | ||
<button type="button" className="btn btn-blue">Reserve Rocket</button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
RocketItem.propTypes = { | ||
rocket: PropTypes.shape({ | ||
id: PropTypes.string.isRequired, | ||
name: PropTypes.string.isRequired, | ||
description: PropTypes.string.isRequired, | ||
image: PropTypes.string.isRequired, | ||
}).isRequired, | ||
}; | ||
|
||
export default RocketItem; |
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,32 @@ | ||
import { useSelector } from 'react-redux'; | ||
import RocketItem from './RocketItem'; | ||
|
||
const RocketsContent = () => { | ||
const { rockets, isLoading, error } = useSelector((state) => state.rockets); | ||
|
||
if (error) { | ||
return ( | ||
<div className="error-message"> | ||
<h2>{error}</h2> | ||
</div> | ||
); | ||
} | ||
|
||
if (isLoading) { | ||
return ( | ||
<div className="loading-message"> | ||
<h2>Loading Rockets...</h2> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="rockets-list"> | ||
{ rockets.map((rocket) => ( | ||
<RocketItem key={rocket.id} rocket={rocket} /> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default RocketsContent; |
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