Skip to content

Commit

Permalink
edit error with pages
Browse files Browse the repository at this point in the history
Relates #37
  • Loading branch information
MohammadAlhalaq committed Oct 2, 2019
1 parent 6425e41 commit 6762ea8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
35 changes: 19 additions & 16 deletions client/src/components/MealPage/MealList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@ import CardMeal from './CardMeal';
import './style.css';

const MealList = ({ data }) => {
const listItems = data.map(item => {
return (
<Link
className="link"
to={{
pathname: '/details',
state: { item },
}}
>
<li>
<CardMeal key={item.id} oneMeal={item} />
</li>
</Link>
);
});
return <ul className="menu">{listItems}</ul>;
if (data) {
const listItems = data.map(item => {
return (
<Link
className="link"
to={{
pathname: '/details',
state: { item },
}}
>
<li>
<CardMeal key={item.id} oneMeal={item} />
</li>
</Link>
);
});
return <ul className="menu">{listItems}</ul>;
}
return '';
};
MealList.propTypes = {
data: PropTypes.isRequired,
Expand Down
8 changes: 5 additions & 3 deletions client/src/components/MealPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ class MenuPage extends React.Component {
fetch(`/api/v1/meals?category=${cat}`)
.then(res => res.json())
.then(result => {
this.setState({
data: result.data,
});
if (result.data) {
this.setState({
data: result.data,
});
}
})
.then(this.changeStateCat())
.catch(() => history.push('/serverError'));
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/feedback/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class FeedbackComponent extends React.Component {
<div>
{this.feedbackPopUp()}
<div className="bg">
<div className="card">
<div className="card-feedback">
<h3 className="header-feedback"> feedback</h3>
<div className="order-info">
<div className="order-number">
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/feedback/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
padding: 1.4rem;
}

.card{
.card-feedback{
margin: 1rem auto;
background: #000;
font-family: Lato, sans-serif;
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const getMeals = require('./getMeals');
const router = express.Router();

router.post('/login', login);
router.use(auth);
router.get('/meals', getMeals);
router.use(auth);
router.post('/post-feedback', postFeedback);
router.post('/order', addOrder);
router.get('/logout', logout);
Expand Down

0 comments on commit 6762ea8

Please sign in to comment.