Skip to content

Commit

Permalink
Added static data to MealPlanner
Browse files Browse the repository at this point in the history
Related to #8
  • Loading branch information
sanchit94 committed Jun 28, 2018
1 parent 27bfcc6 commit fb7764b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
32 changes: 26 additions & 6 deletions src/component/MealPlanner/MealPlan.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, { Component } from 'react';
import { AddMeal } from '../Modals/AddMealModal';
import { Container, Row, Col, Card, CardImg, CardText, CardBody, CardTitle, } from 'reactstrap';
import { cardWidth, cardHeight, topMargin } from './MealPlanStyle'
import { cardSize, cardHeight, topMargin } from './MealPlanStyle'
import { img_url } from '../../data/Images_url'

class MealPlan extends Component {
constructor(props) {
super(props);
Expand All @@ -13,7 +15,8 @@ class MealPlan extends Component {
description: '',
descriptions: [],
step: '',
steps: []
steps: [],
showAddMealMessage: false
};
this.renderMeals = this.renderMeals.bind(this);
this.handleClick = this.handleClick.bind(this);
Expand All @@ -34,6 +37,7 @@ class MealPlan extends Component {
<div>
<Col xs='3'>
<Card style={cardWidth} key={index}>
<Card style={cardSize} key={index}>
<CardImg key={index} top width="100%" style={cardHeight} src={this.state.images[index]} alt="This image is not supported" />
<CardBody key={index}>
<CardTitle>{meal}</CardTitle>
Expand Down Expand Up @@ -77,13 +81,28 @@ class MealPlan extends Component {

handleClick() {
this.setState({
meals: [...this.state.meals, this.state.meal],
images: [...this.state.images, this.state.imgURL],
descriptions: [...this.state.descriptions, this.state.description],
steps: [...this.state.steps, this.state.step]
meals : [...this.state.meals, this.state.meal],
images : [...this.state.images, this.state.imgURL],
descriptions : [...this.state.descriptions, this.state.description],
steps : [...this.state.steps, this.state.step]
});
}

componentWillMount() {
this.setState({
meals : ['Burger', 'Pizza'],
images : img_url,
descriptions : ['Burgers are eaten all over the world, and are one of the most handy and easy to make recipy', 'Pizza is a mouth watering dish']
})
}

componentDidUpdate(prevProps, prevState) {
if (prevState.meals.length < this.state.meals.length) {
this.setState({showAddMealMessage: true});
setTimeout(() => this.setState({showAddMealMessage: false}), 2000);
}
}




Expand All @@ -99,6 +118,7 @@ class MealPlan extends Component {
changeHandle={this.changeHandle}
handleClick={this.handleClick} />
<div style={topMargin}>
<div>{this.state.showAddMealMessage ? <h3>Meal was added</h3> : null}</div>
<ul>
{this.renderMeals()}
</ul>
Expand Down
7 changes: 4 additions & 3 deletions src/component/MealPlanner/MealPlanStyle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
let cardWidth = {
width: '300px'
let cardSize = {
width: '300px',
height: '400px'
}

let cardHeight = {
Expand All @@ -11,4 +12,4 @@ let topMargin = {
}


export { cardWidth, cardHeight, topMargin }
export { cardSize, cardHeight, topMargin }
2 changes: 1 addition & 1 deletion src/component/WorkSchedule/DayModel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { data } from '../../data/Data';
import { data } from '../../data/Data_WorkSceh';
import { Modals } from '../Modals/ModalWork';
import { ListGroupItem, ListGroup } from 'reactstrap';
import { defaultBlockHeight, fillerBlockHeight } from '../../data/style_vars'
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions src/data/Images_url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let img_url = [
'https://dmi4pvc5gbhhd.cloudfront.net/2016/08/easy-black-bean-burger-4-650x433.jpg',
'https://recipes.timesofindia.com/photo/53110049.cms'
]

export { img_url }

0 comments on commit fb7764b

Please sign in to comment.