SOlved conflict
This commit is contained in:
@@ -52,6 +52,7 @@ end
|
|||||||
put '/cart/delivery_destination', &update_delivery_destination
|
put '/cart/delivery_destination', &update_delivery_destination
|
||||||
post '/cart/delivery_destination', &update_delivery_destination
|
post '/cart/delivery_destination', &update_delivery_destination
|
||||||
|
|
||||||
|
|
||||||
def report_to_trello(cart)
|
def report_to_trello(cart)
|
||||||
Thread.new do
|
Thread.new do
|
||||||
@cart = cart
|
@cart = cart
|
||||||
@@ -66,6 +67,22 @@ def report_to_trello(cart)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
update_delivery_destination = ->() {
|
||||||
|
cart = Cart.just_find(anonymous_id, logged_in_user_id)
|
||||||
|
allowed_keys = ["name", "address", "place", "postal_code", "phone", "email", "note", "payment_method", "gift",
|
||||||
|
"recipient_name", "recipient_address", "recipient_place", "recipient_postal_code", "recipient_phone", "recipient_email"]
|
||||||
|
|
||||||
|
params = @json_params.reject { |key,_| !allowed_keys.include?(key) }
|
||||||
|
cart.delivery_destination.update_attributes(params)
|
||||||
|
cart.delivery_destination.save!
|
||||||
|
|
||||||
|
report_to_trello(cart)
|
||||||
|
|
||||||
|
cart.delivery_destination.to_json(:except => [:created_at, :email_verification_code, :phone_verification_code])
|
||||||
|
}
|
||||||
|
put '/cart/delivery_destination', &update_delivery_destination
|
||||||
|
post '/cart/delivery_destination', &update_delivery_destination
|
||||||
|
|
||||||
def send_order_email(cart)
|
def send_order_email(cart)
|
||||||
Thread.new do
|
Thread.new do
|
||||||
client = SendGrid::Client.new(
|
client = SendGrid::Client.new(
|
||||||
@@ -91,13 +108,11 @@ post '/cart/confirmation' do
|
|||||||
cart.ordered = true
|
cart.ordered = true
|
||||||
cart.save!
|
cart.save!
|
||||||
end
|
end
|
||||||
|
report_to_trello(cart)
|
||||||
|
send_order_email(cart)
|
||||||
# since there is no more ordered cart this needs to be done
|
# since there is no more ordered cart this needs to be done
|
||||||
# in order for next call of Cart#just_find to be ready
|
# in order for next call of Cart#just_find to be ready
|
||||||
Cart.find_or_create(anonymous, logged_in_user_id)
|
Cart.find_or_create(anonymous, logged_in_user_id)
|
||||||
|
|
||||||
report_to_trello(cart)
|
|
||||||
send_order_email(cart)
|
|
||||||
|
|
||||||
'OK'.to_json
|
'OK'.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ Bosna i Hercegovina
|
|||||||
|
|
||||||
**Naručeno:** <%= @cart.updated_at.in_time_zone("Europe/Sarajevo").strftime("%A %d.%m.%Y. %H:%M") %>
|
**Naručeno:** <%= @cart.updated_at.in_time_zone("Europe/Sarajevo").strftime("%A %d.%m.%Y. %H:%M") %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
<% if dd.instant_delivery %>
|
<% if dd.instant_delivery %>
|
||||||
** OVO JE NARUDŽBA ZA INSTANT DOSTAVU **
|
** OVO JE NARUDŽBA ZA INSTANT DOSTAVU **
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ var CheckoutPage = React.createClass({
|
|||||||
disabled={!this.state.isDeliveryDestinationValid}
|
disabled={!this.state.isDeliveryDestinationValid}
|
||||||
cashOnDeliveryDisabled={!this.state.isDeliveryDestinationValid || this.state.deliveryDestination.get('gift')}
|
cashOnDeliveryDisabled={!this.state.isDeliveryDestinationValid || this.state.deliveryDestination.get('gift')}
|
||||||
onCashClick={this._onOrderClick}
|
onCashClick={this._onOrderClick}
|
||||||
cartId={this.state.cart.get('id')}
|
cartId={this.state.deliveryDestination.get('id')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -34,15 +34,15 @@ var CheckoutPage = React.createClass({
|
|||||||
var last_used_payment;
|
var last_used_payment;
|
||||||
if(this.state.deliveryDestination.get('payment_method') == 'paypal') {
|
if(this.state.deliveryDestination.get('payment_method') == 'paypal') {
|
||||||
last_used_payment = (
|
last_used_payment = (
|
||||||
<PaypalButton disabled={!this.state.isDeliveryDestinationValid} onSubmitPaypal={this._handleOnSubmitPaypal} deliveryDestination={this.state.deliveryDestination} amount={CartStore.getAmount()} deliveryCost={CartStore.getDeliveryCost(false)} cartId={this.state.cart.get('id')}/>
|
<PaypalButton disabled={!this.state.isDeliveryDestinationValid} onSubmitPaypal={this._handleOnSubmitPaypal} deliveryDestination={this.state.deliveryDestination} amount={CartStore.getAmount()} deliveryCost={CartStore.getDeliveryCost(false)} cartId={this.state.deliveryDestination.get('id')}/>
|
||||||
);
|
);
|
||||||
} else if(this.state.deliveryDestination.get('payment_method') == 'pikpay') {
|
} else if(this.state.deliveryDestination.get('payment_method') == 'pikpay') {
|
||||||
last_used_payment = (
|
last_used_payment = (
|
||||||
<PikpayButton amount={CartStore.getAmount()} deliveryCost={CartStore.getDeliveryCost(false)} disabled={!this.state.isDeliveryDestinationValid} deliveryDestination={this.state.deliveryDestination} cartId={this.state.cart.get('id')}/>
|
<PikpayButton amount={CartStore.getAmount()} deliveryCost={CartStore.getDeliveryCost(false)} disabled={!this.state.isDeliveryDestinationValid} deliveryDestination={this.state.deliveryDestination} cartId={this.state.deliveryDestination.get('id')}/>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
last_used_payment = (
|
last_used_payment = (
|
||||||
<CashOnDeliveryButton onCashClick={this._onOrderClick} disabled={!this.state.isDeliveryDestinationValid || this.state.deliveryDestination.get('gift')} cartId={this.state.cart.get('id')}/>
|
<CashOnDeliveryButton onCashClick={this._onOrderClick} disabled={!this.state.isDeliveryDestinationValid || this.state.deliveryDestination.get('gift')} cartId={this.state.deliveryDestination.get('id')}/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ var DeliveryDestination = require('../models/deliveryDestination');
|
|||||||
var OrderConfirmation = require('../models/orderConfirmation');
|
var OrderConfirmation = require('../models/orderConfirmation');
|
||||||
var Place = require('../models/place');
|
var Place = require('../models/place');
|
||||||
var Validation = require('../utils/validation');
|
var Validation = require('../utils/validation');
|
||||||
var Cart = require('../models/cart');
|
|
||||||
|
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
|
|
||||||
@@ -26,8 +25,6 @@ var _deliveryCosts = new Place({
|
|||||||
postalCode: _deliveryDestination.get('place')
|
postalCode: _deliveryDestination.get('place')
|
||||||
});
|
});
|
||||||
|
|
||||||
var _cart = new Cart();
|
|
||||||
|
|
||||||
var _addressColapsed = false;
|
var _addressColapsed = false;
|
||||||
|
|
||||||
var supportedPlaces = [{
|
var supportedPlaces = [{
|
||||||
@@ -2571,7 +2568,6 @@ var nameOfThePlace = function(code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var loadCart = function() {
|
var loadCart = function() {
|
||||||
_cart.fetch({success: function() {
|
|
||||||
_itemsInCart.fetch({
|
_itemsInCart.fetch({
|
||||||
success: function() {
|
success: function() {
|
||||||
states = {}
|
states = {}
|
||||||
@@ -2595,7 +2591,6 @@ var loadCart = function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}});
|
|
||||||
|
|
||||||
_cartDataLoadCalled = true;
|
_cartDataLoadCalled = true;
|
||||||
};
|
};
|
||||||
@@ -2880,8 +2875,7 @@ var CartStore = _.extend({}, EventEmitter.prototype, {
|
|||||||
deliveryCosts: _deliveryCosts,
|
deliveryCosts: _deliveryCosts,
|
||||||
destinationValid: isDeliveryDestinationValid(),
|
destinationValid: isDeliveryDestinationValid(),
|
||||||
address_colapsed: _addressColapsed,
|
address_colapsed: _addressColapsed,
|
||||||
deliveryCostsTarget: getDeliveryCostTarget(),
|
deliveryCostsTarget: getDeliveryCostTarget()
|
||||||
cart: _cart
|
|
||||||
};
|
};
|
||||||
return state;
|
return state;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user