From 9e1738a7faf3681dc38c00b551f8ce58f8b85f94 Mon Sep 17 00:00:00 2001 From: Erik Kieckhafer Date: Wed, 3 May 2017 15:30:54 -0700 Subject: [PATCH 1/4] update the way address data is provided --- .../containers/orderSummaryContainer.js | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/imports/plugins/core/orders/client/containers/orderSummaryContainer.js b/imports/plugins/core/orders/client/containers/orderSummaryContainer.js index d882ee5901e..8cfdb36bd25 100644 --- a/imports/plugins/core/orders/client/containers/orderSummaryContainer.js +++ b/imports/plugins/core/orders/client/containers/orderSummaryContainer.js @@ -2,7 +2,7 @@ import React, { Component, PropTypes } from "react"; import moment from "moment"; import _ from "lodash"; import { composeWithTracker } from "/lib/api/compose"; -import { Accounts, Orders } from "/lib/collections"; +import { Orders } from "/lib/collections"; import { i18next } from "/client/api"; import OrderSummary from "../components/orderSummary"; @@ -116,25 +116,19 @@ class OrderSummaryContainer extends Component { } const composer = (props, onData) => { - const userId = Meteor.userId(); - const userSub = Meteor.subscribe("UserProfile", userId); const orderSub = Meteor.subscribe("Orders"); - let profile = {}; - - if (userSub.ready() && orderSub.ready()) { - if (typeof userId === "string") { - const userProfile = Accounts.findOne(userId); - if (!userProfile) { - return profile; - } - profile = userProfile.profile.addressBook[0]; - } + if (orderSub.ready()) { + // Find current order const order = Orders.findOne({ "_id": props.orderId, "shipping._id": props.fulfillment._id }); + let profile = {}; + + profile = order.shipping[0].address; + if (order.workflow) { if (order.workflow.status === "coreOrderCreated") { order.workflow.status = "coreOrderCreated"; From b695bdc546841524198c43de8d132f987f56fae0 Mon Sep 17 00:00:00 2001 From: Erik Kieckhafer Date: Wed, 3 May 2017 15:37:00 -0700 Subject: [PATCH 2/4] update const --- .../core/orders/client/containers/orderSummaryContainer.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/imports/plugins/core/orders/client/containers/orderSummaryContainer.js b/imports/plugins/core/orders/client/containers/orderSummaryContainer.js index 8cfdb36bd25..920c1327c81 100644 --- a/imports/plugins/core/orders/client/containers/orderSummaryContainer.js +++ b/imports/plugins/core/orders/client/containers/orderSummaryContainer.js @@ -125,9 +125,7 @@ const composer = (props, onData) => { "shipping._id": props.fulfillment._id }); - let profile = {}; - - profile = order.shipping[0].address; + const profile = order.shipping[0].address; if (order.workflow) { if (order.workflow.status === "coreOrderCreated") { From 8171b60e53714227ffcd59ac44183bec5bc38686 Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Thu, 4 May 2017 08:10:04 +0800 Subject: [PATCH 3/4] Change `profile` variable name to `profileAddress` to be more descriptive --- .../orders/client/components/orderSummary.js | 16 ++++++++-------- .../client/containers/orderSummaryContainer.js | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/imports/plugins/core/orders/client/components/orderSummary.js b/imports/plugins/core/orders/client/components/orderSummary.js index 00a623e0cf0..45dd7208837 100644 --- a/imports/plugins/core/orders/client/components/orderSummary.js +++ b/imports/plugins/core/orders/client/components/orderSummary.js @@ -5,18 +5,18 @@ class OrderSummary extends Component { dateFormat: PropTypes.func, order: PropTypes.object, printableLabels: PropTypes.func, - profile: PropTypes.object, + profileAddress: PropTypes.object, shipmentStatus: PropTypes.func, tracking: PropTypes.func } render() { - const { dateFormat, tracking, order, shipmentStatus, profile, printableLabels } = this.props; + const { dateFormat, tracking, order, shipmentStatus, profileAddress, printableLabels } = this.props; return (
- {profile.fullName} , {profile.country} + {profileAddress.fullName} , {profileAddress.country}
ID {order._id}
@@ -90,15 +90,15 @@ class OrderSummary extends Component {
Ship to
- Phone: {profile.phone} + Phone: {profileAddress.phone}
- {profile.fullName} -
{profile.address1} - {profile.address2 &&
{profile.address2}
} -
{profile.city}, {profile.region}, {profile.country} {profile.postal} + {profileAddress.fullName} +
{profileAddress.address1} + {profileAddress.address2 &&
{profileAddress.address2}
} +
{profileAddress.city}, {profileAddress.region}, {profileAddress.country} {profileAddress.postal}
); diff --git a/imports/plugins/core/orders/client/containers/orderSummaryContainer.js b/imports/plugins/core/orders/client/containers/orderSummaryContainer.js index 920c1327c81..89c8b5d01cd 100644 --- a/imports/plugins/core/orders/client/containers/orderSummaryContainer.js +++ b/imports/plugins/core/orders/client/containers/orderSummaryContainer.js @@ -125,7 +125,7 @@ const composer = (props, onData) => { "shipping._id": props.fulfillment._id }); - const profile = order.shipping[0].address; + const profileAddress = order.shipping[0].address; if (order.workflow) { if (order.workflow.status === "coreOrderCreated") { @@ -136,7 +136,7 @@ const composer = (props, onData) => { onData(null, { order: order, - profile: profile + profileAddress: profileAddress }); } }; From 60b88f61c52ef8784a7143169bd466902467a04a Mon Sep 17 00:00:00 2001 From: Brent Hoover Date: Thu, 4 May 2017 08:13:58 +0800 Subject: [PATCH 4/4] And `profileShippingAddress` is even better --- .../orders/client/components/orderSummary.js | 16 ++++++++-------- .../client/containers/orderSummaryContainer.js | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/imports/plugins/core/orders/client/components/orderSummary.js b/imports/plugins/core/orders/client/components/orderSummary.js index 45dd7208837..18453b6e149 100644 --- a/imports/plugins/core/orders/client/components/orderSummary.js +++ b/imports/plugins/core/orders/client/components/orderSummary.js @@ -5,18 +5,18 @@ class OrderSummary extends Component { dateFormat: PropTypes.func, order: PropTypes.object, printableLabels: PropTypes.func, - profileAddress: PropTypes.object, + profileShippingAddress: PropTypes.object, shipmentStatus: PropTypes.func, tracking: PropTypes.func } render() { - const { dateFormat, tracking, order, shipmentStatus, profileAddress, printableLabels } = this.props; + const { dateFormat, tracking, order, shipmentStatus, profileShippingAddress, printableLabels } = this.props; return (
- {profileAddress.fullName} , {profileAddress.country} + {profileShippingAddress.fullName} , {profileShippingAddress.country}
ID {order._id}
@@ -90,15 +90,15 @@ class OrderSummary extends Component {
Ship to
- Phone: {profileAddress.phone} + Phone: {profileShippingAddress.phone}
- {profileAddress.fullName} -
{profileAddress.address1} - {profileAddress.address2 &&
{profileAddress.address2}
} -
{profileAddress.city}, {profileAddress.region}, {profileAddress.country} {profileAddress.postal} + {profileShippingAddress.fullName} +
{profileShippingAddress.address1} + {profileShippingAddress.address2 &&
{profileShippingAddress.address2}
} +
{profileShippingAddress.city}, {profileShippingAddress.region}, {profileShippingAddress.country} {profileShippingAddress.postal}
); diff --git a/imports/plugins/core/orders/client/containers/orderSummaryContainer.js b/imports/plugins/core/orders/client/containers/orderSummaryContainer.js index 89c8b5d01cd..f537e6175c1 100644 --- a/imports/plugins/core/orders/client/containers/orderSummaryContainer.js +++ b/imports/plugins/core/orders/client/containers/orderSummaryContainer.js @@ -125,7 +125,7 @@ const composer = (props, onData) => { "shipping._id": props.fulfillment._id }); - const profileAddress = order.shipping[0].address; + const profileShippingAddress = order.shipping[0].address; if (order.workflow) { if (order.workflow.status === "coreOrderCreated") { @@ -136,7 +136,7 @@ const composer = (props, onData) => { onData(null, { order: order, - profileAddress: profileAddress + profileShippingAddress: profileShippingAddress }); } };