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

Remove hardcoded billing and shipping objects #2813

Merged
merged 74 commits into from
Sep 26, 2017

Conversation

kieha
Copy link
Contributor

@kieha kieha commented Sep 8, 2017

Resolves #2770

This PR aims to remove hard coded first billing and shipping objects from most code around orders.

How to test

  • Open browser console.
  • Go through order creating/completing/processing-as-admin process.
  • Make sure everything works as normal, and there are no errors in the browser console and/or server.

brent-hoover and others added 30 commits September 1, 2017 07:51
@kieha
Copy link
Contributor Author

kieha commented Sep 21, 2017

@spencern @aaronjudd this is ready for another look through.

@aaronjudd
Copy link
Contributor

@spencern this is ready for you to review again

}
<br/>
<span>
{profileShippingAddress && profileShippingAddress.city},&nbsp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works. 👍

You could have setup profileShippingAddress to pass an empty object if undefined and then just used profileShippingAddress.property everywhere, but that's not necessarily better, just different. Not blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this makes sense. Avoids having to repeat profileShippingAddress && in a lot of places.

<br/>
<span>
{profileShippingAddress && profileShippingAddress.city},&nbsp;
{profileShippingAddress && profileShippingAddress.region},&nbsp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually more curious about the need for &nbsp; here. Does React not respect spaces here?

Copy link
Contributor Author

@kieha kieha Sep 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spencern I added the &nbsp; because the addition of profileShippingAddress &&s made the line too long, and I had to break it into different lines, therefore line 172 and 173 end up being two strings without space in between them.

But if I did this:

You could have set up profileShippingAddress to pass an empty object if undefined and then just used profileShippingAddress.property everywhere.

then I wouldn't have to change the line/add &nbsp;s.

Copy link
Contributor

@spencern spencern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some functions that should use prototype functions instead of lodash, otherwise looks pretty good. A few other "optional" style thoughts that don't block merging.

@@ -115,7 +123,7 @@ Template.coreOrderShippingTracking.helpers({
const currentData = Template.currentData();
const order = Template.instance().order;

const shippedItems = _.every(currentData.fulfillment.items, (shipmentItem) => {
const shippedItems = _.every(currentData.fulfillment && currentData.fulfillment.items, (shipmentItem) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -132,7 +140,7 @@ Template.coreOrderShippingTracking.helpers({
const currentData = Template.currentData();
const order = Template.instance().order;

const canceledItems = _.every(currentData.fulfillment.items, (shipmentItem) => {
const canceledItems = _.every(currentData.fulfillment && currentData.fulfillment.items, (shipmentItem) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -149,7 +157,7 @@ Template.coreOrderShippingTracking.helpers({
const currentData = Template.currentData();
const order = Template.instance().order;

const completedItems = _.every(currentData.fulfillment.items, (shipmentItem) => {
const completedItems = _.every(currentData.fulfillment && currentData.fulfillment.items, (shipmentItem) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prototype instead of lodash


return _.includes(shipment.workflow.workflow, "coreOrderWorkflow/packed") && shipment.tracking ||
_.includes(shipment.workflow.workflow, "coreOrderWorkflow/packed");
return _.includes(shipmentWorkflow && shipmentWorkflow.workflow, "coreOrderWorkflow/packed") && shipment.tracking
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

orderSearch.shippingName = shopShipping.address.fullName;
orderSearch.shippingPhone = _.replace(shopShipping.address.phone, /\D/g, "");
orderSearch.shippingName = shopShipping.address && shopShipping.address.fullName;
orderSearch.shippingPhone = _.replace(shopShipping.address && shopShipping.address.phone, /\D/g, "");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -290,10 +300,13 @@ export const methods = {
ordersInventoryAdjust(order._id);
}

const billingRecord = order.billing.find((billing) => { return billing.shopId === Reaction.getShopId(); });
const shippingRecord = order.shipping.find((shipping) => { return shipping.shopId === Reaction.getShopId(); });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a single line, you can use the shorthand find if you prefer.

order.shipping.find((shipping) => shipping.shopId === Reaction.getShopId());

Just trying to avoid using the shorthand for multi-line functions.

@kieha
Copy link
Contributor Author

kieha commented Sep 26, 2017

@spencern I've addressed the most recent changes that you had requested. I believe this is good to go now.

@spencern
Copy link
Contributor

Only issue was when clicking

image

Client Error:

Error invoking Method 'notification/send': Match failed [400]

Server Error:

Exception while invoking method 'notification/send' Error: Match error: Expected string, got null
    at exports.check (packages/check.js:55:15)
    at [object Object].notificationSend (imports/plugins/included/notifications/server/methods/notifications.js:21:5)
    at packages/check.js:128:16
    at [object Object].EVp.withValue (packages/meteor.js:1134:15)
    at Object.exports.Match._failIfArgumentsAreNotAllChecked (packages/check.js:127:41)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1765:18)
    at packages/ddp-server/livedata_server.js:719:19
    at [object Object].EVp.withValue (packages/meteor.js:1134:15)
    at packages/ddp-server/livedata_server.js:717:46
    at [object Object].EVp.withValue (packages/meteor.js:1134:15)
    at packages/ddp-server/livedata_server.js:715:46
    at [object Object]._.extend.protocol_handlers.method (packages/ddp-server/livedata_server.js:689:23)
    at packages/ddp-server/livedata_server.js:559:43
Sanitized and reported to the client as: Match failed [400]

@spencern
Copy link
Contributor

Turns out that issue is present in the marketplace branch.
Approved 👍

@spencern spencern merged commit a6fc9f9 into marketplace Sep 26, 2017
@spencern spencern deleted the kieha-remove-zeroth-indexes-2770 branch September 26, 2017 22:24
@spencern spencern mentioned this pull request Oct 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants