-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
@spencern @aaronjudd this is ready for another look through. |
@spencern this is ready for you to review again |
} | ||
<br/> | ||
<span> | ||
{profileShippingAddress && profileShippingAddress.city}, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}, | ||
{profileShippingAddress && profileShippingAddress.region}, |
There was a problem hiding this comment.
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
here. Does React not respect spaces here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spencern I added the
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 usedprofileShippingAddress.property
everywhere.
then I wouldn't have to change the line/add
s.
There was a problem hiding this 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) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use prototype every
instead of lodash
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
@@ -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) => { |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we can't use prototype replace
here? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
server/methods/core/orders.js
Outdated
@@ -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(); }); |
There was a problem hiding this comment.
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.
…/reactioncommerce/reaction into kieha-remove-zeroth-indexes-2770
@spencern I've addressed the most recent changes that you had requested. I believe this is good to go now. |
Only issue was when clicking Client Error:
Server Error:
|
Turns out that issue is present in the |
Resolves #2770
This PR aims to remove hard coded first billing and shipping objects from most code around orders.
How to test