Skip to content

Commit

Permalink
Purchases: Show the fetching state when visiting ManagePurchase aft…
Browse files Browse the repository at this point in the history
…er renewing

Fixes #161.
  • Loading branch information
drewblaisdell committed Nov 24, 2015
1 parent 697314e commit 54b56fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
31 changes: 12 additions & 19 deletions client/me/purchases/manage-purchase/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const ManagePurchase = React.createClass( {
const purchase = getPurchase( this.props );
let noticeStatus = 'is-info';

if ( isDataLoading( this.props ) || ! isExpiring( purchase ) || this.isDataFetchingAfterRenewal() ) {
if ( isDataLoading( this.props ) || ! isExpiring( purchase ) ) {
return null;
}

Expand Down Expand Up @@ -272,7 +272,7 @@ const ManagePurchase = React.createClass( {
renderPaymentInfo() {
const purchase = getPurchase( this.props );

if ( isDataLoading( this.props ) ) {
if ( isDataLoading( this.props ) || this.isDataFetchingAfterRenewal() ) {
return <span className="manage-purchase__detail" />;
}

Expand Down Expand Up @@ -303,22 +303,23 @@ const ManagePurchase = React.createClass( {
},

renderPaymentDetails() {
const purchase = getPurchase( this.props );
const purchase = getPurchase( this.props ),
isLoading = isDataLoading( this.props ) || this.isDataFetchingAfterRenewal();

if ( ! isDataLoading( this.props ) && isOneTimePurchase( purchase ) ) {
if ( ! isLoading && isOneTimePurchase( purchase ) ) {
return null;
}

let paymentDetails = (
<span>
<em className="manage-purchase__detail-label">
{ isDataLoading( this.props ) ? null : this.translate( 'Payment method' ) }
{ isLoading ? null : this.translate( 'Payment method' ) }
</em>
{ this.renderPaymentInfo() }
</span>
);

if ( isDataLoading( this.props ) || ! showEditPaymentDetails( purchase ) ) {
if ( isLoading || ! showEditPaymentDetails( purchase ) ) {
return (
<li>
{ paymentDetails }
Expand All @@ -340,7 +341,7 @@ const ManagePurchase = React.createClass( {
renderRenewButton() {
const purchase = getPurchase( this.props );

if ( ! isRenewable( purchase ) || isExpired( purchase ) || isExpiring( purchase ) || this.isDataFetchingAfterRenewal() ) {
if ( ! isRenewable( purchase ) || isExpired( purchase ) || isExpiring( purchase ) ) {
return null;
}

Expand Down Expand Up @@ -375,7 +376,7 @@ const ManagePurchase = React.createClass( {
renderRenewsOrExpiresOnLabel() {
const purchase = getPurchase( this.props );

if ( ! this.isDataFetchingAfterRenewal() && ( isExpiring( purchase ) || creditCardExpiresBeforeSubscription( purchase ) ) ) {
if ( isExpiring( purchase ) || creditCardExpiresBeforeSubscription( purchase ) ) {
return this.translate( 'Expires on' );
}

Expand All @@ -389,10 +390,6 @@ const ManagePurchase = React.createClass( {
renderRenewsOrExpiresOn() {
const purchase = getPurchase( this.props );

if ( this.isDataFetchingAfterRenewal() ) {
return null;
}

if ( isRenewing( purchase ) ) {
return this.moment( purchase.renewDate ).format( 'LL' );
}
Expand Down Expand Up @@ -493,7 +490,7 @@ const ManagePurchase = React.createClass( {
cancelPurchaseNavItem,
cancelPrivateRegistrationNavItem;

if ( isDataLoading( this.props ) ) {
if ( isDataLoading( this.props ) || this.isDataFetchingAfterRenewal() ) {
classes = 'manage-purchase__info is-placeholder';
editPaymentMethodNavItem = <VerticalNavItem isPlaceholder />;
cancelPurchaseNavItem = <VerticalNavItem isPlaceholder />;
Expand All @@ -510,18 +507,14 @@ const ManagePurchase = React.createClass( {
productLink = this.renderProductLink();
price = this.renderPrice();
renewsOrExpiresOnLabel = this.renderRenewsOrExpiresOnLabel();
renewsOrExpiresOn = this.renderRenewsOrExpiresOn();
renewButton = this.renderRenewButton();
expiredRenewNotice = this.renderExpiredRenewNotice();
editPaymentMethodNavItem = this.renderEditPaymentMethodNavItem();
cancelPurchaseNavItem = this.renderCancelPurchaseNavItem();
cancelPrivateRegistrationNavItem = this.renderCancelPrivateRegistration();
renewsOrExpiresOn = this.renderRenewsOrExpiresOn();
}

const renewsOrExpiresOnClasses = classNames( 'manage-purchase__detail', {
'is-placeholder': this.isDataFetchingAfterRenewal()
} );

return (
<div>
<Card className={ classes }>
Expand All @@ -543,7 +536,7 @@ const ManagePurchase = React.createClass( {
</li>
<li>
<em className="manage-purchase__detail-label">{ renewsOrExpiresOnLabel }</em>
<span className={ renewsOrExpiresOnClasses }>
<span className="manage-purchase__detail">
{ renewsOrExpiresOn }
</span>
</li>
Expand Down
7 changes: 0 additions & 7 deletions client/me/purchases/manage-purchase/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,6 @@
text-align: right;
}

&.is-placeholder {
@include placeholder( 23% );

display: block;
height: 25px;
}

a {
display: block;
font-size: 12px;
Expand Down

0 comments on commit 54b56fc

Please sign in to comment.