Compare commits
5 Commits
21ed7d3c17
...
06ca8f24cf
Author | SHA1 | Date |
---|---|---|
sovanna | 06ca8f24cf | |
sovanna | c70e171275 | |
sovanna | f6a6555bc8 | |
sovanna | 708d209768 | |
sovanna | 389552e308 |
|
@ -160,7 +160,7 @@ button {
|
||||||
font-size: .8rem;
|
font-size: .8rem;
|
||||||
|
|
||||||
table {
|
table {
|
||||||
max-width: 350px;
|
max-width: 450px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.summary-remove-all {
|
.summary-remove-all {
|
||||||
|
@ -176,7 +176,7 @@ button {
|
||||||
}
|
}
|
||||||
|
|
||||||
.price {
|
.price {
|
||||||
text-align: left;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-card-name > div,
|
.item-card-name > div,
|
||||||
|
|
|
@ -108,6 +108,24 @@ const nbrOccupiedSlotsInCrate = (items) => {
|
||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function formatMoney(amount, decimalCount = 2, decimal = ".", thousands = ",") {
|
||||||
|
// https://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-currency-string-in-javascript
|
||||||
|
// changes: return amount if error in order to avoid empty value
|
||||||
|
try {
|
||||||
|
decimalCount = Math.abs(decimalCount);
|
||||||
|
decimalCount = isNaN(decimalCount) ? 2 : decimalCount;
|
||||||
|
|
||||||
|
const negativeSign = amount < 0 ? "-" : "";
|
||||||
|
|
||||||
|
let i = parseInt(amount = Math.abs(Number(amount) || 0).toFixed(decimalCount)).toString();
|
||||||
|
let j = (i.length > 3) ? i.length % 3 : 0;
|
||||||
|
|
||||||
|
return negativeSign + (j ? i.substr(0, j) + thousands : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands) + (decimalCount ? decimal + Math.abs(amount - i).toFixed(decimalCount).slice(2) : "");
|
||||||
|
} catch (e) {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that provides a base layout (aside/main) for the page.
|
* Component that provides a base layout (aside/main) for the page.
|
||||||
|
@ -196,7 +214,7 @@ class ProductItem extends React.PureComponent {
|
||||||
<div className="content">
|
<div className="content">
|
||||||
<h3>{name}</h3>
|
<h3>{name}</h3>
|
||||||
|
|
||||||
<div className="price">{`${currency} ${price}`}</div>
|
<div className="price">{`${currency} ${formatMoney(price)}`}</div>
|
||||||
|
|
||||||
{render_specs}
|
{render_specs}
|
||||||
</div>
|
</div>
|
||||||
|
@ -438,7 +456,7 @@ class ProductCartItem extends React.PureComponent {
|
||||||
|
|
||||||
<img src="/images/shop/icon-remove.svg" alt="rm"/>
|
<img src="/images/shop/icon-remove.svg" alt="rm"/>
|
||||||
|
|
||||||
<p>remove</p>
|
<p>Remove</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* progression container */}
|
{/* progression container */}
|
||||||
|
@ -891,11 +909,18 @@ class OrderSumary extends React.PureComponent {
|
||||||
<tr>
|
<tr>
|
||||||
<td className="item-card-name">{mode.name}</td>
|
<td className="item-card-name">{mode.name}</td>
|
||||||
<td className="price">
|
<td className="price">
|
||||||
{`${currency} ${mode.price}`}
|
<div>
|
||||||
|
{`${currency} ${formatMoney(mode.price)}`}
|
||||||
|
|
||||||
<button style={{'opacity': '0', 'cursor': 'initial'}}>
|
<button style={{'opacity': '0', 'cursor': 'initial'}}>
|
||||||
<img src="/images/shop/icon-remove.svg" />
|
<img src="/images/shop/icon-remove.svg" />
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span style={{
|
||||||
|
'display': 'inline-block',
|
||||||
|
'width': '30px',
|
||||||
|
}}> </span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
)}
|
||||||
|
@ -927,7 +952,7 @@ class OrderSumary extends React.PureComponent {
|
||||||
|
|
||||||
<td className="price">
|
<td className="price">
|
||||||
<div>
|
<div>
|
||||||
{`${currency} ${item.price}`}
|
{`${currency} ${formatMoney(item.price)}`}
|
||||||
|
|
||||||
<button onClick={this.handleOnDeleteItem.bind(this, index)}>
|
<button onClick={this.handleOnDeleteItem.bind(this, index)}>
|
||||||
<img src="/images/shop/icon-remove.svg" />
|
<img src="/images/shop/icon-remove.svg" />
|
||||||
|
@ -941,6 +966,13 @@ class OrderSumary extends React.PureComponent {
|
||||||
src={`/images/${warning.icon}`}
|
src={`/images/${warning.icon}`}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{!warning && (
|
||||||
|
<span style={{
|
||||||
|
'display': 'inline-block',
|
||||||
|
'width': '30px',
|
||||||
|
}}> </span>
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
|
@ -951,19 +983,26 @@ class OrderSumary extends React.PureComponent {
|
||||||
<tr>
|
<tr>
|
||||||
<td className="item-card-name">Price estimate</td>
|
<td className="item-card-name">Price estimate</td>
|
||||||
<td className="price">
|
<td className="price">
|
||||||
{summary.length ? (
|
<div>
|
||||||
`${currency} ${summary.reduce(
|
{summary.length ? (
|
||||||
(prev, next) => {
|
`${currency} ${formatMoney(summary.reduce(
|
||||||
return prev + next.price;
|
(prev, next) => {
|
||||||
}, 0
|
return prev + next.price;
|
||||||
) + mode.price}`
|
}, 0
|
||||||
) : (
|
) + mode.price)}`
|
||||||
`${currency} ${mode.price}`
|
) : (
|
||||||
)}
|
`${currency} ${formatMoney(mode.price)}`
|
||||||
|
)}
|
||||||
|
|
||||||
<button style={{'opacity': '0', 'cursor': 'initial'}}>
|
<button style={{'opacity': '0', 'cursor': 'initial'}}>
|
||||||
<img src="/images/shop/icon-remove.svg" alt="icon remove"/>
|
<img src="/images/shop/icon-remove.svg" alt="icon remove"/>
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span style={{
|
||||||
|
'display': 'inline-block',
|
||||||
|
'width': '30px',
|
||||||
|
}}> </span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue