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) +%> + +
+ 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' %> +
++ Unlocked pages +
+ <% Rails.application.config.content_types[:all].each_with_index do |content_class, i| %> + + <%= content_class.icon %> + + <% end %> ++ The standard Premium membership is $9 per month. However, you can save more by choosing to prepay every three months or per year. +
++ 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. +
++ 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 %> +
++ Enter the code below to apply it to your account. +
+ + <%= form_for :promotional_code, url: redeem_path do |form| %> ++ Your active promo codes: + +
+ <%= 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 %> +
+