@jetshop/core 6.2.0-alpha.d01f0565 → 6.2.0-alpha.d3139588
Sign up to get free protection for your applications and to get access to all the features.
- package/cart/AddToCartFormik.d.ts +1 -1
- package/cart/AddToCartFormik.js +13 -11
- package/cart/AddToCartFormik.js.map +1 -1
- package/components/AuthContext/AuthProvider.js +1 -2
- package/components/AuthContext/AuthProvider.js.map +1 -1
- package/components/Cart/CartIdContext.js +1 -2
- package/components/Cart/CartIdContext.js.map +1 -1
- package/components/Mutation/AddToCart/addToCartUtils.d.ts +1 -3
- package/components/Mutation/AddToCart/addToCartUtils.js +1 -8
- package/components/Mutation/AddToCart/addToCartUtils.js.map +1 -1
- package/components/Mutation/AddToCartFormik.js +11 -2
- package/components/Mutation/AddToCartFormik.js.map +1 -1
- package/components/Mutation/cartMutationUtils.d.ts +1 -1
- package/components/Mutation/cartMutationUtils.js +1 -4
- package/components/Mutation/cartMutationUtils.js.map +1 -1
- package/components/Mutation/useDecrementQuantity.js +9 -13
- package/components/Mutation/useDecrementQuantity.js.map +1 -1
- package/components/Mutation/useIncrementQuantity.js +9 -13
- package/components/Mutation/useIncrementQuantity.js.map +1 -1
- package/components/Mutation/useRemoveFromCart.js +9 -0
- package/components/Mutation/useRemoveFromCart.js.map +1 -1
- package/components/Query/CartProvider.js +4 -4
- package/components/Query/CartProvider.js.map +1 -1
- package/hooks/useAddMultipleToCart.js +4 -5
- package/hooks/useAddMultipleToCart.js.map +1 -1
- package/package.json +1 -1
@@ -38,5 +38,5 @@ interface AddToCartFormikProps {
|
|
38
38
|
}) => void;
|
39
39
|
children: (props: FormikProps<AddToCartFormikValues>) => React.ReactNode;
|
40
40
|
}
|
41
|
-
export declare function AddToCartFormik({ product, variant, commentValidators, getMissingOptions, initialValues, onAddToCartInit, onAddToCartError, onAddToCartSuccess,
|
41
|
+
export declare function AddToCartFormik({ product, variant, commentValidators, getMissingOptions, initialValues, onAddToCartInit, onAddToCartError, onAddToCartSuccess, cartMutation, children }: AddToCartFormikProps): React.JSX.Element;
|
42
42
|
export default AddToCartFormik;
|
package/cart/AddToCartFormik.js
CHANGED
@@ -10,17 +10,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
import React from 'react';
|
11
11
|
import { useAddToCart } from './useAddToCart';
|
12
12
|
import { FormikProvider } from 'formik';
|
13
|
-
import {
|
13
|
+
import { useMutation } from '@apollo/client';
|
14
14
|
import { addToCartError, addToCartSuccess, useTrackProductAdd } from '../components/Mutation/AddToCart/addToCartUtils';
|
15
15
|
import uniqueId from '@jetshop/core/helpers/uniqueId';
|
16
|
-
import { getAddToCartOptimisticResponse } from '../components/Mutation/cartMutationUtils';
|
17
16
|
import { useCartId } from '../components/Cart/CartIdContext';
|
18
17
|
export function AddToCartFormik({ product, variant, commentValidators = {}, getMissingOptions, initialValues,
|
19
18
|
// Apollo specific props
|
20
|
-
onAddToCartInit, onAddToCartError, onAddToCartSuccess,
|
19
|
+
onAddToCartInit, onAddToCartError, onAddToCartSuccess, cartMutation,
|
21
20
|
// Backwards compatability with render props
|
22
21
|
children }) {
|
23
|
-
|
22
|
+
// tslint:disable-next-line:no-unused
|
24
23
|
const [addToCartMutation] = useMutation(cartMutation, {
|
25
24
|
onCompleted: () => localStorage.setItem('cartChange', '1')
|
26
25
|
});
|
@@ -44,19 +43,22 @@ children }) {
|
|
44
43
|
variables: {
|
45
44
|
input
|
46
45
|
},
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
update: (cache, { data }) => {
|
47
|
+
cache.modify({
|
48
|
+
fields: {
|
49
|
+
cart() {
|
50
|
+
var _a;
|
51
|
+
return (_a = data === null || data === void 0 ? void 0 : data.addToCart) === null || _a === void 0 ? void 0 : _a.cart;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
});
|
52
55
|
}
|
53
56
|
})
|
54
57
|
.then(addToCartSuccess({
|
55
58
|
onAddToCartSuccess,
|
56
59
|
callbackOptions,
|
57
60
|
cartId,
|
58
|
-
setCartId
|
59
|
-
client
|
61
|
+
setCartId
|
60
62
|
}))
|
61
63
|
.catch(addToCartError({
|
62
64
|
onAddToCartError,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AddToCartFormik.js","sourceRoot":"","sources":["AddToCartFormik.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAmB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAe,MAAM,QAAQ,CAAC;AAWrD,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"AddToCartFormik.js","sourceRoot":"","sources":["AddToCartFormik.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAmB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAe,MAAM,QAAQ,CAAC;AAWrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,iDAAiD,CAAC;AACzD,OAAO,QAAQ,MAAM,gCAAgC,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AA6C7D,MAAM,UAAU,eAAe,CAAC,EAC9B,OAAO,EACP,OAAO,EACP,iBAAiB,GAAG,EAAE,EACtB,iBAAiB,EACjB,aAAa;AACb,wBAAwB;AACxB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,YAAY;AACZ,4CAA4C;AAC5C,QAAQ,EACa;IACrB,qCAAqC;IACrC,MAAM,CAAC,iBAAiB,CAAC,GAAG,WAAW,CAGrC,YAAY,EAAE;QACd,WAAW,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC;KAC3D,CAAC,CAAC;IAEH,MAAM,EAAE,MAAM,EAAE,SAAS,EAA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WAAW,CAAC,QAAQ,kBAAC,KAAK,EAAE,KAAK,IAAM,KAAK,EAAI,CAAC;AAC3D,CAAC,CAAC;AAEF,SAAS,uBAAuB,CAAC,WAAgB;IAC/C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,QAAQ,GAAG,CAAC,CAAe,EAAE,EAAE;YACnC,MAAM,oBAAoB,GAAG,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAC9D,IAAI,CAAC,CAAC,WAAW,KAAK,YAAY,IAAI,CAAC,CAAC,GAAG,KAAK,UAAU,EAAE;gBAC1D,WAAW,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC;aACrC;QACH,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAE7C,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,eAAe,WAAW,CAAC,YAAY,CAAC,CAAC"}
|
@@ -38,8 +38,7 @@ const CartIdProvider = function CartIdProvider(props) {
|
|
38
38
|
localStorage.setItem('cartId', cartId);
|
39
39
|
}
|
40
40
|
else {
|
41
|
-
|
42
|
-
// localStorage.removeItem('cartId');
|
41
|
+
localStorage.removeItem('cartId');
|
43
42
|
}
|
44
43
|
}
|
45
44
|
catch (e) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CartIdContext.js","sourceRoot":"","sources":["CartIdContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExE,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAGtC;IACD,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS;CAC3B,CAAC,CAAC;AAEH,MAAM,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G,QAAQ,CAAC,eAAe,CAAC,CAAC;IAEtD,+BAA+B;IAC/B,kBAAkB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,eAAe;YAAE,OAAO;QAE/D,IAAI;YACF,IAAI,MAAM,EAAE;gBACV,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;aACxC;iBAAM;gBACL,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;aACnC;SACF;QAAC,OAAO,CAAC,EAAE;YACV,mBAAmB;YACnB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAChB;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;IAE9B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE;QACzB,OAAO;YACL,MAAM;YACN,SAAS;SACV,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,oBAAC,aAAa,CAAC,QAAQ,kBAAC,KAAK,EAAE,KAAK,IAAM,KAAK,EAAI,CAAC;AAC7D,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAEzC,MAAM,UAAU,SAAS;IACvB,OAAO,UAAU,CAAC,aAAa,CAAC,CAAC;AACnC,CAAC"}
|
@@ -1,18 +1,16 @@
|
|
1
1
|
import { Product, ProductVariant } from '../../../types';
|
2
2
|
import { AddToCartFormikValues, AddToCartFormProps, AddToCartCallbackOptions } from '../AddToCartFormik';
|
3
|
-
import { ApolloClient } from '@apollo/client';
|
4
3
|
export declare function getArticleNumber(product: Product, selectedVariation: ProductVariant): string;
|
5
4
|
export declare function useTrackProductAdd(selectedVariation: ProductVariant): (product: Product, quantity: number) => void;
|
6
5
|
export declare function getCommentsFromFormikValues(values: AddToCartFormikValues): {
|
7
6
|
name: string;
|
8
7
|
value: string;
|
9
8
|
}[];
|
10
|
-
export declare function addToCartSuccess({ onAddToCartSuccess, callbackOptions, cartId, setCartId
|
9
|
+
export declare function addToCartSuccess({ onAddToCartSuccess, callbackOptions, cartId, setCartId }: {
|
11
10
|
onAddToCartSuccess?: AddToCartFormProps['onAddToCartSuccess'];
|
12
11
|
callbackOptions?: AddToCartCallbackOptions;
|
13
12
|
cartId: string;
|
14
13
|
setCartId: (cartId: string) => void;
|
15
|
-
client: ApolloClient<any>;
|
16
14
|
}): ({ data }: any) => void;
|
17
15
|
export declare function addToCartError({ onAddToCartError, callbackOptions }: {
|
18
16
|
onAddToCartError: AddToCartFormProps['onAddToCartError'];
|
@@ -32,18 +32,11 @@ export function getCommentsFromFormikValues(values) {
|
|
32
32
|
};
|
33
33
|
});
|
34
34
|
}
|
35
|
-
export function addToCartSuccess({ onAddToCartSuccess, callbackOptions, cartId, setCartId
|
35
|
+
export function addToCartSuccess({ onAddToCartSuccess, callbackOptions, cartId, setCartId }) {
|
36
36
|
return ({ data }) => {
|
37
37
|
if (!cartId || data.addToCart.cart.id !== cartId) {
|
38
38
|
data.addToCart && setCartId(data.addToCart.cart.id);
|
39
39
|
}
|
40
|
-
if (cartId) {
|
41
|
-
// When logged in, we always have a cartId,
|
42
|
-
// so we need to refetch it on the first item add, since we cannot update the local cache using it's ID
|
43
|
-
client.refetchQueries({
|
44
|
-
include: ['CartQuery']
|
45
|
-
});
|
46
|
-
}
|
47
40
|
onAddToCartSuccess && onAddToCartSuccess(callbackOptions);
|
48
41
|
};
|
49
42
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"addToCartUtils.js","sourceRoot":"","sources":["addToCartUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAMrE,OAA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KAAK,CAAC,CAC3B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,MAA6B;IACvE,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC/C,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;SAC7B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAC/B,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,SAAS,EAMV;IACC,OAAO,CAAC,EAAE,IAAI,EAAO,EAAE,EAAE;QACvB,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,EAAE;YAChD,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACrD;QACD,kBAAkB,IAAI,kBAAkB,CAAC,eAAe,CAAC,CAAC;IAC5D,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAC7B,gBAAgB,EAChB,eAAe,EAIhB;IACC,OAAO,CAAC,KAAU,EAAE,EAAE;QACpB,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC,gBAAgB,EAAE;YACrB,MAAM,KAAK,CAAC;SACb;QACD,gBAAgB,iCAAM,eAAe,KAAE,KAAK,IAAG,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC"}
|
@@ -63,14 +63,23 @@ const useAddToCart = ({ articleNumber, cartMutation, cartQuery, onAddToCartInit,
|
|
63
63
|
cart: getAddToCartOptimisticResponse(product, values.quantity, cartId, client, cartQuery),
|
64
64
|
__typename: 'CartMutation'
|
65
65
|
}
|
66
|
+
},
|
67
|
+
update: (cache, { data }) => {
|
68
|
+
cache.modify({
|
69
|
+
fields: {
|
70
|
+
cart() {
|
71
|
+
var _a;
|
72
|
+
return (_a = data === null || data === void 0 ? void 0 : data.addToCart) === null || _a === void 0 ? void 0 : _a.cart;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
});
|
66
76
|
}
|
67
77
|
})
|
68
78
|
.then(addToCartSuccess({
|
69
79
|
onAddToCartSuccess,
|
70
80
|
callbackOptions,
|
71
81
|
cartId,
|
72
|
-
setCartId
|
73
|
-
client
|
82
|
+
setCartId
|
74
83
|
}))
|
75
84
|
.catch(addToCartError({ onAddToCartError, callbackOptions }));
|
76
85
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AddToCartFormik.js","sourceRoot":"","sources":["AddToCartFormik.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,EAA6B,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,8BAA8B,EAAE,MAAM,qDAAqD,CAAC;AACrG,OAAO,CAAC,MAAM,eAAe,CAAC;AAC9B,OAAO,QAAQ,MAAM,gCAAgC,CAAC;AAGtD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAQ5D,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,2BAA2B,MAAM,6DAA6D,CAAC;AAuDtG,MAAM,YAAY,GAAG,CAAC,EACpB,aAAa,EACb,YAAY,EACZ,SAAS,EACT,eAAe,EACf,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,CAAC"}
|
@@ -18,7 +18,7 @@ interface OptimisticResponseProps {
|
|
18
18
|
}
|
19
19
|
export declare const getDecrementQuantityOptimisticResponse: ({ itemId, client, cartId, cartQuery }: OptimisticResponseProps) => any;
|
20
20
|
export declare const getIncrementQuantityOptimisticResponse: ({ itemId, client, cartId, cartQuery }: OptimisticResponseProps) => any;
|
21
|
-
export declare const getRemoveFromCartOptimisticResponse: ({ itemId, client, cartId,
|
21
|
+
export declare const getRemoveFromCartOptimisticResponse: ({ itemId, client, cartId, cartQuery }: OptimisticResponseProps & {
|
22
22
|
setCartId: React.Dispatch<string>;
|
23
23
|
}) => any;
|
24
24
|
export declare const getSetQuantityOptimisticResponse: ({ itemId, quantity, client, cartId, cartQuery }: OptimisticResponseProps & {
|
@@ -83,16 +83,13 @@ export const getIncrementQuantityOptimisticResponse = ({ itemId, client, cartId,
|
|
83
83
|
const optimisticCart = Object.assign(Object.assign({}, cart), { items, __optimistic: true });
|
84
84
|
return optimisticCart;
|
85
85
|
};
|
86
|
-
export const getRemoveFromCartOptimisticResponse = ({ itemId, client, cartId,
|
86
|
+
export const getRemoveFromCartOptimisticResponse = ({ itemId, client, cartId, cartQuery }) => {
|
87
87
|
throwErrorInDev(!cartQuery, `You forgot to pass 'cartQuery' to getRemoveFromCartOptimisticResponse`);
|
88
88
|
const { cart } = client.readQuery({
|
89
89
|
query: cartQuery,
|
90
90
|
variables: { cartId }
|
91
91
|
});
|
92
92
|
const items = cart.items.filter((item) => item.id !== itemId);
|
93
|
-
if (items.length === 0) {
|
94
|
-
setCartId(null);
|
95
|
-
}
|
96
93
|
const optimisticCart = Object.assign(Object.assign({}, cart), { items, __optimistic: true });
|
97
94
|
return optimisticCart;
|
98
95
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cartMutationUtils.js","sourceRoot":"","sources":["cartMutationUtils.ts"],"names":[],"mappings":"AAIA,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAS5D,MAAM,CAAC,MAAM,Y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,QAAQ,EACR,MAAM,EACN,MAAM,EACN,SAAS,EACsC,EAAE,EAAE;IACnD,eAAe,CACb,CAAC,SAAS,EACV,oEAAoE,CACrE,CAAC;IAEF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC;QAChC,KAAK,EAAE,SAAS;QAChB,SAAS,EAAE,EAAE,MAAM,EAAE;KACtB,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAc,EAAE,EAAE,CAC9C,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,iCAAM,IAAI,KAAE,QAAQ,IAAG,CAAC,CAAC,IAAI,CAClD,CAAC;IACF,MAAM,cAAc,mCACf,IAAI,KACP,KAAK,EACL,YAAY,EAAE,IAAI,GACnB,CAAC;IACF,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import { useMutation
|
1
|
+
import { useMutation } from '@apollo/client';
|
2
2
|
import { CartIdContext } from '../Cart/CartIdContext';
|
3
|
-
import { getDecrementQuantityOptimisticResponse } from './cartMutationUtils';
|
4
3
|
import { useContext } from 'react';
|
5
4
|
import throwErrorInDev from '../../helpers/throwErrorInDev';
|
6
5
|
import { useTracker } from '../../analytics/Analytics';
|
@@ -13,7 +12,6 @@ export default function useDecrementQuantity({ decrementQuantityMutation, cartQu
|
|
13
12
|
const track = useTracker();
|
14
13
|
const { cart } = useCart(cartQuery);
|
15
14
|
const { cartId } = useContext(CartIdContext);
|
16
|
-
const client = useApolloClient();
|
17
15
|
const [decrementQuantityMutationFn] = useMutation(decrementQuantityMutation, {
|
18
16
|
onCompleted: () => localStorage.setItem('cartChange', '1')
|
19
17
|
});
|
@@ -36,16 +34,14 @@ export default function useDecrementQuantity({ decrementQuantityMutation, cartQu
|
|
36
34
|
itemId
|
37
35
|
}
|
38
36
|
},
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
__typename: 'CartMutation'
|
48
|
-
}
|
37
|
+
update: (cache, { data }) => {
|
38
|
+
cache.modify({
|
39
|
+
fields: {
|
40
|
+
cart() {
|
41
|
+
return data === null || data === void 0 ? void 0 : data.decrementItemQuantity.cart;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
});
|
49
45
|
}
|
50
46
|
});
|
51
47
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDecrementQuantity.js","sourceRoot":"","sources":["useDecrementQuantity.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,
|
1
|
+
{"version":3,"file":"useDecrementQuantity.js","sourceRoot":"","sources":["useDecrementQuantity.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,gDAAgD,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,yDAAyD,CAAC;AAMpG,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,yBAAyB,EACzB,SAAS,EACc;IACvB,eAAe,CACb,CAAC,SAAS,EACV,wDAAwD,CACzD,CAAC;IACF,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;IAC3B,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,aAAa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'@apollo/client';
|
2
2
|
import { CartIdContext } from '../Cart/CartIdContext';
|
3
|
-
import { getIncrementQuantityOptimisticResponse } from './cartMutationUtils';
|
4
3
|
import { useContext } from 'react';
|
5
4
|
import throwErrorInDev from '../../helpers/throwErrorInDev';
|
6
5
|
import { useTracker } from '../../analytics/Analytics';
|
@@ -13,7 +12,6 @@ export default function useIncrementQuantity({ incrementQuantityMutation, cartQu
|
|
13
12
|
const track = useTracker();
|
14
13
|
const { cart } = useCart(cartQuery);
|
15
14
|
const { cartId } = useContext(CartIdContext);
|
16
|
-
const client = useApolloClient();
|
17
15
|
const [incrementQuantityMutationFn] = useMutation(incrementQuantityMutation, {
|
18
16
|
onCompleted: () => localStorage.setItem('cartChange', '1')
|
19
17
|
});
|
@@ -36,16 +34,14 @@ export default function useIncrementQuantity({ incrementQuantityMutation, cartQu
|
|
36
34
|
itemId
|
37
35
|
}
|
38
36
|
},
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
__typename: 'CartMutation'
|
48
|
-
}
|
37
|
+
update: (cache, { data }) => {
|
38
|
+
cache.modify({
|
39
|
+
fields: {
|
40
|
+
cart() {
|
41
|
+
return data === null || data === void 0 ? void 0 : data.incrementItemQuantity.cart;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
});
|
49
45
|
}
|
50
46
|
});
|
51
47
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useIncrementQuantity.js","sourceRoot":"","sources":["useIncrementQuantity.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,
|
1
|
+
{"version":3,"file":"useIncrementQuantity.js","sourceRoot":"","sources":["useIncrementQuantity.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM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SAAS,CAAC,MAAA,MAAA,OAAO,CAAC,iBAAiB,0CAAE,YAAY,0CAAE,IAAI,CAAC;gBACxD,EAAE;SACL,CAAC,CACH,CAAC;QACF,OAAO,2BAA2B,CAAC;YACjC,SAAS,EAAE;gBACT,KAAK,EAAE;oBACL,MAAM;oBACN,MAAM;iBACP;aACF;YACD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;gBAC1B,KAAK,CAAC,MAAM,CAAC;oBACX,MAAM,EAAE;wBACN,IAAI;4BACF,OAAO,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,qBAAqB,CAAC,IAAI,CAAC;wBAC1C,CAAC;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC/B,CAAC"}
|
@@ -42,6 +42,15 @@ export default function useRemoveFromCart({ removeFromCartMutation, cartQuery })
|
|
42
42
|
}),
|
43
43
|
__typename: 'CartMutation'
|
44
44
|
}
|
45
|
+
},
|
46
|
+
update: (cache, { data }) => {
|
47
|
+
cache.modify({
|
48
|
+
fields: {
|
49
|
+
cart() {
|
50
|
+
return data === null || data === void 0 ? void 0 : data.removeFromCart.cart;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
});
|
45
54
|
}
|
46
55
|
});
|
47
56
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useRemoveFromCart.js","sourceRoot":"","sources":["useRemoveFromCart.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,mCAAmC,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;A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;YACP,QAAQ,EACN,yBAAyB,CAAC,MAAA,OAAO,CAAC,YAAY,0CAAE,WAAW,CAAC;gBAC5D,SAAS,CAAC,MAAA,MAAA,OAAO,CAAC,iBAAiB,0CAAE,YAAY,0CAAE,IAAI,CAAC;gBACxD,EAAE;SACL,CAAC,CACH,CAAC;QACF,OAAO,wBAAwB,CAAC;YAC9B,SAAS,EAAE;gBACT,KAAK,EAAE;oBACL,MAAM;oBACN,MAAM;iBACP;aACF;YACD,kBAAkB,EAAE;gBAClB,cAAc,EAAE;oBACd,IAAI,EAAE,mCAAmC,CAAC;wBACxC,MAAM;wBACN,MAAM;wBACN,MAAM;wBACN,SAAS;wBACT,SAAS;qBACV,CAAC;oBACF,UAAU,EAAE,cAAc;iBAC3B;aACF;YACD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;gBAC1B,KAAK,CAAC,MAAM,CAAC;oBACX,MAAM,EAAE;wBACN,IAAI;4BACF,OAAO,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,cAAc,CAAC,IAAI,CAAC;wBACnC,CAAC;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,cAAc,EAAE,CAAC;AAC5B,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { useQuery } from '@apollo/client';
|
2
|
-
import { useEffect, useRef } from 'react';
|
2
|
+
import { useContext, useEffect, useRef } from 'react';
|
3
3
|
import throwErrorInDev from '../../helpers/throwErrorInDev';
|
4
|
-
import {
|
4
|
+
import { CartIdContext } from '../Cart/CartIdContext';
|
5
5
|
import debounce from 'lodash.debounce';
|
6
6
|
import { useTracker } from '../../analytics/Analytics';
|
7
7
|
import { trackCartEvent } from '../../analytics/tracking';
|
@@ -30,10 +30,10 @@ function useSingleCartTracker(result) {
|
|
30
30
|
}, [result.loading, (_a = result.data) === null || _a === void 0 ? void 0 : _a.cart, track]);
|
31
31
|
}
|
32
32
|
export function useCart(cartQuery) {
|
33
|
-
const { cartId } =
|
33
|
+
const { cartId } = useContext(CartIdContext);
|
34
34
|
const result = useQuery(cartQuery, {
|
35
35
|
variables: { cartId },
|
36
|
-
skip: __IN_SERVER__
|
36
|
+
skip: __IN_SERVER__
|
37
37
|
});
|
38
38
|
useSingleCartTracker(result);
|
39
39
|
return { result, cart: result.data && result.data.cart };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CartProvider.js","sourceRoot":"","sources":["CartProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"CartProvider.js","sourceRoot":"","sources":["CartProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAiB1D,sGAAsG;AACtG,IAAI,eAAe,GAAG,KAAK,CAAC;AAC5B,SAAS,oBAAoB,CAAC,MAAyB;;IACrD,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;IAE3B,SAAS,CAAC,GAAG,EAAE;;QACb,IAAI,CAAC,eAAe,EAAE;YACpB,eAAe,GAAG,IAAI,CAAC;YAEvB,IAAI,MAAM,CAAC,OAAO,EAAE;aACnB;iBAAM,IAAI,MAAA,MAAM,CAAC,IAAI,0CAAE,IAAI,EAAE;gBAC5B,IAAK,MAAM,C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AO,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;gBAC1D,eAAe,CAAC,OAAO,EAAE,CAAC;gBAC1B,YAAY,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;aACvC;QACH,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAE7C,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAqB;IACzE,eAAe,CAAC,CAAC,KAAK,EAAE,4CAA4C,CAAC,CAAC;IAEtE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAClC,mBAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEpC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC"}
|
@@ -20,8 +20,7 @@ export function useAddMultipleToCart(items, hookQueries, hookCallbacks) {
|
|
20
20
|
const cartIdNotSet = !cartId;
|
21
21
|
const cartIdFromMutation = data.addMultipleToCart.cart.id;
|
22
22
|
const newCartIdReturnedFromAPI = cartIdFromMutation !== cartId;
|
23
|
-
// Set the cart ID in context so any future add to cart actions use the same
|
24
|
-
// ID
|
23
|
+
// Set the cart ID in context so any future add to cart actions use the same ID
|
25
24
|
if (cartIdNotSet || newCartIdReturnedFromAPI) {
|
26
25
|
setCartId(cartIdFromMutation);
|
27
26
|
}
|
@@ -59,9 +58,9 @@ export function useAddMultipleToCart(items, hookQueries, hookCallbacks) {
|
|
59
58
|
}))
|
60
59
|
},
|
61
60
|
refetchQueries: (resp) => {
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
return ((resp.errors || cartId) && [
|
62
|
+
{ query: queries.cartQuery, variables: { cartId } }
|
63
|
+
]);
|
65
64
|
}
|
66
65
|
})
|
67
66
|
.then((resp) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAddMultipleToCart.js","sourceRoot":"","sources":["useAddMultipleToCart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAA6B,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAO7C,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAsBzF,MAAM,UAAU,oBAAoB,CAClC,KAA0C,EAC1C,WAAsC,EACtC,aAA2C;IAc3C,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IACjC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAElC,MAAM,CAAC,CAAC;IACV,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,EAAqC,CAAC;IACtE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAExD,IAAI,CAAC,KAAK,EAAE;QACV,eAAe,CACb,IAAI,EACJ,4DAA4D,CAC7D,CAAC;QACF,OAAO,IAAI,CAAC;KACb;IAED,SAAS,UAAU,CAAC,EAAE,IAAI,EAAqC;QAC7D,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC;QAC7B,MAAM,kBAAkB,GAAG,IAAI,CAAC,i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