Skip to content

Commit

Permalink
Tidy code
Browse files Browse the repository at this point in the history
  • Loading branch information
slyg committed Dec 15, 2015
1 parent ab0a915 commit 7b8eefd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 39 deletions.
24 changes: 9 additions & 15 deletions app/scripts/shop/components/PayBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,21 @@ import { PropTypes } from 'react';

const PayBox = ({finalPrice, totalPrice}) => {

const hasDiscount = (finalPrice > 0);
let discountDom;

if (hasDiscount){

const discountPrice = (Math.round((finalPrice + 0.00001) * 100) / 100).toFixed(2);

discountDom = (
<p className='txtcenter mtm'>
Pay {discountPrice}<small>instead of <strike>{totalPrice}</strike>!</small>
</p>
);

}
const discountPrice = (Math.round((finalPrice + 0.00001) * 100) / 100).toFixed(2);
const hasDiscount = (discountPrice > 0);

return (
<div className={hasDiscount ? 'discount' : ''}>
<div className='txtcenter'>
<button className='btn btn-primary btn-large' type='submit'>Order Now</button>
</div>
{discountDom}
{
hasDiscount ?
<p className='txtcenter mtm'>
Pay {discountPrice}<small>instead of <strike>{totalPrice}</strike>!</small>
</p>
: null
}
</div>
);

Expand Down
39 changes: 16 additions & 23 deletions public/shop.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -40758,14 +40758,22 @@
var finalPrice = _ref.finalPrice;
var totalPrice = _ref.totalPrice;

var hasDiscount = finalPrice > 0;
var discountDom = undefined;
var discountPrice = (Math.round((finalPrice + 0.00001) * 100) / 100).toFixed(2);
var hasDiscount = discountPrice > 0;

if (hasDiscount) {

var discountPrice = (Math.round((finalPrice + 0.00001) * 100) / 100).toFixed(2);

discountDom = _react2['default'].createElement(
return _react2['default'].createElement(
'div',
{ className: hasDiscount ? 'discount' : '' },
_react2['default'].createElement(
'div',
{ className: 'txtcenter' },
_react2['default'].createElement(
'button',
{ className: 'btn btn-primary btn-large', type: 'submit' },
'Order Now'
)
),
hasDiscount ? _react2['default'].createElement(
'p',
{ className: 'txtcenter mtm' },
'Pay ',
Expand All @@ -40783,22 +40791,7 @@
),
'!'
)
);
}

return _react2['default'].createElement(
'div',
{ className: hasDiscount ? 'discount' : '' },
_react2['default'].createElement(
'div',
{ className: 'txtcenter' },
_react2['default'].createElement(
'button',
{ className: 'btn btn-primary btn-large', type: 'submit' },
'Order Now'
)
),
discountDom
) : null
);
};

Expand Down
2 changes: 1 addition & 1 deletion public/shop.bundle.js.map

Large diffs are not rendered by default.

0 comments on commit 7b8eefd

Please sign in to comment.