7
7
cta-text =" Setup billing"
8
8
cta-to =" /manage/billing"
9
9
/>
10
+ <Loading v-else-if =" loading" :message =" loading" />
10
11
<div v-else >
11
- <h1 >Subscription</h1 >
12
- <Loading v-if =" loading" :message =" loading" />
12
+ <h1 >Subscriptions</h1 >
13
13
<LargeMessage
14
- v-else- if ="
14
+ v-if ="
15
15
!loading &&
16
16
(!subscriptions ||
17
17
!subscriptions.data ||
25
25
subscriptions && subscriptions.data && subscriptions.data.length
26
26
"
27
27
>
28
- <table class =" table table--type-cols" >
28
+ <table class =" table" >
29
+ <thead >
30
+ <tr >
31
+ <th >Plan</th >
32
+ <th >Price</th >
33
+ <th >Billing period</th >
34
+ <th ></th >
35
+ </tr >
36
+ </thead >
29
37
<tbody >
30
38
<tr
31
39
v-for =" (subscription, index) in subscriptions.data"
32
40
:key =" `${subscription.id}_${index}`"
33
41
>
34
42
<td >
35
- {{ subscription }}
43
+ <span >{{ subscription.plan.nickname }}</span >
44
+ <span :class =" `label label--color-${subscription.status}`" >{{
45
+ subscription.status
46
+ }}</span >
47
+ </td >
48
+ <td >
49
+ <span >{{ subscription.plan.currency.toUpperCase() }}</span >
50
+ <span >{{ subscription.plan.amount }}</span >
51
+ <span >{{
52
+ subscription.plan.interval_count == 1
53
+ ? "per"
54
+ : `per ${subscription.plan.interval_count}`
55
+ }}</span >
56
+ <span v-if =" subscription.plan.interval_count != 1" >{{
57
+ subscription.plan.interval_count
58
+ }}</span >
59
+ <span >{{ subscription.plan.interval }}</span >
60
+ </td >
61
+ <td >
62
+ Ends <TimeAgo :date =" subscription.current_period_end * 1000" />
63
+ </td >
64
+ <td class =" text text--align-right" >
65
+ <router-link
66
+ :to ="
67
+ `/manage/${$route.params.team}/invoices/${subscription.latest_invoice}`
68
+ "
69
+ data-balloon =" Last invoice"
70
+ data-balloon-pos =" up"
71
+ class =" button button--type-icon"
72
+ >
73
+ <font-awesome-icon
74
+ title =" Last invoice"
75
+ class =" icon"
76
+ icon =" file-invoice-dollar"
77
+ fixed-width
78
+ />
79
+ </router-link >
80
+ <router-link
81
+ :to ="
82
+ `/manage/${$route.params.team}/subscriptions/${subscription.id}`
83
+ "
84
+ data-balloon =" Edit"
85
+ data-balloon-pos =" up"
86
+ class =" button button--type-icon"
87
+ >
88
+ <font-awesome-icon
89
+ title =" Edit"
90
+ class =" icon"
91
+ icon =" pencil-alt"
92
+ fixed-width
93
+ />
94
+ </router-link >
36
95
</td >
37
96
</tr >
38
97
</tbody >
39
98
</table >
99
+ <div class =" pagination text text--align-center" >
100
+ <button
101
+ v-if =" subscriptions && subscriptions.hasMore"
102
+ class =" button"
103
+ :disabled =" loadingMore"
104
+ @click =" loadMore"
105
+ >
106
+ <span >Load more subscriptions</span >
107
+ <font-awesome-icon
108
+ v-if =" !loadingMore"
109
+ class =" icon"
110
+ icon =" arrow-down"
111
+ />
112
+ <font-awesome-icon
113
+ v-else
114
+ title =" Available"
115
+ class =" icon icon--ml-2 icon--color-light"
116
+ icon =" sync"
117
+ spin
118
+ />
119
+ </button >
120
+ </div >
40
121
</div >
41
122
<h2 >New subscription</h2 >
42
- <p >Create a new subscription for your organization.</p >
123
+ <p >
124
+ Create a new subscription for your organization. Your default payment
125
+ method will be charged automatically
126
+ </p >
43
127
<Loading v-if =" loadingPricingPlans" :message =" loadingPricingPlans" />
44
128
<LargeMessage
45
129
v-else-if ="
49
133
heading =" No plans here"
50
134
text =" Unfortunately, we don't have any subscription plans available for you right now."
51
135
/>
52
- <form v-else >
136
+ <form v-else @submit.prevent = " createSubscription " >
53
137
<div
54
138
v-for =" (plan, index) in pricingPlans.data"
55
139
:key =" `${plan.id}_${index}`"
140
+ class =" fake-radio-container"
56
141
>
57
142
<label >
58
143
<input v-model =" newPlan" type =" radio" :value =" plan.id" required />
144
+ <span class =" fake-radio" role =" radio" tabindex =" 0" />
59
145
<strong class =" name" >{{ plan.nickname }}</strong >
60
146
<span class =" amount" >
61
147
{{ (plan.currency || "eur").toUpperCase() }}
69
155
</span >
70
156
</label >
71
157
</div >
72
- <p class =" text text--size-small" >
73
- On creating a new subscription, your default payment method will be
74
- billed.
75
- </p >
76
158
<button class =" button" >Create subscription</button >
77
159
</form >
78
160
</div >
83
165
import { Component , Vue , Watch } from " vue-property-decorator" ;
84
166
import { mapGetters } from " vuex" ;
85
167
import Loading from " @/components/Loading.vue" ;
168
+ import TimeAgo from " @/components/TimeAgo.vue" ;
86
169
import LargeMessage from " @/components/LargeMessage.vue" ;
87
170
import Input from " @/components/form/Input.vue" ;
88
- import Select from " @/components/form/Select.vue" ;
89
171
import Checkbox from " @/components/form/Checkbox.vue" ;
172
+ import Select from " @/components/form/Select.vue" ;
173
+
90
174
import { getAllCountries } from " countries-and-timezones" ;
91
175
import { User } from " @/types/auth" ;
176
+ import { FontAwesomeIcon } from " @fortawesome/vue-fontawesome" ;
177
+ import { library } from " @fortawesome/fontawesome-svg-core" ;
178
+ import {
179
+ faFileInvoiceDollar ,
180
+ faPencilAlt ,
181
+ faArrowDown ,
182
+ faSync
183
+ } from " @fortawesome/free-solid-svg-icons" ;
92
184
import { Subscriptions , emptyPagination } from " ../../../../types/manage" ;
185
+ library .add (faFileInvoiceDollar , faPencilAlt , faArrowDown , faSync );
93
186
94
187
@Component ({
95
188
components: {
96
189
Loading ,
190
+ TimeAgo ,
97
191
Input ,
192
+ FontAwesomeIcon ,
98
193
Select ,
99
194
LargeMessage ,
100
195
Checkbox
@@ -107,6 +202,7 @@ import { Subscriptions, emptyPagination } from "../../../../types/manage";
107
202
})
108
203
export default class ManageSettings extends Vue {
109
204
subscriptions: Subscriptions = emptyPagination ;
205
+ loadingMore = false ;
110
206
pricingPlans! : any ;
111
207
noBilling = false ;
112
208
user! : any ;
@@ -135,10 +231,45 @@ export default class ManageSettings extends Vue {
135
231
this .loadingPricingPlans = " Loading pricing plans" ;
136
232
this .$store
137
233
.dispatch (" manage/getPricingPlans" , this .$route .params .team )
138
- .then (() => {})
234
+ .then (() => {
235
+ this .newPlan = this .pricingPlans .data [0 ].id ;
236
+ })
139
237
.catch (() => {})
140
238
.finally (() => (this .loadingPricingPlans = " " ));
141
239
}
240
+
241
+ private loadMore() {
242
+ this .loadingMore = true ;
243
+ this .$store
244
+ .dispatch (" manage/getSubscriptions" , {
245
+ team: this .$route .params .team ,
246
+ start: this .$store .state .manage .subscriptions [this .$route .params .team ]
247
+ .start
248
+ })
249
+ .then (subscriptions => {
250
+ this .subscriptions = { ... subscriptions };
251
+ })
252
+ .catch (error => {
253
+ if (error .response .data .error === " no-customer" ) this .noBilling = true ;
254
+ })
255
+ .finally (() => (this .loadingMore = false ));
256
+ }
257
+
258
+ private createSubscription() {
259
+ this .loading = " Creating your subscription" ;
260
+ this .$store
261
+ .dispatch (" manage/createSubscription" , {
262
+ team: this .$route .params .team ,
263
+ plan: this .newPlan
264
+ })
265
+ .then (subscriptions => {
266
+ this .subscriptions = { ... subscriptions };
267
+ })
268
+ .catch (error => {
269
+ if (error .response .data .error === " no-customer" ) this .noBilling = true ;
270
+ })
271
+ .finally (() => (this .loading = " " ));
272
+ }
142
273
}
143
274
</script >
144
275
0 commit comments