From 2aa0dc8df1feaf63ea28f9999e3fa06e006cdd9b Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Fri, 18 Oct 2019 19:38:57 -0500 Subject: [PATCH] billing page redesign --- app/controllers/subscriptions_controller.rb | 13 ++ app/views/subscriptions/manage.html.erb | 240 ++++++++++++++++++++ config/routes.rb | 3 +- 3 files changed, 255 insertions(+), 1 deletion(-) create mode 100644 app/views/subscriptions/manage.html.erb diff --git a/app/controllers/subscriptions_controller.rb b/app/controllers/subscriptions_controller.rb index 6bbb42a3..d8c23b67 100644 --- a/app/controllers/subscriptions_controller.rb +++ b/app/controllers/subscriptions_controller.rb @@ -20,6 +20,19 @@ class SubscriptionsController < ApplicationController @stripe_invoices = @stripe_customer.invoices # makes a second call to Stripe end + # this endpoint replaces the #new endpoint above; it's separated out for development/testing, as well as the ability + # to quickly flip back to the original unchanged endpoint if there are any issues post-release + def manage + @sidenav_expansion = 'my account' + + @active_billing_plans = current_user.active_billing_plans + @active_billing_plans = [BillingPlan.find_by(stripe_plan_id: 'starter')] if @active_billing_plans.empty? + + @storage_used = Filesize.from("#{current_user.image_uploads.sum(:src_file_size)}B") + @storage_remaining = Filesize.from("#{current_user.upload_bandwidth_kb.abs}KB") + @storage_capacity = @storage_used + @storage_remaining + end + def show end diff --git a/app/views/subscriptions/manage.html.erb b/app/views/subscriptions/manage.html.erb new file mode 100644 index 00000000..0dd1a22a --- /dev/null +++ b/app/views/subscriptions/manage.html.erb @@ -0,0 +1,240 @@ +<% + free_for_life_user = current_user.selected_billing_plan_id == 2 + on_premium_plan = current_user.on_premium_plan? + active_stripe_plan = @active_billing_plans.first.try(:stripe_plan_id) +%> + +
+
+

+ Notebook.ai subscriptions +

+
+
+ +
+
+
Your current plan
+
+
+ +
+
+ $0/month +
+ class + Notebook.ai Starter +
+
+
+
+
+
    +
  • + check + Plan up to 5 universes +
  • +
  • + check + Upload 50MB of images +
  • +
  • + check + Create basic page types +
  • +
+
+
+

+ Unlocked pages +

+ + <%= Universe.icon %> + + <% (Rails.application.config.content_types[:free]).each do |content_class| %> + <% next if content_class.name == "Universe" %> + + <%= content_class.icon %> + + <% end %> +
+
+
+
+

+ Payment +

+

+ <%= link_to 'BILLING HISTORY', '#', class: 'right' %> + Your next bill for $9.99 is due on 10/23/19. +

+
+

+ credit_card + Visa ending in 1234 (expires 01/2020). + <%= link_to 'UPDATE CARD', '#', class: 'right' %> +

+
+
+
+
+ +
+
+
Other plans available
+
+
+ +
+
+ $9/month +
+ star + Notebook.ai Premium +
+
+
+
+
+
    +
  • + arrow_upward + Plan unlimited universes +
  • +
  • + arrow_upward + Upload 10GB of images +
  • +
  • + arrow_upward + Create all <%= Rails.application.config.content_types[:all].count %> page types +
  • +
  • + arrow_upward + Analyze your writing with AI +
  • +
+
+
+

+ Unlocked pages +

+ <% Rails.application.config.content_types[:all].each_with_index do |content_class, i| %> + + <%= content_class.icon %> + + <% end %> +
+
+
+
+ <%= link_to 'Upgrade to this plan', change_subscription_path('premium'), class: "btn-large waves-effect waves-light blue white-text hoverable left", style: "margin-right: 20px" %> +
+
+

+ The standard Premium membership is $9 per month. However, you can save more by choosing to prepay every three months or per year. +

+
+
+
+
+
+
+ +
+
+
+
+
+ cloud_upload + Upload Bandwidth +
+ <%= (current_user.upload_bandwidth_kb) > 0 ? Filesize.from("#{current_user.upload_bandwidth_kb}KB").pretty : '-' + Filesize.from("#{current_user.upload_bandwidth_kb.abs}KB").pretty %> remaining +
+
+

+ You've used <%= @storage_used.pretty %> from <%= current_user.image_uploads.count %> uploads, + with <%= (current_user.upload_bandwidth_kb > 0 ? @storage_remaining : '-' + @storage_remaining).pretty %> + of bandwidth remaining. +

+
+ <% if @storage_used > 0 %> +
+
+
+ <% end %> +

+ This bandwidth can be used to upload images to your notebook pages. Deleting an uploaded image frees + up the same amount of bandwidth. + <% unless on_premium_plan %> + To get more bandwidth, upgrade to our Premium plan. + <% end %> +

+
+
+ <%= link_to 'Purchase more', '#', class: 'blue-text' %> + <%= link_to 'Earn more', '#', class: 'right blue-text' %> +
+
+
+ +
+
+
+ +
+ redeem + Have a promotional code to redeem? +
+

+ Enter the code below to apply it to your account. +

+ + <%= form_for :promotional_code, url: redeem_path do |form| %> +
+ <%= form.text_field :promo_code %> + +
+ +
+ <%= form.submit 'Redeem code', class: 'white black-text btn' %> +
+ <% end %> +
+ + <% if current_user.active_promotions.any? %> +

+ Your active promo codes: + +

    + <% current_user.active_promo_codes.each do |promo_code| %> + <% promotion = Promotion.find_by(user: current_user, page_unlock_promo_code_id: promo_code.id) %> +
  • +

    + <%= promo_code.code %> - <%= promo_code.description %> + + (active for another <%= distance_of_time_in_words(DateTime.current, promotion.expires_at) %>) + +

    +

    + Pages unlocked: + <% promo_code.page_types.each do |page_type| %> + <% page_type_class = page_type.constantize %> + <%= link_to polymorphic_path(page_type_class) do %> + + <%= page_type_class.icon %> + + <% end %> + <% end %> +

    +
  • + <% end %> +
+ + <%= link_to 'Click here to turn on your new page types!', customization_content_types_path, class: 'btn blue white-text' %> +

+ <% end %> +
+
+
+
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index e5b2dc19..635c59fd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -39,8 +39,9 @@ Rails.application.routes.draw do # Billing scope '/billing' do - #get '/', to: 'subscriptions#show', as: :billing + #get '/', to: 'subscriptions#show', as: :billing get '/subscription', to: 'subscriptions#new', as: :subscription + get '/manage', to: 'subscriptions#manage' get '/to/:stripe_plan_id', to: 'subscriptions#change', as: :change_subscription