From c345e9f016ad9a5b9cbc8384433fb9e25899c271 Mon Sep 17 00:00:00 2001 From: "adam.harbas@a-net.ba" Date: Mon, 11 Jan 2016 10:52:18 +0100 Subject: [PATCH] Last used btn --- back-office/app/models/delivery_destination.rb | 2 +- front-api/controllers/cart.rb | 4 ++-- front-api/db/schema.rb | 4 ++-- front-api/models/delivery_destination.rb | 3 ++- front-ui/app/components/cart/checkoutPage.js | 8 +++++--- front-ui/app/css/checkout.css | 4 ++++ 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/back-office/app/models/delivery_destination.rb b/back-office/app/models/delivery_destination.rb index 0ba1066..8fa2e38 100644 --- a/back-office/app/models/delivery_destination.rb +++ b/back-office/app/models/delivery_destination.rb @@ -2,7 +2,7 @@ class DeliveryDestination < ActiveRecord::Base def get_payment_string case self.payment_method when 'cash_on_delivery' - 'Pouzecem' + 'Prilikom preuzimanja' when 'paypal' 'Paypal' when 'pikpay' diff --git a/front-api/controllers/cart.rb b/front-api/controllers/cart.rb index 2bb0207..0883f55 100644 --- a/front-api/controllers/cart.rb +++ b/front-api/controllers/cart.rb @@ -44,7 +44,7 @@ end update_delivery_destination = ->() { cart = Cart.just_find(anonymous_id, logged_in_user_id) - allowed_keys = ["name", "address", "place", "postal_code", "phone", "email", "note"] + allowed_keys = ["name", "address", "place", "postal_code", "phone", "email", "note", "payment_method"] params = @json_params.reject { |key,_| !allowed_keys.include?(key) } cart.delivery_destination.update_attributes(params) cart.delivery_destination.save! @@ -129,7 +129,7 @@ get '/pikpay/confirmation' do user = params["user_id"] user ||= -1 user = user.to_i - + cart = Cart.just_find(anonymous, user) if cart.item_in_carts.length > 0 cart.ordered = true diff --git a/front-api/db/schema.rb b/front-api/db/schema.rb index f5633fb..0db9c5d 100644 --- a/front-api/db/schema.rb +++ b/front-api/db/schema.rb @@ -62,8 +62,8 @@ ActiveRecord::Schema.define(version: 20160111024541) do t.boolean "phone_verified" t.string "phone_verification_code" t.string "email_verification_code" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "user_id" t.string "anonymous_id_string" t.boolean "instant_delivery", default: false diff --git a/front-api/models/delivery_destination.rb b/front-api/models/delivery_destination.rb index 8237eaa..e42c60c 100644 --- a/front-api/models/delivery_destination.rb +++ b/front-api/models/delivery_destination.rb @@ -6,6 +6,7 @@ class DeliveryDestination < ActiveRecord::Base dd = DeliveryDestination.where(["user_id is not null and user_id = ?", user_id]).order("id desc").first dd ||= DeliveryDestination.where(["anonymous_id_string is not null and anonymous_id_string = ?", anonymous_id]).order("id desc").first dd ||= DeliveryDestination.new({user_id: user_id, anonymous_id_string: anonymous_id }) + dd.payment_method ||= "cash_on_delivery" attributes = dd.as_json attributes.delete("id") result = DeliveryDestination.create!(attributes) @@ -15,7 +16,7 @@ class DeliveryDestination < ActiveRecord::Base def get_payment_string case self.payment_method when 'cash_on_delivery' - 'Pouzecem' + 'Prilikom preuzimanja' when 'paypal' 'Paypal' when 'pikpay' diff --git a/front-ui/app/components/cart/checkoutPage.js b/front-ui/app/components/cart/checkoutPage.js index fe35df8..b69b63c 100644 --- a/front-ui/app/components/cart/checkoutPage.js +++ b/front-ui/app/components/cart/checkoutPage.js @@ -10,6 +10,7 @@ var React = require('react'), PaymentSelect = require('../payment/paymentSelect'), RibicaFormError = require('../shared/ribicaFormError'), PaypalButton = require('../payment/paypalButton'), + PikpayButton = require('../payment/pikpayButton'), CashOnDeliveryButton = require('../payment/cashOnDeliveryButton'); var Router = require('react-router'); @@ -34,10 +35,10 @@ var CheckoutPage = React.createClass({ ); } else if(this.state.deliveryDestination.get('payment_method') == 'pikpay') { - + } else { last_used_payment = ( - + ); } @@ -138,7 +139,7 @@ var CheckoutPage = React.createClass({ Ukupno:

-

{last_used_payment} ili +

{last_used_payment} ili

@@ -176,6 +177,7 @@ var CheckoutPage = React.createClass({ }, _onOrderClick: function (event) { + CartActions.changeDeliveryDestinationProperty("payment_method", "cash_on_delivery"); CartActions.confirmDelivery(); }, diff --git a/front-ui/app/css/checkout.css b/front-ui/app/css/checkout.css index b8e9e90..1093a21 100644 --- a/front-ui/app/css/checkout.css +++ b/front-ui/app/css/checkout.css @@ -14,3 +14,7 @@ .payment-select-mobile .payment-btn { margin-bottom: 6px !important; } + +.collapsed_address_container .mybutton { + margin-top: 0px !important; +}