75 lines
1.9 KiB
CoffeeScript
75 lines
1.9 KiB
CoffeeScript
context = window
|
|
rest = context.JK.Rest()
|
|
logger = context.JK.logger
|
|
|
|
AppStore = context.AppStore
|
|
UserStore = context.UserStore
|
|
SubscriptionStore = context.SubscriptionStore
|
|
SubscriptionActions = context.SubscriptionActions
|
|
|
|
profileUtils = context.JK.ProfileUtils
|
|
|
|
@AccountSubscriptionScreen = React.createClass({
|
|
|
|
mixins: [
|
|
ICheckMixin,
|
|
Reflux.listenTo(AppStore, "onAppInit"),
|
|
Reflux.listenTo(UserStore, "onUserChanged"),
|
|
Reflux.listenTo(SubscriptionStore, "onSubscriptionChanged")
|
|
]
|
|
|
|
onAppInit: (@app) ->
|
|
@app.bindScreen('account/subscription', {beforeShow: @beforeShow, afterShow: @afterShow, beforeHide: @beforeHide})
|
|
|
|
onUserChanged: (userState) ->
|
|
@setState({user: userState?.user})
|
|
|
|
onSubscriptionChanged: (subscription) ->
|
|
@setState({subscription: subscription})
|
|
|
|
beforeHide: (e) ->
|
|
@screenVisible = false
|
|
return true
|
|
|
|
beforeShow: (e) ->
|
|
SubscriptionActions.updateSubscription()
|
|
|
|
afterShow: (e) ->
|
|
@screenVisible = true
|
|
logger.debug("AccountSubscriptionScreen: afterShow")
|
|
|
|
getInitialState: () ->
|
|
{ user: null, updating: false, subscription: null}
|
|
|
|
onCancel: (e) ->
|
|
e.preventDefault()
|
|
context.location.href = '/client#/account'
|
|
|
|
render: () ->
|
|
|
|
if @state.subscription
|
|
|
|
currentSubscription = `<CurrentSubscription subscription={this.state.subscription} app={this.app}/>`
|
|
|
|
content = `<div>
|
|
<div className="current-subscription-block">
|
|
{currentSubscription}
|
|
</div>
|
|
</div>`
|
|
else
|
|
content = `<div className="loading">Loading...</div>`
|
|
|
|
`<div className="content-body-scroller">
|
|
<div className="profile-header profile-head">
|
|
|
|
</div>
|
|
<div className="profile-body">
|
|
<div className="profile-wrapper">
|
|
<div className="main-content">
|
|
{content}
|
|
<br />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>`
|
|
}) |