/**
* @jsx React.DOM
*/
var MealCalc = React.createClass({
render: function() {
var total = this.props.meals.reduce(
function(previousValue, currentValue, index, array) {
return {
Breakfast: previousValue.Breakfast + currentValue.Breakfast,
Lunch: previousValue.Lunch + currentValue.Lunch,
Dinner: previousValue.Dinner + currentValue.Dinner
};
});
return (
| Total (include Tips) |
|
|
|
|
|
|
|
{total.Breakfast + total.Lunch + total.Dinner} |
|
);
}
}
);
var MilesCalc = React.createClass({
render: function() {
var total = this.props.miles.reduce(
function(previousValue, currentValue, index, array) {
return {
distance: (previousValue.distance) + (currentValue.distance)
};
});
return (
| Mult. By Allow per mile (.45 cents) |
|
|
|
|
|
|
|
${total.distance * .45} |
|
);
}
}
);
var MilesRow = React.createClass({
render: function() {
var total = this.props.miles.reduce(
function(previousValue, currentValue, index, array) {
return {
distance: previousValue.distance + currentValue.distance
};
});
return (
| Miles Driven |
{this.props.miles[0].distance} |
{this.props.miles[1].distance} |
{this.props.miles[2].distance} |
{this.props.miles[3].distance} |
{this.props.miles[4].distance} |
{this.props.miles[5].distance} |
{this.props.miles[6].distance} |
{total} |
|
);
}
}
);
var MealRow = React.createClass({
render: function() {
var total=0;
if (this.props.meal=="Breakfast") {
var total = this.props.meals.reduce(
function(previousValue, currentValue, index, array) {
return {
Breakfast: previousValue.Breakfast + currentValue.Breakfast
};
});
return (
|
{this.props.meal} |
{this.props.meals[0].Breakfast} |
{this.props.meals[1].Breakfast} |
{this.props.meals[2].Breakfast} |
{this.props.meals[3].Breakfast} |
{this.props.meals[4].Breakfast} |
{this.props.meals[5].Breakfast} |
{this.props.meals[6].Breakfast} |
{total} |
|
);
} else if (this.props.meal=="Lunch") {
var total = this.props.meals.reduce(
function(previousValue, currentValue, index, array) {
return {
Lunch: previousValue.Lunch + currentValue.Lunch
};
});
return (
|
{this.props.meal} |
{this.props.meals[0].Lunch} |
{this.props.meals[1].Lunch} |
{this.props.meals[2].Lunch} |
{this.props.meals[3].Lunch} |
{this.props.meals[4].Lunch} |
{this.props.meals[5].Lunch} |
{this.props.meals[6].Lunch} |
{total} |
|
);
} else if (this.props.meal=="Dinner") {
var total = this.props.meals.reduce(
function(previousValue, currentValue, index, array) {
return {
Dinner: previousValue.Dinner + currentValue.Dinner
};
});
return (
|
{this.props.meal} |
{this.props.meals[0].Dinner} |
{this.props.meals[1].Dinner} |
{this.props.meals[2].Dinner} |
{this.props.meals[3].Dinner} |
{this.props.meals[4].Dinner} |
{this.props.meals[5].Dinner} |
{this.props.meals[6].Dinner} |
{total} |
|
);
}
}
}
);
var DateRow = React.createClass({
render: function() {
return (
| Date |
Sunday Sept 7, 2014 |
Monday Sept 8, 2014 |
Tuesday Sept 9, 2014 |
Wednesday Sept 10, 2014 |
Thursday Sept 11, 2014 |
Friday Sept 12, 2014 |
Saturday Sept 13, 2014 |
Totals |
|
);
}
}
);
var ExpenseReport = React.createClass({
render: function() {
var miles = this.props.miles;
var meals = this.props.meals;
return (
| Section 1 |
Auto and Meals Expense |
Section 3 Comments |
);
},
});
/* mock data */
var miles = [
{distance:3.3},
{distance:4.0},
{distance:2.0},
{distance:0.0},
{distance:0.0},
{distance:0.0},
{distance:22}
];
var meals = [
{Breakfast:2.0,Lunch:3.5,Dinner:9.9},
{Breakfast:9.0,Lunch:3.5,Dinner:9.9},
{Breakfast:0.0,Lunch:12.5,Dinner:20},
{Breakfast:8.4,Lunch:5,Dinner:30},
{Breakfast:9.9,Lunch:3.5,Dinner:32},
{Breakfast:2.0,Lunch:3.5,Dinner:9},
{Breakfast:5,Lunch:8,Dinner:22.30}
];
React.renderComponent(, document.body);