Skip to content

Commit

Permalink
🔀 Merge pull request #28 from alexlee-dev/feature/ship-cargo-capacity
Browse files Browse the repository at this point in the history
✨ Limit maximum number of items in ship cargo to 5.
  • Loading branch information
Alex Lee authored Aug 21, 2019
2 parents ec5cdc3 + 0e3bbb6 commit f25e56a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/views/planets.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const PlanetsView = ({
handleShipTravel,
handleStoreCargo,
planets,
shipCargoLength,
shipLocationValue
}) => {
const [storagePlanets, setStoragePlanets] = useLocalStorage('planets', [])
Expand Down Expand Up @@ -60,6 +61,7 @@ const PlanetsView = ({
{shipLocationValue === location && (
<Box pad="medium">
<Button
disabled={shipCargoLength === 5}
hoverIndicator
icon={<Add />}
onClick={() =>
Expand All @@ -86,11 +88,13 @@ PlanetsView.propTypes = {
handleShipTravel: PropTypes.func.isRequired,
handleStoreCargo: PropTypes.func.isRequired,
planets: PropTypes.array.isRequired,
shipCargoLength: PropTypes.number.isRequired,
shipLocationValue: PropTypes.number.isRequired
}

const mapStateToProps = ({ ship, world }) => ({
planets: world.planets,
shipCargoLength: ship.cargo.length,
shipLocationValue: ship.location.value
})

Expand Down

0 comments on commit f25e56a

Please sign in to comment.