@jetshop/core 5.11.0 → 5.11.1
Sign up to get free protection for your applications and to get access to all the features.
- package/data/fragments/ProductListsFragments.gql +94 -0
- package/data/mutations/productListMutations.gql +18 -0
- package/data/queries/ProductLists.gql +8 -0
- package/dependencies.d.ts +10 -1
- package/hooks/ProductList/ProductListContext.js +16 -4
- package/hooks/ProductList/ProductListContext.js.map +1 -1
- package/hooks/ProductList/ProductLists.gql +0 -0
- package/package.json +1 -1
@@ -0,0 +1,94 @@
|
|
1
|
+
#import "@jetshop/core/data/fragments/BadgeFragment.gql"
|
2
|
+
#import "@jetshop/core/data/fragments/ProductPriceFragment.gql"
|
3
|
+
|
4
|
+
fragment MinimalProductListDetail on CustomerProductList {
|
5
|
+
id
|
6
|
+
name
|
7
|
+
# TODO
|
8
|
+
# typeId {...}
|
9
|
+
# description
|
10
|
+
items {
|
11
|
+
variant {
|
12
|
+
articleNumber
|
13
|
+
}
|
14
|
+
product {
|
15
|
+
articleNumber
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
fragment VariantDetail on ProductVariant {
|
21
|
+
id
|
22
|
+
articleNumber
|
23
|
+
values
|
24
|
+
stockStatus {
|
25
|
+
buyable
|
26
|
+
text
|
27
|
+
}
|
28
|
+
images {
|
29
|
+
modifiedDate
|
30
|
+
alt
|
31
|
+
title
|
32
|
+
url
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
fragment VariantsDetail on ProductVariants {
|
37
|
+
options {
|
38
|
+
name
|
39
|
+
values
|
40
|
+
}
|
41
|
+
values {
|
42
|
+
...VariantDetail
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
fragment ProductDetail on Product {
|
47
|
+
id
|
48
|
+
articleNumber
|
49
|
+
name
|
50
|
+
subName
|
51
|
+
hasConfigurations
|
52
|
+
hasVariants
|
53
|
+
isPreOrder
|
54
|
+
isPackage
|
55
|
+
stockStatus {
|
56
|
+
buyable
|
57
|
+
text
|
58
|
+
}
|
59
|
+
primaryRoute {
|
60
|
+
id
|
61
|
+
path
|
62
|
+
slug
|
63
|
+
}
|
64
|
+
...ProductPrice
|
65
|
+
badges {
|
66
|
+
...Badge
|
67
|
+
}
|
68
|
+
images {
|
69
|
+
modifiedDate
|
70
|
+
alt
|
71
|
+
title
|
72
|
+
url
|
73
|
+
}
|
74
|
+
variants {
|
75
|
+
...VariantsDetail
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
fragment ProductListFragment on CustomerProductList {
|
80
|
+
id
|
81
|
+
description
|
82
|
+
name
|
83
|
+
shareToken
|
84
|
+
items {
|
85
|
+
quantity
|
86
|
+
description
|
87
|
+
product {
|
88
|
+
...ProductDetail
|
89
|
+
}
|
90
|
+
variant {
|
91
|
+
...VariantDetail
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#import "@jetshop/core/data/fragments/ProductListsFragments.gql"
|
2
|
+
|
3
|
+
## Create a product list
|
4
|
+
mutation CreateProductList($input: CreateCustomerProductListInput!) {
|
5
|
+
createCustomerProductList(input: $input) {
|
6
|
+
success
|
7
|
+
customerProductList {
|
8
|
+
...MinimalProductListDetail
|
9
|
+
}
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
## delete product list
|
14
|
+
mutation DeleteProductList($id: ID) {
|
15
|
+
deleteCustomerProductList(id: $id) {
|
16
|
+
success
|
17
|
+
}
|
18
|
+
}
|
package/dependencies.d.ts
CHANGED
@@ -11,7 +11,7 @@ declare module '@jetshop/intl/config';
|
|
11
11
|
declare module 'store-css';
|
12
12
|
declare module 'dnscache';
|
13
13
|
declare module 'isbot' {
|
14
|
-
export default function(userAgent: string): boolean;
|
14
|
+
export default function (userAgent: string): boolean;
|
15
15
|
}
|
16
16
|
declare module '*.gql' {
|
17
17
|
import { DocumentNode } from 'graphql';
|
@@ -32,6 +32,15 @@ declare module '@jetshop/core/data/mutations/accountMutations.gql' {
|
|
32
32
|
export const resetRequest: DocumentNode;
|
33
33
|
}
|
34
34
|
|
35
|
+
declare module '@jetshop/core/data/mutations/productListMutations.gql' {
|
36
|
+
export const CreateProductList: DocumentNode;
|
37
|
+
export const DeleteProductList: DocumentNode;
|
38
|
+
}
|
39
|
+
|
40
|
+
declare module '@jetshop/core/data/queries/ProductLists.gql' {
|
41
|
+
export const ProductLists: DocumentNode;
|
42
|
+
}
|
43
|
+
|
35
44
|
declare module '*.svg' {
|
36
45
|
import React = require('react');
|
37
46
|
|
@@ -11,6 +11,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
11
11
|
};
|
12
12
|
import React, { useEffect, useMemo } from 'react';
|
13
13
|
import { useMutation, useQuery } from 'react-apollo';
|
14
|
+
import useWarningInDev from '@jetshop/core/hooks/useWarningInDev';
|
15
|
+
import productListQueries from '@jetshop/core/data/queries/ProductLists.gql';
|
16
|
+
import productListMutations from '@jetshop/core/data/mutations/productListMutations.gql';
|
14
17
|
import { emptyProductLists, productListMapToArray, PRODUCT_LISTS_KEY } from '.';
|
15
18
|
import useAuth from '../../components/AuthContext/useAuth';
|
16
19
|
import { useThunkReducer } from '../useThunkReducer';
|
@@ -18,11 +21,20 @@ import { createListAction, deleteListAction, loginAction, refreshAction } from '
|
|
18
21
|
import { normalizeServerList } from './list-transforms';
|
19
22
|
import { init, reducer } from './product-list-reducer';
|
20
23
|
export const ProductListContext = React.createContext(undefined);
|
24
|
+
function useMissingQueryWarning(property, queries) {
|
25
|
+
return useWarningInDev(!(property in queries), `No \`${property}\` query available in \`queries\` for \`ProductListProvider\`. ` +
|
26
|
+
`Check migration guide for 5.11.0 (product lists section) to remove this warning`);
|
27
|
+
}
|
21
28
|
export const ProductListProvider = function ProductListProvider(_a) {
|
22
29
|
var { queries, initialState = {} } = _a, rest = __rest(_a, ["queries", "initialState"]);
|
30
|
+
// NOTE: Warn about missing queries, should be removed in next major release.
|
31
|
+
useMissingQueryWarning('all', queries);
|
32
|
+
useMissingQueryWarning('createList', queries);
|
33
|
+
useMissingQueryWarning('deleteList', queries);
|
23
34
|
const { loggedIn } = useAuth();
|
24
35
|
const requestIdRef = React.useRef(null);
|
25
|
-
const
|
36
|
+
const allQuery = queries.all || productListQueries.ProductLists;
|
37
|
+
const { data: serverList, client } = useQuery(allQuery, {
|
26
38
|
skip: !loggedIn
|
27
39
|
});
|
28
40
|
const lists = serverList
|
@@ -44,9 +56,9 @@ export const ProductListProvider = function ProductListProvider(_a) {
|
|
44
56
|
// loginMutation is a mutation to merge product lists
|
45
57
|
const [loginMutation] = useMutation(queries.login);
|
46
58
|
// To be used to fetch all lists of user after login
|
47
|
-
const fetchAll = () => client.query({ query:
|
48
|
-
const [createMutation] = useMutation(queries.createList);
|
49
|
-
const [deleteListMutation] = useMutation(queries.deleteList);
|
59
|
+
const fetchAll = () => client.query({ query: allQuery });
|
60
|
+
const [createMutation] = useMutation(queries.createList || productListMutations.CreateProductList);
|
61
|
+
const [deleteListMutation] = useMutation(queries.deleteList || productListMutations.DeleteProductList);
|
50
62
|
function deleteList(listId) {
|
51
63
|
dispatch(deleteListAction({ listId, deleteListMutation }));
|
52
64
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ProductListContext.js","sourceRoot":"","sources":["ProductListContext.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAW,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"ProductListContext.js","sourceRoot":"","sources":["ProductListContext.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAW,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,eAAe,MAAM,qCAAqC,CAAC;AAClE,OAAO,kBAAkB,MAAM,6CAA6C,CAAC;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