done
This commit is contained in:
parent
4df1fe9ce1
commit
84ef9d188b
|
|
@ -141,3 +141,5 @@ UPDATE users set stored_credit_card = true where recurly_code is not null;
|
|||
-- alreday on WWW
|
||||
CREATE INDEX msuh_user_id ON music_sessions_user_history USING btree (user_id);
|
||||
CREATE INDEX msuh_created_at ON music_sessions_user_history USING btree (created_at);
|
||||
|
||||
CREATE INDEX bands_musicians_user_id_idx ON bands_musicians USING btree (user_id);
|
||||
|
|
@ -31,6 +31,11 @@ module JamRuby
|
|||
target_user = params[:user]
|
||||
target_band = params[:band]
|
||||
|
||||
# TODO: SPEED UP QUERY. CURRENTLY TAKES FOR EVER.
|
||||
if target_user or target_band
|
||||
return { query: [], next_page: nil}
|
||||
end
|
||||
|
||||
#query = Feed.includes([:recording]).includes([:music_session]).limit(limit)
|
||||
query = Feed.joins("LEFT OUTER JOIN recordings ON recordings.id = feeds.recording_id")
|
||||
.joins("LEFT OUTER JOIN music_sessions ON music_sessions.id = feeds.music_session_id")
|
||||
|
|
|
|||
|
|
@ -18,8 +18,10 @@ profileUtils = context.JK.ProfileUtils
|
|||
Reflux.listenTo(SubscriptionStore, "onSubscriptionChanged")
|
||||
]
|
||||
|
||||
subRef: null
|
||||
|
||||
onAppInit: (@app) ->
|
||||
@app.bindScreen('account/subscription', {beforeShow: @beforeShow, afterShow: @afterShow, beforeHide: @beforeHide})
|
||||
@app.bindScreen('account/subscription', {beforeShow: @beforeShow, afterShow: @afterShow, beforeHide: @beforeHide, beforeLeave: @beforeLeave})
|
||||
|
||||
onUserChanged: (userState) ->
|
||||
@setState({user: userState?.user})
|
||||
|
|
@ -32,8 +34,44 @@ profileUtils = context.JK.ProfileUtils
|
|||
return true
|
||||
|
||||
beforeShow: (e) ->
|
||||
|
||||
@allowLeave = false
|
||||
|
||||
SubscriptionActions.updateSubscription()
|
||||
|
||||
forceUpdate: () ->
|
||||
this.refs.sub.onSubmit()
|
||||
|
||||
userMustLeave: (location) ->
|
||||
@allowLeave = true
|
||||
window.location.href = '/client' + location
|
||||
|
||||
beforeLeave: (data) ->
|
||||
console.debug("subscription beforeLeave", @allowLeave)
|
||||
|
||||
if !this.refs.sub? || @allowLeave
|
||||
return true
|
||||
else
|
||||
|
||||
if this.refs.sub?
|
||||
if !this.refs.sub.state.selectedPlan?
|
||||
console.log("no selected plan; can leave")
|
||||
return true
|
||||
|
||||
buttons = []
|
||||
buttons.push({name: 'LEAVE ANYWAY', buttonStyle: 'button-grey', click: (() => (@userMustLeave(data.hash)))})
|
||||
buttons.push({
|
||||
name: 'UPDATE PLAN',
|
||||
buttonStyle: 'button-orange',
|
||||
click: (() => (@forceUpdate()))
|
||||
})
|
||||
context.JK.Banner.show({
|
||||
title: "Subscription Not Updated",
|
||||
html: '<div>If you leave this page without saving your new subscription plan preference, your selection will not take effect.<br/><br/>To save your new plan, please click the Update Plan button</div>',
|
||||
buttons: buttons})
|
||||
|
||||
return false
|
||||
|
||||
afterShow: (e) ->
|
||||
@screenVisible = true
|
||||
logger.debug("AccountSubscriptionScreen: afterShow")
|
||||
|
|
@ -49,7 +87,7 @@ profileUtils = context.JK.ProfileUtils
|
|||
|
||||
if @state.subscription
|
||||
|
||||
currentSubscription = `<CurrentSubscription subscription={this.state.subscription} app={this.app}/>`
|
||||
currentSubscription = `<CurrentSubscription ref="sub" subscription={this.state.subscription} app={this.app}/>`
|
||||
|
||||
content = `<div>
|
||||
<div className="current-subscription-block">
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ AppStore = context.AppStore
|
|||
else
|
||||
this.props.subscription.desired_plan_code || ''
|
||||
|
||||
checkIfPending:() ->
|
||||
return this.state.selectedPlan?
|
||||
|
||||
onSubmit: (event) ->
|
||||
if event
|
||||
event.preventDefault()
|
||||
|
|
@ -75,6 +78,7 @@ AppStore = context.AppStore
|
|||
SubscriptionActions.forceUpdate(subscription)
|
||||
has_billing_info = subscription.has_billing_info
|
||||
console.log("subscription change update", subscription)
|
||||
@setState({updating: false, selectedPlan: null})
|
||||
if has_billing_info
|
||||
@props.app.layout.notify({
|
||||
title: "Subscription updated!",
|
||||
|
|
@ -108,7 +112,7 @@ AppStore = context.AppStore
|
|||
# title: "Payment method still needed",
|
||||
# text: "Please click UPDATE PAYMENT METHOD in the bottom-right of the screen."
|
||||
#})
|
||||
@setState({updating: false, selectedPlan: null})
|
||||
|
||||
)
|
||||
.fail((jqXHR) =>
|
||||
@setState({updating: false})
|
||||
|
|
@ -128,10 +132,6 @@ AppStore = context.AppStore
|
|||
if confirm("Are you sure you want to cancel your plan?")
|
||||
SubscriptionActions.cancelSubscription()
|
||||
|
||||
componentDidUpdate: () ->
|
||||
if @state.updating
|
||||
@setState({updating:false})
|
||||
|
||||
componentDidMount: () ->
|
||||
|
||||
@root = $(@getDOMNode())
|
||||
|
|
@ -164,6 +164,11 @@ AppStore = context.AppStore
|
|||
if !@state.selectedPlan? || @state.updating
|
||||
changeClass = changeClass + ' disabled'
|
||||
|
||||
if @state.updating
|
||||
update_plan_text = 'UPDATING PLAN ... PLEASE WAIT'
|
||||
else
|
||||
update_plan_text = 'UPDATE PLAN'
|
||||
|
||||
|
||||
recurly_subscription = @props.subscription.subscription
|
||||
effective_plan_name = `<span className="plan-name">{this.getDisplayNameTier(this.props.subscription.plan_code)}</span>`
|
||||
|
|
@ -177,7 +182,6 @@ AppStore = context.AppStore
|
|||
show_payment_info = null
|
||||
has_billing_info = @props.subscription.has_billing_info
|
||||
|
||||
#console.log("@props.subscription.subscription", @props.subscription.subscription, has_pending_subscription)
|
||||
|
||||
if admin_override
|
||||
explanation = `<span>You have a {effective_plan_name} account until your gifted plan ends {context.JK.formatDateShort(this.props.subscription.admin_override_ends_at)}.</span>`
|
||||
|
|
@ -232,7 +236,7 @@ AppStore = context.AppStore
|
|||
<div className="subscription-actions">
|
||||
{plansJsx}
|
||||
<a className="button-grey" onClick={this.comparePlans} target="_blank" href="https://jamkazam.freshdesk.com/support/solutions/articles/66000122535-what-are-jamkazam-s-free-vs-premium-features-">COMPARE PLANS</a>
|
||||
<button className={changeClass} onClick={this.onSubmit} type="submit">UPDATE PLAN</button>
|
||||
<button className={changeClass} onClick={this.onSubmit} type="submit">{update_plan_text}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue