@faststore/api 3.95.0 → 3.96.0-dev.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/package.json +9 -2
- package/dist/cjs/src/__generated__/schema.d.ts +3 -0
- package/dist/cjs/src/__generated__/schema.d.ts.map +1 -1
- package/dist/cjs/src/__generated__/schema.js.map +1 -1
- package/dist/cjs/src/directives/cacheControl.d.ts +1 -1
- package/dist/cjs/src/directives/cacheControl.d.ts.map +1 -1
- package/dist/cjs/src/directives/cacheControl.js +5 -1
- package/dist/cjs/src/directives/cacheControl.js.map +1 -1
- package/dist/cjs/src/platforms/vtex/resolvers/userOrder.d.ts +5 -0
- package/dist/cjs/src/platforms/vtex/resolvers/userOrder.d.ts.map +1 -1
- package/dist/cjs/src/platforms/vtex/resolvers/userOrder.js +19 -2
- package/dist/cjs/src/platforms/vtex/resolvers/userOrder.js.map +1 -1
- package/dist/cjs/src/typeDefs/userOrder.graphql +3 -0
- package/dist/esm/package.json +9 -2
- package/dist/esm/src/__generated__/schema.d.ts +3 -0
- package/dist/esm/src/__generated__/schema.d.ts.map +1 -1
- package/dist/esm/src/__generated__/schema.js.map +1 -1
- package/dist/esm/src/directives/cacheControl.d.ts +1 -1
- package/dist/esm/src/directives/cacheControl.d.ts.map +1 -1
- package/dist/esm/src/directives/cacheControl.js +5 -1
- package/dist/esm/src/directives/cacheControl.js.map +1 -1
- package/dist/esm/src/platforms/vtex/resolvers/userOrder.d.ts +5 -0
- package/dist/esm/src/platforms/vtex/resolvers/userOrder.d.ts.map +1 -1
- package/dist/esm/src/platforms/vtex/resolvers/userOrder.js +17 -1
- package/dist/esm/src/platforms/vtex/resolvers/userOrder.js.map +1 -1
- package/dist/esm/src/typeDefs/userOrder.graphql +3 -0
- package/package.json +10 -3
- package/src/__generated__/schema.ts +3 -0
- package/src/directives/cacheControl.ts +12 -6
- package/src/platforms/vtex/resolvers/userOrder.ts +30 -1
- package/src/typeDefs/userOrder.graphql +3 -0
|
@@ -2039,7 +2039,10 @@ export type UserOrderDeliveryOptionsItems = {
|
|
|
2039
2039
|
name?: Maybe<Scalars['String']>;
|
|
2040
2040
|
price?: Maybe<Scalars['Float']>;
|
|
2041
2041
|
quantity?: Maybe<Scalars['Int']>;
|
|
2042
|
+
sellingPrice?: Maybe<Scalars['Float']>;
|
|
2042
2043
|
tax?: Maybe<Scalars['Float']>;
|
|
2044
|
+
taxPriceTags?: Maybe<Array<Maybe<UserOrderPriceTag>>>;
|
|
2045
|
+
taxPriceTagsTotal?: Maybe<Scalars['Float']>;
|
|
2043
2046
|
total?: Maybe<Scalars['Float']>;
|
|
2044
2047
|
uniqueId?: Maybe<Scalars['String']>;
|
|
2045
2048
|
};
|
|
@@ -11,12 +11,18 @@ export interface CacheControl {
|
|
|
11
11
|
scope?: string
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const stringify = (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
export const stringify = (
|
|
15
|
+
cacheControl: CacheControl,
|
|
16
|
+
forcePrivate?: boolean
|
|
17
|
+
): string => {
|
|
18
|
+
const {
|
|
19
|
+
scope = 'private',
|
|
20
|
+
sMaxAge = 0,
|
|
21
|
+
staleWhileRevalidate = 0,
|
|
22
|
+
} = cacheControl
|
|
23
|
+
const finalScope = forcePrivate ? 'private' : scope
|
|
24
|
+
return `${finalScope}, s-maxage=${sMaxAge}, stale-while-revalidate=${staleWhileRevalidate}`
|
|
25
|
+
}
|
|
20
26
|
|
|
21
27
|
const min = (a: number | undefined, b: number | undefined) => {
|
|
22
28
|
if (typeof a === 'number' && typeof b === 'number') {
|
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
Maybe,
|
|
4
4
|
UserOrderCustomField,
|
|
5
5
|
UserOrderDeliveryOption,
|
|
6
|
+
UserOrderPriceTag,
|
|
6
7
|
} from '../../..'
|
|
7
8
|
import type { PromiseType } from '../../../typings'
|
|
8
9
|
import type { Query } from './query'
|
|
@@ -59,8 +60,14 @@ export const UserOrderResult: Record<string, Resolver<Root>> = {
|
|
|
59
60
|
`${deliveryChannelsMapping[deliveryChannel as keyof typeof deliveryChannelsMapping] || ''} ${friendlyShippingEstimate} ${address?.neighborhood ? `to ${address?.neighborhood}` : ''}`.trim()
|
|
60
61
|
|
|
61
62
|
// TODO check other totals like bundleItems etc
|
|
63
|
+
const { taxPriceTagsTotal, taxPriceTags } = filterTaxPriceTags(
|
|
64
|
+
(item?.priceTags ?? []) as UserOrderPriceTag[]
|
|
65
|
+
)
|
|
66
|
+
|
|
62
67
|
const itemTotal =
|
|
63
|
-
(item?.sellingPrice ?? 0) * (item?.quantity ?? 0) +
|
|
68
|
+
(item?.sellingPrice ?? 0) * (item?.quantity ?? 0) +
|
|
69
|
+
(item?.tax ?? 0) +
|
|
70
|
+
(taxPriceTagsTotal ?? 0)
|
|
64
71
|
|
|
65
72
|
if (!acc[groupKey]) {
|
|
66
73
|
acc[groupKey] = {
|
|
@@ -90,7 +97,10 @@ export const UserOrderResult: Record<string, Resolver<Root>> = {
|
|
|
90
97
|
name: item?.name || '',
|
|
91
98
|
quantity: item?.quantity || 0,
|
|
92
99
|
price: item?.price || 0,
|
|
100
|
+
sellingPrice: item?.sellingPrice || 0,
|
|
93
101
|
imageUrl: item?.imageUrl || '',
|
|
102
|
+
taxPriceTags: taxPriceTags ?? [],
|
|
103
|
+
taxPriceTagsTotal: taxPriceTagsTotal ?? 0,
|
|
94
104
|
tax: item?.tax || 0,
|
|
95
105
|
total: itemTotal,
|
|
96
106
|
})
|
|
@@ -205,3 +215,22 @@ export const UserOrderResult: Record<string, Resolver<Root>> = {
|
|
|
205
215
|
// ]
|
|
206
216
|
},
|
|
207
217
|
}
|
|
218
|
+
|
|
219
|
+
// logic copied from https://github.com/vtex/my-orders/blob/3271bdd4216851fb21b64093769d73183868e362/react/components/Order/ChangeSummary/ChangeV2/shared/filterPriceTags.js#L59-L60
|
|
220
|
+
export function filterTaxPriceTags(priceTags: UserOrderPriceTag[]) {
|
|
221
|
+
const multiplier = 100
|
|
222
|
+
|
|
223
|
+
const taxPriceTags = priceTags.filter((priceTag) =>
|
|
224
|
+
priceTag?.name?.includes('TAX')
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
const taxPriceTagsTotal = taxPriceTags.reduce(
|
|
228
|
+
(acc, curr) => acc + (curr.rawValue ? curr.rawValue * multiplier : 0),
|
|
229
|
+
0
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
taxPriceTags,
|
|
234
|
+
taxPriceTagsTotal,
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -682,8 +682,11 @@ type UserOrderDeliveryOptionsItems {
|
|
|
682
682
|
name: String
|
|
683
683
|
quantity: Int
|
|
684
684
|
price: Float
|
|
685
|
+
sellingPrice: Float
|
|
685
686
|
imageUrl: String
|
|
686
687
|
tax: Float
|
|
688
|
+
taxPriceTags: [UserOrderPriceTag]
|
|
689
|
+
taxPriceTagsTotal: Float
|
|
687
690
|
total: Float
|
|
688
691
|
}
|
|
689
692
|
|