mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
wip: downgrade to student if they are a collab monthly
This commit is contained in:
parent
5c05d02840
commit
8fb1f9e00b
2 changed files with 55 additions and 15 deletions
|
@ -6,7 +6,7 @@ block scripts
|
|||
window.recomendedCurrency = '#{recomendedCurrency}'
|
||||
window.recurlyApiKey = "!{settings.apis.recurly.publicKey}"
|
||||
window.taxRate = #{taxRate}
|
||||
|
||||
window.subscription = !{JSON.stringify(subscription)}
|
||||
|
||||
|
||||
|
||||
|
@ -36,11 +36,11 @@ mixin printPlans(plans)
|
|||
mixin printPlan(plan)
|
||||
|
||||
block content
|
||||
.content.content-alt
|
||||
.container
|
||||
.content.content-alt(ng-cloak)
|
||||
.container(ng-controller="UserSubscriptionController")
|
||||
.row
|
||||
.col-md-8.col-md-offset-2
|
||||
.card
|
||||
.col-md-8.col-md-offset-2 {{view}}
|
||||
.card(ng-if="view == 'overview'")
|
||||
.page-header
|
||||
h1 #{translate("your_subscription")}
|
||||
-if (groups.length != 0)
|
||||
|
@ -56,12 +56,10 @@ block content
|
|||
a(href, ng-click="changePlan = true") !{translate("change_plan")}.
|
||||
p !{translate("next_payment_of_x_collectected_on_y", {paymentAmmount:"<strong>" + subscription.price + "</strong>", collectionDate:"<strong>" + subscription.nextPaymentDueAt + "</strong>"})}
|
||||
p.pull-right
|
||||
|
||||
p: form(action="/user/subscription/cancel",method="post")
|
||||
input(type="hidden", name="_csrf", value=csrfToken)
|
||||
p
|
||||
a(href="/user/subscription/billing-details/edit").btn.btn-info #{translate("update_your_billing_details")}
|
||||
|
|
||||
input(type="submit", value="Cancel your subscription").btn.btn-primary#cancelSubscription
|
||||
p
|
||||
a(href, ng-click="switchToCancelationView()").btn.btn-success !{translate("cancel_your_subscription")}
|
||||
when "canceled"
|
||||
p !{translate("currently_subscribed_to_plan", {planName:"<strong>" + subscription.name + "</strong>"})}
|
||||
p !{translate("subscription_canceled_and_terminate_on_x", {terminateDate:"<strong>" + subscription.nextPaymentDueAt + "</strong>"})}
|
||||
|
@ -76,7 +74,7 @@ block content
|
|||
p !{translate("problem_with_subscription_contact_us")}
|
||||
|
||||
-if(subscription.groupPlan)
|
||||
a(href="/subscription/group").btn.btn-success !{translate("manage_group")}
|
||||
a(href="/subscription/group").btn.btn-primary !{translate("manage_group")}
|
||||
|
||||
|
||||
|
||||
|
@ -107,6 +105,17 @@ block content
|
|||
|
||||
|
||||
|
||||
.card(ng-if="view == 'cancelation'")
|
||||
.page-header
|
||||
h1 #{translate("Cancel Subscription")}
|
||||
div(ng-show="isMonthlyCollab")
|
||||
span(ng-controller="ChangePlanFormController") downgrade to student for {{studentPrice}}
|
||||
button(type="submit", ng-click="downgradeToStudent()", ng-disabled='inflight').btn.btn-success #{translate("change_to_this_plan")}
|
||||
|
||||
div(ng-if="!isMonthlyCollab")
|
||||
form(action="/user/subscription/cancel",method="post")
|
||||
input(type="hidden", name="_csrf", value=csrfToken)
|
||||
input(type="submit", value="Cancel your subscription").btn.btn-primary#cancelSubscription
|
||||
script(type="text/javascript").
|
||||
$('#cancelSubscription').on("click", function() {
|
||||
ga('send', 'event', 'subscription-funnel', 'cancelation')
|
||||
|
|
|
@ -5,7 +5,7 @@ define [
|
|||
|
||||
setupReturly = _.once ->
|
||||
recurly?.configure window.recurlyApiKey
|
||||
|
||||
PRICES = {}
|
||||
|
||||
App.controller "CurrenyDropdownController", ($scope, MultiCurrencyPricing, $q)->
|
||||
|
||||
|
@ -18,7 +18,7 @@ define [
|
|||
|
||||
App.controller "ChangePlanFormController", ($scope, $modal, MultiCurrencyPricing)->
|
||||
setupReturly()
|
||||
|
||||
console.log("init")
|
||||
taxRate = window.taxRate
|
||||
|
||||
$scope.changePlan = ->
|
||||
|
@ -37,10 +37,11 @@ define [
|
|||
|
||||
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
||||
|
||||
$scope.prices = {}
|
||||
$scope.prices = PRICES
|
||||
$scope.refreshPrice = (planCode)->
|
||||
if $scope.prices[planCode]?
|
||||
return
|
||||
$scope.prices[planCode] = "..."
|
||||
pricing = recurly.Pricing()
|
||||
pricing.plan(planCode, { quantity: 1 }).currency(MultiCurrencyPricing.currencyCode).done (price)->
|
||||
totalPriceExTax = parseFloat(price.next.total)
|
||||
|
@ -71,4 +72,34 @@ define [
|
|||
console.log "something went wrong changing plan"
|
||||
|
||||
$scope.cancel = () ->
|
||||
$modalInstance.dismiss('cancel')
|
||||
$modalInstance.dismiss('cancel')
|
||||
|
||||
|
||||
App.controller "UserSubscriptionController", ($scope, MultiCurrencyPricing, $http) ->
|
||||
$scope.view = 'overview'
|
||||
$scope.isMonthlyCollab = subscription?.planCode?.indexOf("collaborator") != -1 and subscription?.planCode?.indexOf("ann") == -1
|
||||
setupReturly()
|
||||
|
||||
recurly.Pricing().plan('student', { quantity: 1 }).currency(MultiCurrencyPricing.currencyCode).done (price)->
|
||||
totalPriceExTax = parseFloat(price.next.total)
|
||||
$scope.$evalAsync () ->
|
||||
taxAmmount = totalPriceExTax * taxRate
|
||||
if isNaN(taxAmmount)
|
||||
taxAmmount = 0
|
||||
$scope.currencySymbol = MultiCurrencyPricing.plans[MultiCurrencyPricing.currencyCode].symbol
|
||||
$scope.studentPrice = $scope.currencySymbol + (totalPriceExTax + taxAmmount)
|
||||
|
||||
$scope.downgradeToStudent = ->
|
||||
body =
|
||||
plan_code: 'student'
|
||||
_csrf : window.csrfToken
|
||||
$scope.inflight = true
|
||||
$http.post(SUBSCRIPTION_URL, body)
|
||||
.success ->
|
||||
location.reload()
|
||||
.error ->
|
||||
console.log "something went wrong changing plan"
|
||||
|
||||
|
||||
$scope.switchToCancelationView = ->
|
||||
$scope.view = "cancelation"
|
Loading…
Reference in a new issue