-
Notifications
You must be signed in to change notification settings - Fork 24
add: Passar o segmento via props #1516
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
base: main
Are you sure you want to change the base?
Changes from all commits
ec6a371
0a09fce
e37d3d7
15254dc
159eedf
21cd841
e641b31
bf6170a
de7c1c4
cdd859e
4655342
df6bb11
79614c7
9cc0f29
96df3fb
a4362fc
257837e
f639a01
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 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { getSegmentFromBag } from "../../utils/segment.ts"; | |||||||||||
|
|
||||||||||||
| export interface Props { | ||||||||||||
| paymentSystem: number; | ||||||||||||
| sc?: string; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
|
|
@@ -19,16 +20,25 @@ const action = async ( | |||||||||||
| ctx: AppContext, | ||||||||||||
| ): Promise<InstallmentOption> => { | ||||||||||||
| const { vcsDeprecated } = ctx; | ||||||||||||
| const { paymentSystem } = props; | ||||||||||||
| const { paymentSystem, sc } = props; | ||||||||||||
| const { orderFormId } = parseCookie(req.headers); | ||||||||||||
| const cookie = req.headers.get("cookie") ?? ""; | ||||||||||||
| const segment = getSegmentFromBag(ctx); | ||||||||||||
|
|
||||||||||||
| const response = await vcsDeprecated | ||||||||||||
| ["GET /api/checkout/pub/orderForm/:orderFormId/installments"]( | ||||||||||||
| { orderFormId, paymentSystem, sc: segment?.payload.channel }, | ||||||||||||
| { headers: { accept: "application/json", cookie } }, | ||||||||||||
| ); | ||||||||||||
| const response = await vcsDeprecated[ | ||||||||||||
| "GET /api/checkout/pub/orderForm/:orderFormId/installments" | ||||||||||||
| ]( | ||||||||||||
| { | ||||||||||||
| orderFormId, | ||||||||||||
| paymentSystem, | ||||||||||||
| sc: | ||||||||||||
| sc ? sc : | ||||||||||||
|
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. P2: Using a truthy check for Prompt for AI agents
Suggested change
|
||||||||||||
| (ctx.allowMixedSegments | ||||||||||||
| ? segment?.payload.channel | ||||||||||||
| : ctx.salesChannel) | ||||||||||||
| }, | ||||||||||||
| { headers: { accept: "application/json", cookie } }, | ||||||||||||
| ); | ||||||||||||
|
|
||||||||||||
| proxySetCookie(response.headers, ctx.response.headers, req.url); | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 2284
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 226
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 226
🏁 Script executed:
git ls-files vtex/actions/cart/*.tsRepository: deco-cx/apps
Length of output: 627
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 1796
🏁 Script executed:
rg -n "sc\?" vtex/actions/cart -A1 -B1Repository: deco-cx/apps
Length of output: 365
🏁 Script executed:
rg -n "sc:" vtex/actions/cart -B2 -A2Repository: deco-cx/apps
Length of output: 4285
🏁 Script executed:
cat -n vtex/utils/segment.ts | head -50Repository: deco-cx/apps
Length of output: 1586
🏁 Script executed:
rg -n "interface Segment" vtex/utils/types.ts -A20Repository: deco-cx/apps
Length of output: 778
🏁 Script executed:
rg -n "salesChannel" vtex/mod.ts -B5 -A5Repository: deco-cx/apps
Length of output: 1017
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 994
Align
sctype across cart actions to avoid type inconsistencies.scis typed asstringinaddItems.tsbutsimulation.tsacceptssc?: number. Both fallback tosegment?.payload.channel(which isstring). Standardizing tostring | numberwith explicitString(...)coercion on send would prevent callers from hitting type errors when using similar actions with numeric values.♻️ Suggested normalization
export interface Props { orderItems: Item[]; allowedOutdatedData?: Array<"paymentData">; - sc?: string; + sc?: string | number; } @@ - sc: sc ?? segment?.payload.channel, + sc: sc != null ? String(sc) : segment?.payload.channel,🤖 Prompt for AI Agents