diff --git a/demo/peacock/src/pages/checkout/billing/edit-billing.jsx b/demo/peacock/src/pages/checkout/billing/edit-billing.jsx index f61e029b9e..b5fd0cb96d 100644 --- a/demo/peacock/src/pages/checkout/billing/edit-billing.jsx +++ b/demo/peacock/src/pages/checkout/billing/edit-billing.jsx @@ -55,6 +55,7 @@ type Props = CheckoutActions & { creditCards: Array, creditCardsLoading: boolean, chooseCreditCard: () => Promise<*>, + fetchAddresses: () => Promise<*>, }; type State = { @@ -95,13 +96,17 @@ class EditBilling extends Component { } const coupon = this.props.coupon; + let newState = {}; + if (!_.isEmpty(coupon)) { - this.setState({ couponCode: coupon.code }); + newState = { couponCode: coupon.code }; } - if (this.props.data.address) { - this.state.billingAddressIsSame = false; + if (this.props.shippingAddress) { + newState = {...newState, billingAddressIsSame: false }; } + + this.setState(newState); } // Credit Card Handling @@ -216,6 +221,7 @@ class EditBilling extends Component { return operation.then((card) => { this.props.fetchCreditCards(); + this.props.fetchAddresses(); this.props.resetBillingData(); this.setState({ addingNew: false, cardAdded: (id === undefined) }); return card; @@ -462,6 +468,7 @@ class EditBilling extends Component { checked={this.state.billingAddressIsSame} onChange={this.toggleSeparateBillingAddress} styleName="same-address-checkbox" + disabled={_.isEmpty(this.props.shippingAddress)} > {t('Billing address is same as shipping')} diff --git a/demo/peacock/src/pages/checkout/checkout.jsx b/demo/peacock/src/pages/checkout/checkout.jsx index 05eb9a4c27..b96212a986 100644 --- a/demo/peacock/src/pages/checkout/checkout.jsx +++ b/demo/peacock/src/pages/checkout/checkout.jsx @@ -219,63 +219,62 @@ class Checkout extends Component { const isGuestMode = isGuest(_.get(props.auth, 'user')); const cartFetched = props.fetchCartState.finished; - if (cartFetched) { - const shippingAddress = _.get(this.props.cart, 'shippingAddress', {}); - - return ( -
-
-
-
-
- -
-
- -
-
-
- ; + } + + const shippingAddress = _.get(this.props.cart, 'shippingAddress', {}); + + return ( +
+
+
+
+
+ +
+
+
-
- {this.orderContent} +
+
-
- {this.orderTotals} +
+ {this.orderContent}
- -
- ); - } +
+ {this.orderTotals} +
- return ( - + +
); }