Skip to content

Commit

Permalink
feature: show discount code usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinW520 committed Aug 6, 2019
1 parent 3843ce8 commit 9b37469
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
6 changes: 6 additions & 0 deletions app/views/admin/discount_codes/_card.html.haml
@@ -0,0 +1,6 @@
.row
.col-12
.card
.card-header Usage
.card-body
= bar_chart Registration.where(id: discount_code.registrations.pluck(:id)).joins(:participant).group('participants.email').count
4 changes: 4 additions & 0 deletions app/views/admin/discount_codes/_discount_code.html.haml
Expand Up @@ -10,6 +10,10 @@
class: "btn btn-sm btn-outline-primary" do
%i.fa.fa-edit
Edit
= link_to admin_discount_code_path(discount_code),
class: "btn btn-sm btn-outline-tertiary" do
%i.fa.fa-eye
Show
- unless discount_code.used?
= link_to admin_discount_code_path(discount_code),
method: :delete,
Expand Down
14 changes: 8 additions & 6 deletions app/views/admin/discount_codes/index.html.haml
@@ -1,11 +1,13 @@
= content_for :admin_area_title do
Discount Codes
= link_to new_admin_discount_code_path, class: "ml-4 btn btn-sm btn-success" do
%i.fa.fa-plus
New
.row
.col
.card
.card-header
Usage Summary
= column_chart Registration.joins(:discount_code).group('discount_codes.code').count

= render "table"
.row.mt-3
.col-12
.float-right
= link_to new_admin_discount_code_path, class: "btn btn-sm btn-success" do
%i.fa.fa-plus
Create New Discount Code
11 changes: 10 additions & 1 deletion app/views/admin/discount_codes/show.html.haml
@@ -1 +1,10 @@
= render "admin/registrations/card", registration: @registration.decorate
= content_for :admin_area_title do
Discount Code ##{@discount_code.id}
%nav{"aria-label" => "breadcrumb"}
%ol.breadcrumb
%li.breadcrumb-item
%a{href: admin_discount_codes_path} Discount Codes
%li.breadcrumb-item.active{"aria-current" => "page"} ##{@discount_code.id}
.row
.col-12
= render "card", discount_code: @discount_code

0 comments on commit 9b37469

Please sign in to comment.