Skip to content

Commit

Permalink
Fix sumup on iPadOS (#762)
Browse files Browse the repository at this point in the history
* Fix sumup on ipados

* Fix linting errors
  • Loading branch information
wilco375 authored Aug 24, 2022
1 parent 100d6dc commit 3fe0727
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 2 additions & 3 deletions app/controllers/activities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def show # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
@count_per_product = @activity.count_per_product
end

def order_screen # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def order_screen # rubocop:disable Metrics/MethodLength
authorize Activity

@activity = Activity.includes([:price_list, { price_list: { product_price: :product } }])
Expand All @@ -98,9 +98,8 @@ def order_screen # rubocop:disable Metrics/AbcSize, Metrics/MethodLength

@activity_json = @activity.to_json(only: %i[id title start_time end_time])

is_mobile = Browser.new(request.user_agent).mobile?
@sumup_key = Rails.application.config.x.sumup_key
@sumup_enabled = (is_mobile && @sumup_key.present?) || false
@sumup_enabled = @sumup_key.present?

# Set flags for application.html.slim
@show_navigationbar = false
Expand Down
5 changes: 5 additions & 0 deletions app/javascript/packs/order_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ document.addEventListener('turbolinks:load', () => {
let callback = element.dataset.sumupCallback;
return `sumupmerchant://pay/1.0?affiliate-key=${affilateKey}&total=${this.orderTotal}&currency=EUR&title=Bestelling SOFIA&callback=${callback}`;
},

isMobile() {
return /Android|webOS|iPhone|iPad|iPod|Opera Mini/i.test(navigator.userAgent) || // Android / iOS
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1); // iPadOS
}
},

// Listen to escape button which are dispatched on the body content_tag
Expand Down
4 changes: 2 additions & 2 deletions app/views/activities/order_screen.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
</div>
</div>
<div class="orders-confirmation">
<div class="btn-group btn-group-lg btn-block" role="group" v-if="payWithPin && <%= @sumup_enabled.to_s %>">
<div class="btn-group btn-group-lg btn-block" role="group" v-if="payWithPin && <%= @sumup_enabled.to_s %> && isMobile">
<a role="button" class="btn btn-success col-9"
@click="confirmOrder"
:class="{ 'disabled': orderConfirmButtonDisabled }"
Expand All @@ -200,7 +200,7 @@
<button @click="maybeConfirmOrder" class="btn btn-block btn-lg btn-success"
:class="{ 'btn-warning' : showOrderWarning }"
:disabled="orderConfirmButtonDisabled"
v-if="!payWithPin || !<%= @sumup_enabled.to_s %>">
v-if="!payWithPin || !<%= @sumup_enabled.to_s %> || !isMobile">
<span class="text-uppercase">
Bestelling plaatsen
</span>
Expand Down

0 comments on commit 3fe0727

Please sign in to comment.