-
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
Changes from 65 commits
d7b40d0
864e52d
dc3f5ee
e0dc83e
e23ed7c
aa772ee
fa45c4f
bf9e50d
42d6341
a9433c4
cd701b1
5ba6521
37f6a7c
baab68c
8916529
9d0010a
d3d1da9
ded21a6
b24c32a
278ee70
b245a4d
48b81fe
553d893
78fd30e
f33da7d
4fd58e1
5fd8f8c
a3c4c4c
4933b60
7e624ac
5297781
09e17ad
e8709c3
eed0d3d
847805f
9d15260
3e04d1d
15cf436
97b8bc4
44dd1a1
c19b4fa
c30e0d8
1554d97
30a5bbd
42bbd41
70592a7
21c4798
2fc89ba
9bc17b8
cb72ef5
2db1e56
c566890
50c4f2b
0b1babe
7e42107
e6b1e12
09802e9
2a17940
806e1e8
da8f1b3
6e59986
fe06cf1
dd1c62f
a4fcf23
c8209df
8b0b539
529a531
d5590a6
6b7cf0a
16a7be4
608b086
e6368d7
0fe9e6a
e645ede
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import React, { Component } from "react"; | |
import PropTypes from "prop-types"; | ||
import moment from "moment"; | ||
import { Badge, ClickToCopy } from "@reactioncommerce/reaction-ui"; | ||
import { getOrderRiskBadge, getOrderRiskStatus } from "../helpers"; | ||
import { getOrderRiskBadge, getOrderRiskStatus, getBillingInfo, getShippingInfo } from "../helpers"; | ||
|
||
class OrderSummary extends Component { | ||
static propTypes = { | ||
|
@@ -15,7 +15,8 @@ class OrderSummary extends Component { | |
} | ||
|
||
badgeStatus() { | ||
const orderStatus = this.props.order.workflow.status; | ||
const order = this.props.order; | ||
const orderStatus = order && order.workflow && order.workflow.status; | ||
|
||
if (orderStatus === "new") { | ||
return "info"; | ||
|
@@ -44,12 +45,18 @@ class OrderSummary extends Component { | |
|
||
render() { | ||
const { dateFormat, tracking, order, profileShippingAddress, printableLabels } = this.props; | ||
const paymentMethod = getBillingInfo(order).paymentMethod; | ||
const invoice = getBillingInfo(order).invoice; | ||
const shipmentMethod = getShippingInfo(order).shipmentMethod; | ||
const orderRisk = getOrderRiskStatus(order); | ||
|
||
return ( | ||
<div> | ||
<div className="order-summary-form-group bg-info" style={{ lineHeight: 3, marginTop: -15, marginRight: -15, marginLeft: -15 }}> | ||
<strong style={{ marginLeft: 15 }}>{profileShippingAddress.fullName}</strong> | ||
<div | ||
className="order-summary-form-group bg-info" | ||
style={{ lineHeight: 3, marginTop: -15, marginRight: -15, marginLeft: -15 }} | ||
> | ||
<strong style={{ marginLeft: 15 }}>{profileShippingAddress && profileShippingAddress.fullName}</strong> | ||
<div className="invoice-details" style={{ marginRight: 15, position: "relative" }}> | ||
{order.email} | ||
</div> | ||
|
@@ -60,8 +67,8 @@ class OrderSummary extends Component { | |
<div style={{ marginBottom: 4 }}> | ||
<Badge | ||
badgeSize="large" | ||
i18nKeyLabel={`cartDrawer.${order.workflow.status}`} | ||
label={order.workflow.status} | ||
i18nKeyLabel={`cartDrawer.${order && order.workflow && order.workflow.status}`} | ||
label={order && order.workflow && order.workflow.status} | ||
status={this.badgeStatus()} | ||
/> | ||
{orderRisk && | ||
|
@@ -97,28 +104,28 @@ class OrderSummary extends Component { | |
<div className="order-summary-form-group"> | ||
<strong data-i18n="order.processor">Processor</strong> | ||
<div className="invoice-details"> | ||
{order.billing[0].paymentMethod.processor} | ||
{paymentMethod && paymentMethod.processor} | ||
</div> | ||
</div> | ||
|
||
<div className="order-summary-form-group"> | ||
<strong data-i18n="order.payment">Payment</strong> | ||
<div className="invoice-details"> | ||
{order.billing[0].paymentMethod.storedCard} ({order.billing[0].invoice.total}) | ||
{paymentMethod && paymentMethod.storedCard} ({invoice && invoice.total}) | ||
</div> | ||
</div> | ||
|
||
<div className="order-summary-form-group"> | ||
<strong data-i18n="order.transaction">Transaction</strong> | ||
<div className="invoice-details"> | ||
{order.billing[0].paymentMethod.transactionId} | ||
{paymentMethod && paymentMethod.transactionId} | ||
</div> | ||
</div> | ||
|
||
<div className="order-summary-form-group"> | ||
<strong data-i18n="orderShipping.carrier">Carrier</strong> | ||
<div className="invoice-details"> | ||
{order.shipping[0].shipmentMethod.carrier} - {order.shipping[0].shipmentMethod.label} | ||
{ shipmentMethod && shipmentMethod.carrier} - {shipmentMethod && shipmentMethod.label} | ||
</div> | ||
</div> | ||
|
||
|
@@ -149,15 +156,24 @@ 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>{profileShippingAddress.phone} | ||
<strong>Phone: </strong>{profileShippingAddress && profileShippingAddress.phone} | ||
</div> | ||
</div> | ||
|
||
<div style={{ marginTop: 4 }}> | ||
<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> | ||
<span>{profileShippingAddress && profileShippingAddress.fullName}</span> | ||
<br/> | ||
<span>{profileShippingAddress && profileShippingAddress.address1}</span> | ||
{profileShippingAddress && profileShippingAddress.address2 && | ||
<span><br/>{profileShippingAddress.address2}</span> | ||
} | ||
<br/> | ||
<span> | ||
{profileShippingAddress && profileShippingAddress.city}, | ||
{profileShippingAddress && profileShippingAddress.region}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm actually more curious about the need for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @spencern I added the But if I did this:
then I wouldn't have to change the line/add |
||
{profileShippingAddress && profileShippingAddress.country} | ||
{profileShippingAddress && profileShippingAddress.postal} | ||
</span> | ||
</div> | ||
</div> | ||
); | ||
|
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 usedprofileShippingAddress.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.