Skip to content

Commit

Permalink
[Refactor] Dont bundle split all of order app
Browse files Browse the repository at this point in the history
  • Loading branch information
damassi committed May 27, 2020
1 parent 4d45870 commit 4b013c5
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 151 deletions.
9 changes: 3 additions & 6 deletions src/v2/Apps/Order/Routes/Accept/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class Accept extends Component<AcceptProps> {
logger.error(error)
switch (error.code) {
case "capture_failed": {
const parsedData = get(error, e => JSON.parse(e.data), {})
const parsedData = get(error, (e) => JSON.parse(e.data), {})

// https://stripe.com/docs/declines/codes
if (parsedData.decline_code === "insufficient_funds") {
Expand Down Expand Up @@ -148,7 +148,7 @@ export class Accept extends Component<AcceptProps> {
artistId() {
return get(
this.props.order,
o => o.lineItems.edges[0].node.artwork.artists[0].slug
(o) => o.lineItems.edges[0].node.artwork.artists[0].slug
)
}

Expand Down Expand Up @@ -221,7 +221,7 @@ export class Accept extends Component<AcceptProps> {
<Flex flexDirection="column">
<Flex flexDirection="column">
<Media greaterThan="xs">
{className => (
{(className) => (
<ArtworkSummaryItem className={className} order={order} />
)}
</Media>
Expand Down Expand Up @@ -288,6 +288,3 @@ export const AcceptFragmentContainer = createFragmentContainer(
`,
}
)

// For bundle splitting in router
export default AcceptFragmentContainer
5 changes: 1 addition & 4 deletions src/v2/Apps/Order/Routes/Counter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class CounterRoute extends Component<CounterProps> {
}
}

@track<CounterProps>(props => ({
@track<CounterProps>((props) => ({
action_type: Schema.ActionType.SubmittedCounterOffer,
order_id: props.order.internalID,
}))
Expand Down Expand Up @@ -248,6 +248,3 @@ export const CounterFragmentContainer = createFragmentContainer(
`,
}
)

// For bundle splitting in router
export default CounterFragmentContainer
11 changes: 4 additions & 7 deletions src/v2/Apps/Order/Routes/NewPayment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
} from "v2/Apps/Order/Utils/commitMutation"
import { get } from "v2/Utils/get"

export const ContinueButton = props => (
export const ContinueButton = (props) => (
<Button size="large" width="100%" {...props}>
Continue
</Button>
Expand All @@ -54,8 +54,8 @@ const logger = createLogger("Order/Routes/NewPayment/index.tsx")

@track()
export class NewPaymentRoute extends Component<
NewPaymentProps,
NewPaymentState
NewPaymentProps,
NewPaymentState
> {
paymentPicker = React.createRef<PaymentPicker>()
state = {
Expand Down Expand Up @@ -295,7 +295,7 @@ NewPaymentState
artistId() {
return get(
this.props.order,
o => o.lineItems.edges[0].node.artwork.artists[0].slug
(o) => o.lineItems.edges[0].node.artwork.artists[0].slug
)
}

Expand Down Expand Up @@ -347,6 +347,3 @@ export const NewPaymentFragmentContainer = createFragmentContainer(
`,
}
)

// For bundle splitting in router
export default NewPaymentFragmentContainer
13 changes: 5 additions & 8 deletions src/v2/Apps/Order/Routes/Offer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class OfferRoute extends Component<OfferProps, OfferState> {
highSpeedBumpEncountered: false,
}

@track<OfferProps>(props => ({
@track<OfferProps>((props) => ({
order_id: props.order.internalID,
action_type: Schema.ActionType.FocusedOnOfferInput,
flow: Schema.Flow.MakeOffer,
Expand All @@ -69,7 +69,7 @@ export class OfferRoute extends Component<OfferProps, OfferState> {
// noop
}

@track<OfferProps>(props => ({
@track<OfferProps>((props) => ({
order_id: props.order.internalID,
action_type: Schema.ActionType.ViewedOfferTooLow,
flow: Schema.Flow.MakeOffer,
Expand All @@ -84,7 +84,7 @@ export class OfferRoute extends Component<OfferProps, OfferState> {
})
}

@track<OfferProps>(props => ({
@track<OfferProps>((props) => ({
order_id: props.order.internalID,
action_type: Schema.ActionType.ViewedOfferHigherThanListPrice,
flow: Schema.Flow.MakeOffer,
Expand Down Expand Up @@ -235,7 +235,7 @@ export class OfferRoute extends Component<OfferProps, OfferState> {
showError={
this.state.formIsDirty && this.state.offerValue <= 0
}
onChange={offerValue => this.setState({ offerValue })}
onChange={(offerValue) => this.setState({ offerValue })}
onFocus={this.onOfferInputFocus.bind(this)}
/>
</Flex>
Expand All @@ -247,7 +247,7 @@ export class OfferRoute extends Component<OfferProps, OfferState> {
<Spacer mb={[2, 3]} />
<RevealButton align="left" buttonLabel="Add note to seller">
<OfferNote
onChange={offerNoteValue =>
onChange={(offerNoteValue) =>
this.setState({ offerNoteValue })
}
artworkId={artworkId}
Expand Down Expand Up @@ -337,6 +337,3 @@ export const OfferFragmentContainer = createFragmentContainer(
`,
}
)

// For bundle splitting in router
export default OfferFragmentContainer
5 changes: 1 addition & 4 deletions src/v2/Apps/Order/Routes/Payment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from "v2/Apps/Order/Utils/commitMutation"
import { AnalyticsSchema, track } from "v2/Artsy"

export const ContinueButton = props => (
export const ContinueButton = (props) => (
<Button size="large" width="100%" {...props}>
Continue
</Button>
Expand Down Expand Up @@ -241,6 +241,3 @@ export const PaymentFragmentContainer = createFragmentContainer(
`,
}
)

// For bundle splitting in router
export default PaymentFragmentContainer
3 changes: 0 additions & 3 deletions src/v2/Apps/Order/Routes/Reject/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,3 @@ export const RejectFragmentContainer = createFragmentContainer(
`,
}
)

// For bundle splitting in router
export default RejectFragmentContainer
13 changes: 5 additions & 8 deletions src/v2/Apps/Order/Routes/Respond/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class RespondRoute extends Component<RespondProps, RespondState> {
highSpeedBumpEncountered: false,
}

@track<RespondProps>(props => ({
@track<RespondProps>((props) => ({
order_id: props.order.internalID,
action_type: Schema.ActionType.FocusedOnOfferInput,
flow: Schema.Flow.MakeOffer,
Expand All @@ -80,7 +80,7 @@ export class RespondRoute extends Component<RespondProps, RespondState> {
// noop
}

@track<RespondProps>(props => ({
@track<RespondProps>((props) => ({
order_id: props.order.internalID,
action_type: Schema.ActionType.ViewedOfferTooLow,
flow: Schema.Flow.MakeOffer,
Expand All @@ -95,7 +95,7 @@ export class RespondRoute extends Component<RespondProps, RespondState> {
})
}

@track<RespondProps>(props => ({
@track<RespondProps>((props) => ({
order_id: props.order.internalID,
action_type: Schema.ActionType.ViewedOfferHigherThanListPrice,
flow: Schema.Flow.MakeOffer,
Expand Down Expand Up @@ -272,7 +272,7 @@ export class RespondRoute extends Component<RespondProps, RespondState> {
showError={
this.state.formIsDirty && this.state.offerValue <= 0
}
onChange={offerValue => this.setState({ offerValue })}
onChange={(offerValue) => this.setState({ offerValue })}
onFocus={this.onOfferInputFocus.bind(this)}
/>
<Spacer mb={0.5} />
Expand All @@ -282,7 +282,7 @@ export class RespondRoute extends Component<RespondProps, RespondState> {
>
<Spacer mb={1} />
<OfferNote
onChange={offerNoteValue =>
onChange={(offerNoteValue) =>
this.setState({ offerNoteValue })
}
artworkId={artworkId}
Expand Down Expand Up @@ -393,6 +393,3 @@ export const RespondFragmentContainer = createFragmentContainer(
`,
}
)

// For bundle splitting in router
export default RespondFragmentContainer
15 changes: 6 additions & 9 deletions src/v2/Apps/Order/Routes/Review/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class ReviewRoute extends Component<ReviewProps, ReviewState> {
}
}

@track<ReviewProps>(props => ({
@track<ReviewProps>((props) => ({
action_type:
props.order.mode === "BUY"
? Schema.ActionType.SubmittedOrder
Expand All @@ -85,7 +85,7 @@ export class ReviewRoute extends Component<ReviewProps, ReviewState> {
this.props.order.mode === "BUY"
? (await this.submitBuyOrder()).commerceSubmitOrder.orderOrError
: (await this.submitOffer(setupIntentId)).commerceSubmitOrderWithOffer
.orderOrError
.orderOrError

if (orderOrError.error) {
this.handleSubmitError(orderOrError.error)
Expand All @@ -97,7 +97,7 @@ export class ReviewRoute extends Component<ReviewProps, ReviewState> {
) {
this.state.stripe
.handleCardAction(orderOrError.actionData.clientSecret)
.then(result => {
.then((result) => {
if (result.error) {
this.props.dialog.showErrorDialog({
title: "An error occurred",
Expand All @@ -115,7 +115,7 @@ export class ReviewRoute extends Component<ReviewProps, ReviewState> {
) {
this.state.stripe
.handleCardSetup(orderOrError.actionData.clientSecret)
.then(result => {
.then((result) => {
if (result.error) {
this.props.dialog.showErrorDialog({
title: "An error occurred",
Expand Down Expand Up @@ -289,14 +289,14 @@ export class ReviewRoute extends Component<ReviewProps, ReviewState> {
artistId() {
return get(
this.props.order,
o => o.lineItems.edges[0].node.artwork.artists[0].slug
(o) => o.lineItems.edges[0].node.artwork.artists[0].slug
)
}

routeToArtworkPage() {
const artworkId = get(
this.props.order,
o => o.lineItems.edges[0].node.artwork.slug
(o) => o.lineItems.edges[0].node.artwork.slug
)
// Don't confirm whether or not you want to leave the page
this.props.route.onTransition = () => null
Expand Down Expand Up @@ -448,6 +448,3 @@ export const ReviewFragmentContainer = createFragmentContainer(
`,
}
)

// For bundle splitting in router
export default ReviewFragmentContainer
18 changes: 8 additions & 10 deletions src/v2/Apps/Order/Routes/Shipping/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ const logger = createLogger("Order/Routes/Shipping/index.tsx")
export class ShippingRoute extends Component<ShippingProps, ShippingState> {
state: ShippingState = {
shippingOption: (this.props.order.requestedFulfillment &&
this.props.order.requestedFulfillment.__typename !== "CommerceShip"
this.props.order.requestedFulfillment.__typename !== "CommerceShip"
? "PICKUP"
: "SHIP") as CommerceOrderFulfillmentTypeEnum,
address: this.startingAddress,
addressErrors: {},
addressTouched: {},
phoneNumber:
this.props.order.requestedFulfillment &&
(this.props.order.requestedFulfillment.__typename === "CommerceShip" ||
this.props.order.requestedFulfillment.__typename === "CommercePickup")
(this.props.order.requestedFulfillment.__typename === "CommerceShip" ||
this.props.order.requestedFulfillment.__typename === "CommercePickup")
? this.props.order.requestedFulfillment.phoneNumber
: "",
phoneNumberError: "",
Expand Down Expand Up @@ -231,7 +231,7 @@ export class ShippingRoute extends Component<ShippingProps, ShippingState> {

handleSubmitError(error: { code: string; data: string }) {
logger.error(error)
const parsedData = get(error, e => JSON.parse(e.data), {})
const parsedData = get(error, (e) => JSON.parse(e.data), {})
if (
error.code === "missing_region" ||
error.code === "missing_country" ||
Expand Down Expand Up @@ -267,7 +267,8 @@ export class ShippingRoute extends Component<ShippingProps, ShippingState> {
country: validatePresence(country),
postalCode: usOrCanada && validatePresence(postalCode),
}
const hasErrors = Object.keys(errors).filter(key => errors[key]).length > 0
const hasErrors =
Object.keys(errors).filter((key) => errors[key]).length > 0

return {
errors,
Expand Down Expand Up @@ -300,7 +301,7 @@ export class ShippingRoute extends Component<ShippingProps, ShippingState> {
})
}

onPhoneNumberChange: PhoneNumberChangeHandler = phoneNumber => {
onPhoneNumberChange: PhoneNumberChangeHandler = (phoneNumber) => {
const { error } = this.validatePhoneNumber(phoneNumber)
this.setState({
phoneNumber,
Expand Down Expand Up @@ -334,7 +335,7 @@ export class ShippingRoute extends Component<ShippingProps, ShippingState> {
} = this.state
const artwork = get(
this.props,
props => props.order.lineItems.edges[0].node.artwork
(props) => props.order.lineItems.edges[0].node.artwork
)

return (
Expand Down Expand Up @@ -508,6 +509,3 @@ export const ShippingFragmentContainer = createFragmentContainer(
`,
}
)

// For bundle splitting in router
export default ShippingFragmentContainer
Loading

0 comments on commit 4b013c5

Please sign in to comment.