Skip to content

Commit 4e58ecc

Browse files
committed
fix(checkout): dont make redundant awaited unleash call
1 parent 950a2a6 commit 4e58ecc

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

src/Apps/Order2/order2Routes.tsx

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import loadable from "@loadable/component"
2-
import { newCheckoutEnabled } from "Apps/Order/redirects"
32
import { OrderErrorApp } from "Apps/Order2/Components/Order2ErrorApp"
4-
import type { SystemContextProps } from "System/Contexts/SystemContext"
53
import type { RouteProps } from "System/Router/Route"
64
import createLogger from "Utils/logger"
75
import type { order2Routes_CheckoutQuery$data } from "__generated__/order2Routes_CheckoutQuery.graphql"
86
import { NOT_FOUND_ERROR } from "Apps/Order2/constants"
9-
import { type Match, RedirectException } from "found"
7+
import { RedirectException } from "found"
108
import { graphql } from "react-relay"
119

1210
const logger = createLogger("order2Routes.tsx")
@@ -63,12 +61,9 @@ export const order2Routes: RouteProps[] = [
6361
}
6462
const typedProps = props as unknown as {
6563
viewer: order2Routes_CheckoutQuery$data["viewer"]
66-
match: Match<SystemContextProps>
6764
}
68-
const { viewer, match } = typedProps
65+
const { viewer } = typedProps
6966
const order = viewer?.me?.order
70-
const featureFlags = match.context.featureFlags
71-
7267
if (!order) {
7368
logger.warn("No order found - checkout page")
7469
return <OrderErrorApp code={404} message={NOT_FOUND_ERROR} />
@@ -79,19 +74,6 @@ export const order2Routes: RouteProps[] = [
7974
throw new RedirectException(redirectUrl)
8075
}
8176

82-
if (!newCheckoutEnabled({ order, featureFlags })) {
83-
const redirectUrl =
84-
order.mode === "OFFER"
85-
? `/orders/${order.internalID}/offer`
86-
: `/orders/${order.internalID}/shipping`
87-
if (process.env.NODE_ENV === "development") {
88-
console.error(
89-
`Redirecting from to ${redirectUrl} because Order2 checkout is not enabled for this order`,
90-
)
91-
}
92-
throw new RedirectException(redirectUrl)
93-
}
94-
9577
return <Component viewer={viewer} />
9678
},
9779
},
@@ -122,11 +104,9 @@ export const order2Routes: RouteProps[] = [
122104
}
123105
const typedProps = props as unknown as {
124106
viewer: order2Routes_CheckoutQuery$data["viewer"]
125-
match: Match<SystemContextProps>
126107
}
127-
const { viewer, match } = typedProps
108+
const { viewer } = typedProps
128109
const order = viewer?.me?.order
129-
const featureFlags = match.context.featureFlags
130110

131111
if (!order) {
132112
logger.warn("No order found - offer page")
@@ -144,16 +124,6 @@ export const order2Routes: RouteProps[] = [
144124
throw new RedirectException(redirectUrl)
145125
}
146126

147-
if (!newCheckoutEnabled({ order, featureFlags })) {
148-
const redirectUrl = `/orders/${order.internalID}/offer`
149-
if (process.env.NODE_ENV === "development") {
150-
console.error(
151-
`Redirecting from to ${redirectUrl} because Order2 checkout is not enabled for this order`,
152-
)
153-
}
154-
throw new RedirectException(redirectUrl)
155-
}
156-
157127
return <Component viewer={viewer} />
158128
},
159129
},

0 commit comments

Comments
 (0)