cart page bearable on mobile
This commit is contained in:
@@ -16,7 +16,7 @@ before do
|
||||
content_type :json
|
||||
# TODO: before running to production change this so that only specific
|
||||
# domain is allowed
|
||||
headers 'Access-Control-Allow-Origin' => 'http://localhost:3001',
|
||||
headers 'Access-Control-Allow-Origin' => 'http://192.168.1.37:3001',
|
||||
'Access-Control-Allow-Methods' => ['OPTIONS', 'GET', 'POST','PUT'],
|
||||
'Access-Control-Allow-Headers' => 'Origin, X-Requested-With, Content-Type, Accept',
|
||||
'Access-Control-Expose-Headers' => 'X-Total-Count',
|
||||
|
||||
@@ -47,7 +47,7 @@ module.exports = function(grunt) {
|
||||
dev: {
|
||||
options: {
|
||||
variables: {
|
||||
apiEndpoint: 'http://localhost:4567'
|
||||
apiEndpoint: 'http://192.168.1.37:4567'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -23,52 +23,10 @@ var CartPage = React.createClass({
|
||||
if(!counts) return false;
|
||||
var count = counts[i.get('id')].get('count');
|
||||
return count > 0 || count === "";
|
||||
}).map(function (i) {
|
||||
var count = counts[i.get('id')].get('count');
|
||||
var commission = counts[i.get('id')].get('commission');
|
||||
var price = i.get('list_price');
|
||||
var firstImage = i.get('multi_media_descriptions')[0];
|
||||
firstImage = firstImage || { resized_url: "https://res.cloudinary.com/lfvt7ps2n/image/upload/c_fit,h_172,w_226/v1421732950/http_www.asms.ru_bitrix_templates_main_images_nophoto_irnofq.png" } ;
|
||||
return (
|
||||
<tr key={i.get('id') } className="cart-table-row">
|
||||
<td className='text-center'>
|
||||
<img style={{maxWidth: '90px', maxHeight: '90px'}} src={firstImage.url} alt="product image"/>
|
||||
</td>
|
||||
<td className="cart-price-bigger">
|
||||
<p> {i.get('brand').name}</p>
|
||||
<p>
|
||||
{i.get('name')}
|
||||
</p>
|
||||
</td>
|
||||
<td className="cart-price-bigger text-center">{ Globals.FormatCurrency(price) }
|
||||
<div className="cart-commision-tiny text-center">{ Globals.FormatPercentage(commission) } RUC</div>
|
||||
}); // tableDetails
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<select style={{textAlign: 'center'}} value={count} className="form-control"
|
||||
onChange={self._onQuantityChange.bind(self, i.get('id'))}
|
||||
>
|
||||
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
<option value="5">5</option>
|
||||
<option value="6">6</option>
|
||||
<option value="7">7</option>
|
||||
<option value="8">8</option>
|
||||
<option value="9">9</option>
|
||||
<option value="10">10</option>
|
||||
</select>
|
||||
</td>
|
||||
<td className="cart-price-bigger text-center">
|
||||
{ Globals.FormatCurrency(count * price) }
|
||||
</td>
|
||||
<td>
|
||||
<button className="btn btn-default" onClick={self._onTakeItemOut.bind(self, i.get('id'))}>Ukloni iz korpe</button>
|
||||
</td>
|
||||
</tr>)
|
||||
});
|
||||
var displayedItemsDesktop = displayedItems.map( this.desktopDetails );
|
||||
var displayedItemsMobile = displayedItems.map( this.mobileDetails );
|
||||
|
||||
var deliveryDestination = (<span></span>);
|
||||
|
||||
@@ -89,7 +47,7 @@ var CartPage = React.createClass({
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="col-lg-12 pull-right">
|
||||
<div className="col-lg-12 pull-left">
|
||||
<button className="mybutton" onClick={this._onOrderClick}>Završi narudžbu</button>
|
||||
</div>
|
||||
|
||||
@@ -112,18 +70,19 @@ var CartPage = React.createClass({
|
||||
} else {
|
||||
content = (<div>
|
||||
<table className="table">
|
||||
<thead>
|
||||
<thead className="hidden-md hidden-sm hidden-xs">
|
||||
<tr className="text-center">
|
||||
<th className="col-lg-2"></th>
|
||||
<th>Proizvod</th>
|
||||
<th>Cijena</th>
|
||||
<th className="col-lg-1">Količina</th>
|
||||
<th>Ukupna cijena</th>
|
||||
<th className="hidden-md hidden-sm hidden-xs">Ukupna cijena</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{displayedItems}
|
||||
{displayedItemsMobile}
|
||||
{displayedItemsDesktop}
|
||||
</tbody>
|
||||
</table>
|
||||
{buySomethingMessage}
|
||||
@@ -150,6 +109,99 @@ var CartPage = React.createClass({
|
||||
|
||||
},
|
||||
|
||||
desktopDetails: function (i) {
|
||||
var self = this;
|
||||
var counts = this.state.itemCounts;
|
||||
var count = counts[i.get('id')].get('count');
|
||||
var commission = counts[i.get('id')].get('commission');
|
||||
var price = i.get('list_price');
|
||||
var firstImage = i.get('multi_media_descriptions')[0];
|
||||
firstImage = firstImage || { resized_url: "https://res.cloudinary.com/lfvt7ps2n/image/upload/c_fit,h_172,w_226/v1421732950/http_www.asms.ru_bitrix_templates_main_images_nophoto_irnofq.png" } ;
|
||||
return (
|
||||
<tr key={i.get('id') } className="cart-table-row hidden-md hidden-xs hidden-sm">
|
||||
<td className='text-center'>
|
||||
<img style={{maxWidth: '90px', maxHeight: '90px'}} src={firstImage.url} alt="product image"/>
|
||||
</td>
|
||||
<td className="cart-price-bigger">
|
||||
<p> {i.get('brand').name}</p>
|
||||
<p>
|
||||
{i.get('name')}
|
||||
</p>
|
||||
</td>
|
||||
<td className="cart-price-bigger text-center">{ Globals.FormatCurrency(price) }
|
||||
<div className="cart-commision-tiny text-center">{ Globals.FormatPercentage(commission) } RUC</div>
|
||||
|
||||
</td>
|
||||
<td >
|
||||
<select style={{textAlign: 'center'}} value={count} className="form-control"
|
||||
onChange={self._onQuantityChange.bind(self, i.get('id'))}
|
||||
>
|
||||
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
<option value="5">5</option>
|
||||
<option value="6">6</option>
|
||||
<option value="7">7</option>
|
||||
<option value="8">8</option>
|
||||
<option value="9">9</option>
|
||||
<option value="10">10</option>
|
||||
</select>
|
||||
</td>
|
||||
<td className="cart-price-bigger text-center">
|
||||
{ Globals.FormatCurrency(count * price) }
|
||||
</td>
|
||||
<td>
|
||||
<button className="btn btn-default" onClick={self._onTakeItemOut.bind(self, i.get('id'))}>Ukloni iz korpe</button>
|
||||
</td>
|
||||
</tr>)
|
||||
},
|
||||
|
||||
mobileDetails: function (i) {
|
||||
var self = this;
|
||||
var counts = this.state.itemCounts;
|
||||
var count = counts[i.get('id')].get('count');
|
||||
var commission = counts[i.get('id')].get('commission');
|
||||
var price = i.get('list_price');
|
||||
var firstImage = i.get('multi_media_descriptions')[0];
|
||||
firstImage = firstImage || { resized_url: "https://res.cloudinary.com/lfvt7ps2n/image/upload/c_fit,h_172,w_226/v1421732950/http_www.asms.ru_bitrix_templates_main_images_nophoto_irnofq.png" } ;
|
||||
return (
|
||||
<tr key={i.get('id') } className="cart-table-row hidden-lg">
|
||||
<td className="cart-price-bigger">
|
||||
<p> {i.get('brand').name}</p>
|
||||
<p>
|
||||
{i.get('name')}
|
||||
</p>
|
||||
<p>
|
||||
{ Globals.FormatCurrency(price) }
|
||||
<div className="cart-commision-tiny text-left">{ Globals.FormatPercentage(commission) } RUC</div>
|
||||
|
||||
</p>
|
||||
</td>
|
||||
<td className="col-sm-2 col-xs-2 col-md-2">
|
||||
<select style={{textAlign: 'center'}} value={count}
|
||||
onChange={self._onQuantityChange.bind(self, i.get('id'))}
|
||||
>
|
||||
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
<option value="5">5</option>
|
||||
<option value="6">6</option>
|
||||
<option value="7">7</option>
|
||||
<option value="8">8</option>
|
||||
<option value="9">9</option>
|
||||
<option value="10">10</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<button onClick={self._onTakeItemOut.bind(self, i.get('id'))}>X</button>
|
||||
</td>
|
||||
</tr>)
|
||||
},
|
||||
|
||||
// Add change listeners to stores
|
||||
componentDidMount: function() {
|
||||
CartStore.addChangeListener(this._onChange);
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user