Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update the way address data is provided #2208

Merged
merged 4 commits into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions imports/plugins/core/orders/client/components/orderSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ class OrderSummary extends Component {
dateFormat: PropTypes.func,
order: PropTypes.object,
printableLabels: PropTypes.func,
profile: PropTypes.object,
profileShippingAddress: PropTypes.object,
shipmentStatus: PropTypes.func,
tracking: PropTypes.func
}

render() {
const { dateFormat, tracking, order, shipmentStatus, profile, printableLabels } = this.props;
const { dateFormat, tracking, order, shipmentStatus, profileShippingAddress, printableLabels } = this.props;

return (
<div>
<div className="order-summary-form-group bg-info" style={{ lineHeight: 3, marginTop: -15, marginRight: -15, marginLeft: -15 }}>
<strong style={{ marginLeft: 15 }}>{profile.fullName}</strong> , {profile.country}
<strong style={{ marginLeft: 15 }}>{profileShippingAddress.fullName}</strong> , {profileShippingAddress.country}
<div className="invoice-details" style={{ marginRight: 15 }}>
<strong>ID </strong>{order._id}
</div>
Expand Down Expand Up @@ -90,15 +90,15 @@ class OrderSummary extends Component {
<div className="order-summary-form-group">
<strong data-i18n="orderShipping.shipTo">Ship to</strong>
<div className="invoice-details">
<strong>Phone: </strong>{profile.phone}
<strong>Phone: </strong>{profileShippingAddress.phone}
</div>
</div>

<div style={{ marginTop: 4 }}>
<span>{profile.fullName}</span>
<br/><span>{profile.address1}</span>
{profile.address2 && <span><br/>{profile.address2}</span>}
<br/><span>{profile.city}, {profile.region}, {profile.country} {profile.postal}</span>
<span>{profileShippingAddress.fullName}</span>
<br/><span>{profileShippingAddress.address1}</span>
{profileShippingAddress.address2 && <span><br/>{profileShippingAddress.address2}</span>}
<br/><span>{profileShippingAddress.city}, {profileShippingAddress.region}, {profileShippingAddress.country} {profileShippingAddress.postal}</span>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -116,25 +116,17 @@ 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
});

const profileShippingAddress = order.shipping[0].address;

if (order.workflow) {
if (order.workflow.status === "coreOrderCreated") {
order.workflow.status = "coreOrderCreated";
Expand All @@ -144,7 +136,7 @@ const composer = (props, onData) => {

onData(null, {
order: order,
profile: profile
profileShippingAddress: profileShippingAddress
});
}
};
Expand Down