@@ -44,7 +44,7 @@ import {
44
44
showCreditCardExpiringWarning ,
45
45
showEditPaymentDetails
46
46
} from 'lib/purchases' ;
47
- import purchasesMixin from '../purchases-mixin ' ;
47
+ import { getPurchase , goToList , isDataLoading } from '../helper ' ;
48
48
49
49
const ManagePurchase = React . createClass ( {
50
50
propTypes : {
@@ -54,8 +54,6 @@ const ManagePurchase = React.createClass( {
54
54
destinationType : React . PropTypes . string
55
55
} ,
56
56
57
- mixins : [ purchasesMixin ] ,
58
-
59
57
isDataFetchingAfterRenewal ( ) {
60
58
return 'thank-you' === this . props . destinationType && this . props . selectedPurchase . isFetching ;
61
59
} ,
@@ -65,10 +63,10 @@ const ManagePurchase = React.createClass( {
65
63
} ,
66
64
67
65
renderPurchaseExpiringNotice ( ) {
68
- const purchase = this . getPurchase ( ) ;
66
+ const purchase = getPurchase ( this . props ) ;
69
67
let noticeStatus = 'is-info' ;
70
68
71
- if ( this . isDataLoading ( ) || ! isExpiring ( purchase ) || this . isDataFetchingAfterRenewal ( ) ) {
69
+ if ( isDataLoading ( this . props ) || ! isExpiring ( purchase ) || this . isDataFetchingAfterRenewal ( ) ) {
72
70
return null ;
73
71
}
74
72
@@ -97,11 +95,11 @@ const ManagePurchase = React.createClass( {
97
95
} ,
98
96
99
97
renderCreditCardExpiringNotice ( ) {
100
- if ( this . isDataLoading ( ) ) {
98
+ if ( isDataLoading ( this . props ) ) {
101
99
return null ;
102
100
}
103
101
104
- const purchase = this . getPurchase ( ) ,
102
+ const purchase = getPurchase ( this . props ) ,
105
103
{ domain, id, payment : { creditCard } } = purchase ;
106
104
107
105
if ( isExpired ( purchase ) || isOneTimePurchase ( purchase ) || isIncludedWithPlan ( purchase ) ) {
@@ -134,11 +132,11 @@ const ManagePurchase = React.createClass( {
134
132
} ,
135
133
136
134
renderPathNotice ( ) {
137
- if ( this . isDataLoading ( ) || ! this . props . destinationType ) {
135
+ if ( isDataLoading ( this . props ) || ! this . props . destinationType ) {
138
136
return ;
139
137
}
140
138
141
- const purchase = this . getPurchase ( ) ;
139
+ const purchase = getPurchase ( this . props ) ;
142
140
let text ;
143
141
144
142
if ( 'thank-you' === this . props . destinationType ) {
@@ -171,7 +169,7 @@ const ManagePurchase = React.createClass( {
171
169
} ,
172
170
173
171
handleRenew ( ) {
174
- const purchase = this . getPurchase ( ) ,
172
+ const purchase = getPurchase ( this . props ) ,
175
173
cartItem = cartItems . getRenewalItemFromProduct ( purchase , {
176
174
domain : purchase . meta
177
175
} ) ;
@@ -204,7 +202,7 @@ const ManagePurchase = React.createClass( {
204
202
} ,
205
203
206
204
renderPrice ( ) {
207
- const purchase = this . getPurchase ( ) ,
205
+ const purchase = getPurchase ( this . props ) ,
208
206
{ amount, currencyCode, currencySymbol } = purchase ;
209
207
210
208
if ( isOneTimePurchase ( purchase ) ) {
@@ -230,7 +228,7 @@ const ManagePurchase = React.createClass( {
230
228
231
229
renderProductLink ( ) {
232
230
const { selectedSite } = this . props ,
233
- purchase = this . getPurchase ( ) ;
231
+ purchase = getPurchase ( this . props ) ;
234
232
let url , text ;
235
233
236
234
if ( isPlan ( purchase ) ) {
@@ -265,9 +263,9 @@ const ManagePurchase = React.createClass( {
265
263
} ,
266
264
267
265
renderPaymentInfo ( ) {
268
- const purchase = this . getPurchase ( ) ;
266
+ const purchase = getPurchase ( this . props ) ;
269
267
270
- if ( this . isDataLoading ( ) ) {
268
+ if ( isDataLoading ( this . props ) ) {
271
269
return < span className = "manage-purchase__detail" /> ;
272
270
}
273
271
@@ -298,22 +296,22 @@ const ManagePurchase = React.createClass( {
298
296
} ,
299
297
300
298
renderPaymentDetails ( ) {
301
- const purchase = this . getPurchase ( ) ;
299
+ const purchase = getPurchase ( this . props ) ;
302
300
303
- if ( ! this . isDataLoading ( ) && isOneTimePurchase ( purchase ) ) {
301
+ if ( ! isDataLoading ( this . props ) && isOneTimePurchase ( purchase ) ) {
304
302
return null ;
305
303
}
306
304
307
305
let paymentDetails = (
308
306
< span >
309
307
< em className = "manage-purchase__detail-label" >
310
- { this . isDataLoading ( ) ? null : this . translate ( 'Payment method' ) }
308
+ { isDataLoading ( this . props ) ? null : this . translate ( 'Payment method' ) }
311
309
</ em >
312
310
{ this . renderPaymentInfo ( ) }
313
311
</ span >
314
312
) ;
315
313
316
- if ( this . isDataLoading ( ) || ! showEditPaymentDetails ( purchase ) ) {
314
+ if ( isDataLoading ( this . props ) || ! showEditPaymentDetails ( purchase ) ) {
317
315
return (
318
316
< li >
319
317
{ paymentDetails }
@@ -333,7 +331,7 @@ const ManagePurchase = React.createClass( {
333
331
} ,
334
332
335
333
renderRenewButton ( ) {
336
- const purchase = this . getPurchase ( ) ;
334
+ const purchase = getPurchase ( this . props ) ;
337
335
338
336
if ( ! isRenewable ( purchase ) || isExpired ( purchase ) || isExpiring ( purchase ) || this . isDataFetchingAfterRenewal ( ) ) {
339
337
return null ;
@@ -345,7 +343,7 @@ const ManagePurchase = React.createClass( {
345
343
} ,
346
344
347
345
renderExpiredRenewNotice ( ) {
348
- const purchase = this . getPurchase ( ) ;
346
+ const purchase = getPurchase ( this . props ) ;
349
347
350
348
if ( ! isRenewable ( purchase ) && ! isRedeemable ( purchase ) ) {
351
349
return null ;
@@ -368,7 +366,7 @@ const ManagePurchase = React.createClass( {
368
366
} ,
369
367
370
368
renderRenewsOrExpiresOnLabel ( ) {
371
- const purchase = this . getPurchase ( ) ;
369
+ const purchase = getPurchase ( this . props ) ;
372
370
373
371
if ( ! this . isDataFetchingAfterRenewal ( ) && ( isExpiring ( purchase ) || creditCardExpiresBeforeSubscription ( purchase ) ) ) {
374
372
return this . translate ( 'Expires on' ) ;
@@ -382,7 +380,7 @@ const ManagePurchase = React.createClass( {
382
380
} ,
383
381
384
382
renderRenewsOrExpiresOn ( ) {
385
- const purchase = this . getPurchase ( ) ;
383
+ const purchase = getPurchase ( this . props ) ;
386
384
387
385
if ( this . isDataFetchingAfterRenewal ( ) ) {
388
386
return null ;
@@ -418,7 +416,7 @@ const ManagePurchase = React.createClass( {
418
416
} ,
419
417
420
418
renderEditPaymentMethodNavItem ( ) {
421
- const purchase = this . getPurchase ( ) ,
419
+ const purchase = getPurchase ( this . props ) ,
422
420
{ domain, id, payment } = purchase ;
423
421
424
422
if ( showEditPaymentDetails ( purchase ) ) {
@@ -433,7 +431,7 @@ const ManagePurchase = React.createClass( {
433
431
} ,
434
432
435
433
renderCancelPurchaseNavItem ( ) {
436
- const purchase = this . getPurchase ( ) ,
434
+ const purchase = getPurchase ( this . props ) ,
437
435
{ domain, id } = purchase ;
438
436
439
437
if ( isExpired ( purchase ) || ! isCancelable ( purchase ) ) {
@@ -456,7 +454,7 @@ const ManagePurchase = React.createClass( {
456
454
} ,
457
455
458
456
renderCancelPrivateRegistration ( ) {
459
- const purchase = this . getPurchase ( ) ,
457
+ const purchase = getPurchase ( this . props ) ,
460
458
{ domain, id } = purchase ;
461
459
462
460
if ( isExpired ( purchase ) || ! hasPrivateRegistration ( purchase ) ) {
@@ -488,12 +486,12 @@ const ManagePurchase = React.createClass( {
488
486
cancelPurchaseNavItem ,
489
487
cancelPrivateRegistrationNavItem ;
490
488
491
- if ( this . isDataLoading ( ) ) {
489
+ if ( isDataLoading ( this . props ) ) {
492
490
classes = 'manage-purchase__info is-placeholder' ;
493
491
editPaymentMethodNavItem = < VerticalNavItem isPlaceholder /> ;
494
492
cancelPurchaseNavItem = < VerticalNavItem isPlaceholder /> ;
495
493
} else {
496
- purchase = this . getPurchase ( ) ;
494
+ purchase = getPurchase ( this . props ) ;
497
495
classes = classNames ( 'manage-purchase__info' , {
498
496
'is-expired' : purchase && isExpired ( purchase )
499
497
} ) ;
@@ -532,7 +530,7 @@ const ManagePurchase = React.createClass( {
532
530
< ul className = "manage-purchase__meta" >
533
531
< li >
534
532
< em className = "manage-purchase__detail-label" >
535
- { this . isDataLoading ( ) ? null : this . translate ( 'Price' ) }
533
+ { isDataLoading ( this . props ) ? null : this . translate ( 'Price' ) }
536
534
</ em >
537
535
< span className = "manage-purchase__detail" > { price } </ span >
538
536
</ li >
@@ -557,7 +555,7 @@ const ManagePurchase = React.createClass( {
557
555
} ,
558
556
559
557
render ( ) {
560
- if ( this . props . selectedPurchase . hasLoadedFromServer && ! this . getPurchase ( ) ) {
558
+ if ( this . props . selectedPurchase . hasLoadedFromServer && ! getPurchase ( this . props ) ) {
561
559
// TODO: redirect to purchases list
562
560
return null ;
563
561
}
@@ -566,7 +564,7 @@ const ManagePurchase = React.createClass( {
566
564
< span >
567
565
{ this . renderPathNotice ( ) }
568
566
< Main className = "manage-purchase" >
569
- < HeaderCake onClick = { this . goToList } > { this . translate ( 'Manage Purchase' ) } </ HeaderCake >
567
+ < HeaderCake onClick = { goToList } > { this . translate ( 'Manage Purchase' ) } </ HeaderCake >
570
568
{ this . renderNotices ( ) }
571
569
{ this . renderPurchaseDetail ( ) }
572
570
</ Main >
0 commit comments