Skip to content

Commit

Permalink
Fixing checkout and bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
kigster committed May 20, 2024
1 parent 5be39f3 commit d269d76
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 66 deletions.
2 changes: 1 addition & 1 deletion app/javascript/init_bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


import "bootstrap/dist/js/bootstrap.bundle.min";
import "bootstrap/dist/js/bootstrap";

import * as bootstrap from "bootstrap";

Expand Down
7 changes: 7 additions & 0 deletions app/javascript/init_popup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import "@popperjs";

import * as popover from "@popperjs/core";

window.popover= popover;


// open a popup
window.popupWindow = function(url, windowName, win, w, h) {
const y = win.top.outerHeight / 2 + win.top.screenY - (h / 2);
Expand Down
2 changes: 1 addition & 1 deletion app/models/ticket_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def total_tickets
end

def guest_count
total_tickets - 1
total_tickets
end

def guests_specified
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
%link{:href => "/icons/android-chrome-192x192.png", :rel => "shortcut icon", :type => "image/png"}/
%link{:href => "https://fonts.googleapis.com", :rel => "preconnect"}/
%link{:href => "https://fonts.googleapis.com/css2?family=Dosis:[email protected]&family=Oswald:[email protected]&display=swap", :rel => "stylesheet"}/
%script{src: "https://js.stripe.com/v3/", crossorigin: "anonymous"}
%script{src: "https://js.stripe.com/v3/", crossorigin: "anonymous", async: true}

%title
- if content_for?(:title)
Expand Down
57 changes: 41 additions & 16 deletions app/views/payments/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,50 @@

- if @event.tickets_require_approval
.card-body.bg-success-subtle
%p.lead
Your request for
%strong
= @ticket_request.adults
= 'ticket'.pluralize(@ticket_request.total_tickets)
has been approved!
%table.w-100
%thead
%tr
%th
Your request for
%strong
= @ticket_request.adults
= 'ticket'.pluralize(@ticket_request.total_tickets)
has been approved!

%td.text-end.small.p-2.px-4.text-nowrap= "Total Ticket Price:"
%td
%strong
%span{ class: ('label label-info' if @ticket_request.special_price) }
= number_to_currency(@ticket_request.price, precision: 0)
%p
%tbody
%tr
%td.w-100{colspan: 2}
%hr.w-100
%tr
%td= "Total Price for Tickets:"
%td.text-end
%strong
%span{ class: ('label label-info' if @ticket_request.special_price) }
= number_to_currency(@ticket_request.price, precision: 0)

- if @ticket_request.donation&.positive?
%tr
%td= "Additional Donation:"
%td.text-end
%strong
= number_to_currency(@ticket_request.donation, precision: 0)

%tbody
%tr
%td.w-100{colspan: 2}
%hr.w-100

%tr
%td= "Total Amount"
%td.text-end
%strong
= number_to_currency(@ticket_request.cost, precision: 0)


.card-footer.bg-body-secondary
%p
Now all that's left is to pay for your tickets.
If you are paying via credit card, please fill out the form ➜

.card-footer.bg-body-secondary
%strong
= link_to 'I am not paying via credit card',
other_event_ticket_request_payment_path(@event, @ticket_request)
Expand All @@ -46,8 +71,8 @@
.card-header.bg-body-secondary
%h5 Please Enter Your Payment Details
%strong
Total Ticket Price:
= number_to_currency(@ticket_request.price, precision: 0)
Total Amount Due:
= number_to_currency(@ticket_request.cost, precision: 0)
%p

.card-body
Expand Down
8 changes: 4 additions & 4 deletions app/views/ticket_requests/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
%li John Digweed <[email protected]>
- total_guests = @ticket_request.guest_count
- adult_guests = @ticket_request.adults - 1
- adult_guests = @ticket_request.adults
- adult_guests.times do |guest_id|
- next if @ticket_request.guests[guest_id] == "#{@ticket_request.user.name} <#{@ticket_request.user.email}>"
- default_value = guest_id == 0 ? @ticket_request.user.name_and_email : ''
= f.label "Adult Guest #{guest_id + 1}"
= f.text_field :guest_list, readonly: list_finalized, multiple: true, value: Array(@ticket_request.guests[0...adult_guests])[guest_id], style: 'width: 80%'
= f.text_field :guest_list, readonly: list_finalized, multiple: true, value: Array(@ticket_request.guests[0...adult_guests])[guest_id] || default_value, style: 'width: 80%'

- if @ticket_request.kids.positive?
.col-lg-6.col-xl-6.col-md-12.col-sm-12
Expand All @@ -74,7 +74,7 @@
- kid_guests = @ticket_request.kids
- kid_guests.times do |guest_id|
= f.label "Kid Guest #{guest_id + 1}"
= f.text_field :guest_list, readonly: list_finalized, multiple: true, value: Array(@ticket_request.guests[(adult_guests)...total_guests])[guest_id], style: 'width: 80%'
= f.text_field :guest_list, readonly: list_finalized, multiple: true, value: Array(@ticket_request.guests[(adult_guests)..total_guests])[guest_id], style: 'width: 80%'

%hr
%h4 How are you contributing to the event?
Expand Down
87 changes: 44 additions & 43 deletions app/views/ticket_requests/_ticket_request_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
%span.p-2.rounded{ class: text_class_for_status(ticket_request) }
= ticket_request.status_name

%tr
%td.text-end.small.p-2.px-4.text-nowrap= "Total Tickets Price:"
%td
%strong
%span{ class: ('label label-info' if ticket_request.special_price) }
= number_to_currency(ticket_request.price, precision: 0)
- if ticket_request.can_purchase?
%tr
%td.text-end.small.p-2.px-4.text-nowrap= "Total Tickets Price:"
%td
%strong
%span{ class: ('label label-info' if ticket_request.special_price) }
= number_to_currency(ticket_request.price, precision: 0)

- if ticket_request.donation&.positive?
%tr
Expand All @@ -30,46 +31,46 @@
%strong
= number_to_currency(ticket_request.donation, precision: 0)

%tr
%td.text-end.small.p-2.px-4.text-nowrap= "Payment:"
%td
%strong
- if ticket_request.payment_received?
- if ticket_request.refunded?
%span.bg-success Refunded
- else
.text-success
= link_to 'Received', event_ticket_request_payment_path(payment, ticket_request)

- if event.admin?(current_user)
= link_to 'Refund', refund_event_ticket_request_path(event, ticket_request),
method: :post,
class: 'btn btn-sm btn-danger',
data: { confirm: "Are you sure you want to refund #{ticket_request.user.name}'s ticket? This cannot be undone!",
disable_with: 'Refunding...' }
- elsif ticket_request.free?
.text-success
Free
%tr
%td.text-end.small.p-2.px-4.text-nowrap= "Payment:"
%td
%strong
- if ticket_request.payment_received?
- if ticket_request.refunded?
%span.bg-success Refunded
- else
- if event.ticket_sales_open?
- if ticket_request.payment.present? && ticket_request.payment.explanation.present?
%span.bg-warning Paying with #{ticket_request.payment.explanation}
.text-success
= link_to 'Received', event_ticket_request_payment_path(payment, ticket_request)

- if event.admin?(current_user)
= link_to 'Refund', refund_event_ticket_request_path(event, ticket_request),
method: :post,
class: 'btn btn-sm btn-danger',
data: { confirm: "Are you sure you want to refund #{ticket_request.user.name}'s ticket? This cannot be undone!",
disable_with: 'Refunding...' }
- elsif ticket_request.free?
.text-success
Free
- else
- if event.ticket_sales_open?
- if ticket_request.payment.present? && ticket_request.payment.explanation.present?
%span.bg-warning Paying with #{ticket_request.payment.explanation}
- else
- if ticket_request.all_guests_specified?
= link_to 'Purchase your ticket now',
new_event_ticket_request_payment_path(event, ticket_request),
class: 'btn btn-primary m-0'
- else
- if ticket_request.all_guests_specified?
= link_to 'Purchase your ticket now',
new_event_ticket_request_payment_path(event, ticket_request),
class: 'btn btn-primary m-0'
- else
.small
You must register all of your guests before you can pay for your ticket.
= link_to edit_event_ticket_request_path(event, ticket_request), class: 'btn btn-primary btn-round btn-sm mx-0' do
= event.admin?(current_user) ? 'Add Their Guests' : 'Add My Guests'
.small
You must register all of your guests before you can pay for your ticket.
= link_to edit_event_ticket_request_path(event, ticket_request), class: 'btn btn-primary btn-round btn-sm mx-0' do
= event.admin?(current_user) ? 'Add Their Guests' : 'Add My Guests'

- else
%span.bg-warning
Unfortunately, ticket sales are now closed. You can no longer purchase your
= succeed '.' do
= 'ticket'.pluralize(ticket_request.total_tickets)
- else
%span.bg-warning
Unfortunately, ticket sales are now closed. You can no longer purchase your
= succeed '.' do
= 'ticket'.pluralize(ticket_request.total_tickets)

%tr
%td.text-end.small.p-2.px-4.text-nowrap= "Email:"
Expand Down

0 comments on commit d269d76

Please sign in to comment.