@soppiya/app-bridge 1.1.7 → 1.1.9
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/components/articles-picker/ui/ArticlesPicker.d.ts +2 -1
- package/dist/components/articles-picker/ui/ArticlesPicker.js +2 -1
- package/dist/components/articles-picker/ui/ProductPicker.stories.d.ts +2 -1
- package/dist/components/blogs-picker/ui/BlogsPicker.d.ts +2 -1
- package/dist/components/blogs-picker/ui/BlogsPicker.js +2 -1
- package/dist/components/blogs-picker/ui/BlogsPicker.stories.d.ts +2 -1
- package/dist/components/collections-pciker/api/query.d.ts +5 -2
- package/dist/components/collections-pciker/api/query.js +8 -8
- package/dist/components/collections-pciker/model/useCollections.d.ts +1 -1
- package/dist/components/collections-pciker/model/useCollections.js +3 -4
- package/dist/components/collections-pciker/ui/CollectionPicker.d.ts +2 -1
- package/dist/components/collections-pciker/ui/CollectionPicker.js +2 -1
- package/dist/components/collections-pciker/ui/CollectionPicker.stories.d.ts +2 -1
- package/dist/components/country-picker/api/query.d.ts +8 -0
- package/dist/components/country-picker/api/query.js +19 -0
- package/dist/components/country-picker/index.d.ts +1 -0
- package/dist/components/country-picker/index.js +2 -0
- package/dist/components/country-picker/model/useContry.d.ts +26 -0
- package/dist/components/country-picker/model/useContry.js +48 -0
- package/dist/components/country-picker/ui/CountryPicker.d.ts +10 -0
- package/dist/components/country-picker/ui/CountryPicker.js +115 -0
- package/dist/components/country-picker/ui/CountryPicker.stories.d.ts +13 -0
- package/dist/components/country-picker/ui/CountryPicker.stories.js +11 -0
- package/dist/components/customers-picker/api/query.d.ts +8 -0
- package/dist/components/customers-picker/api/query.js +22 -0
- package/dist/components/customers-picker/index.d.ts +1 -0
- package/dist/components/customers-picker/index.js +2 -0
- package/dist/components/customers-picker/model/useCustomers.d.ts +30 -0
- package/dist/components/customers-picker/model/useCustomers.js +48 -0
- package/dist/components/customers-picker/ui/CustomersPicker.d.ts +10 -0
- package/dist/components/customers-picker/ui/CustomersPicker.js +114 -0
- package/dist/components/customers-picker/ui/CustomersPicker.stories.d.ts +13 -0
- package/dist/components/customers-picker/ui/CustomersPicker.stories.js +11 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/components/link-list-picker/ui/LinkListPicker.d.ts +2 -1
- package/dist/components/link-list-picker/ui/LinkListPicker.js +2 -1
- package/dist/components/link-list-picker/ui/LinkListPicker.stories.d.ts +2 -1
- package/dist/components/media/Media.d.ts +2 -1
- package/dist/components/media/Media.js +2 -1
- package/dist/components/media/Media.stories.d.ts +2 -1
- package/dist/components/metaobjects-entries-picker/ui/MetaobjectEntriesPicker.d.ts +2 -1
- package/dist/components/metaobjects-entries-picker/ui/MetaobjectEntriesPicker.js +2 -1
- package/dist/components/metaobjects-entries-picker/ui/MetaobjectEntriesPicker.stories.d.ts +2 -1
- package/dist/components/metaobjects-picker/ui/MetaobjectsPicker.d.ts +2 -1
- package/dist/components/metaobjects-picker/ui/MetaobjectsPicker.js +2 -1
- package/dist/components/metaobjects-picker/ui/MetaobjectsPicker.stories.d.ts +2 -1
- package/dist/components/pages-picker/ui/PagesPicker.d.ts +2 -1
- package/dist/components/pages-picker/ui/PagesPicker.js +2 -1
- package/dist/components/pages-picker/ui/PagesPicker.stories.d.ts +2 -1
- package/dist/components/products-picker/ui/ProductPicker.d.ts +2 -1
- package/dist/components/products-picker/ui/ProductPicker.js +2 -1
- package/dist/components/products-picker/ui/ProductsPicker.stories.d.ts +2 -1
- package/dist/components/segments-picker/api/query.d.ts +8 -0
- package/dist/components/segments-picker/api/query.js +18 -0
- package/dist/components/segments-picker/index.d.ts +1 -0
- package/dist/components/segments-picker/index.js +2 -0
- package/dist/components/segments-picker/model/useSegments.d.ts +25 -0
- package/dist/components/segments-picker/model/useSegments.js +48 -0
- package/dist/components/segments-picker/ui/SegmentsPicker.d.ts +10 -0
- package/dist/components/segments-picker/ui/SegmentsPicker.js +106 -0
- package/dist/components/segments-picker/ui/SegmentsPicker.stories.d.ts +13 -0
- package/dist/components/segments-picker/ui/SegmentsPicker.stories.js +11 -0
- package/dist/components/variants-picker/ui/VariantsPicker.d.ts +2 -1
- package/dist/components/variants-picker/ui/VariantsPicker.js +2 -1
- package/dist/components/variants-picker/ui/VariantsPicker.stories.d.ts +2 -1
- package/dist/shared/graphql/gql.d.ts +17 -2
- package/dist/shared/graphql/gql.js +5 -2
- package/dist/shared/graphql/graphql.d.ts +150 -38
- package/dist/shared/graphql/graphql.js +1303 -284
- package/dist/styles.css +12 -0
- package/package.json +2 -2
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { InfinityScroll } from "../../infinity-scroll/index.js";
|
|
3
|
+
import { useFilterQuery } from "../../../shared/lib/index.js";
|
|
4
|
+
import { BlockStack, Box, Button, Checkbox, InlineStack, Input, Modal, Spinner, Text } from "@soppiya/elementus";
|
|
5
|
+
import classnames from "classnames";
|
|
6
|
+
import lodash from "lodash";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { useCustomers } from "../model/useCustomers.js";
|
|
9
|
+
const CustomersPicker = ({ title = "Customers", initialIds = [], limit = 1 / 0, okButtonLoading, onClose, onOk })=>{
|
|
10
|
+
const [selectedCustomer, setSelectedCustomer] = useState(initialIds);
|
|
11
|
+
const { query, debounceQuery, onChangeQuery } = useFilterQuery();
|
|
12
|
+
const { customers, pageInfo, isLoadingCustomers, fetchMoreCustomers } = useCustomers({
|
|
13
|
+
first: 20,
|
|
14
|
+
query: debounceQuery
|
|
15
|
+
});
|
|
16
|
+
const isReached = limit !== 1 / 0 && selectedCustomer.length >= limit;
|
|
17
|
+
const isDisabled = limit !== 1 / 0 && selectedCustomer.length > limit;
|
|
18
|
+
const handleSelectCustomer = (customerId)=>{
|
|
19
|
+
if (selectedCustomer.includes(customerId)) return void setSelectedCustomer((prev)=>prev.filter((id)=>customerId !== id));
|
|
20
|
+
if (isReached) return;
|
|
21
|
+
setSelectedCustomer((prev)=>[
|
|
22
|
+
...prev,
|
|
23
|
+
customerId
|
|
24
|
+
]);
|
|
25
|
+
};
|
|
26
|
+
const handleOk = ()=>{
|
|
27
|
+
if (lodash.isFunction(onOk)) onOk(selectedCustomer);
|
|
28
|
+
};
|
|
29
|
+
const buttonsJSX = /*#__PURE__*/ jsx(InlineStack, {
|
|
30
|
+
gap: 50,
|
|
31
|
+
justifyContent: "end",
|
|
32
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
33
|
+
loading: okButtonLoading,
|
|
34
|
+
disabled: lodash.isEmpty(selectedCustomer) || isDisabled,
|
|
35
|
+
onClick: handleOk,
|
|
36
|
+
children: "Add"
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
return /*#__PURE__*/ jsx(Modal, {
|
|
40
|
+
open: true,
|
|
41
|
+
title: title,
|
|
42
|
+
bodyPadding: 0,
|
|
43
|
+
buttons: buttonsJSX,
|
|
44
|
+
onClose: onClose,
|
|
45
|
+
children: /*#__PURE__*/ jsxs(BlockStack, {
|
|
46
|
+
children: [
|
|
47
|
+
/*#__PURE__*/ jsx(Box, {
|
|
48
|
+
padding: 60,
|
|
49
|
+
children: /*#__PURE__*/ jsx(Input, {
|
|
50
|
+
size: "sm",
|
|
51
|
+
type: "search",
|
|
52
|
+
value: query ?? "",
|
|
53
|
+
onChange: (event)=>onChangeQuery(event.target.value)
|
|
54
|
+
})
|
|
55
|
+
}),
|
|
56
|
+
isLoadingCustomers ? /*#__PURE__*/ jsx(InlineStack, {
|
|
57
|
+
justifyContent: "center",
|
|
58
|
+
padding: 80,
|
|
59
|
+
children: /*#__PURE__*/ jsx(Spinner, {
|
|
60
|
+
size: "md"
|
|
61
|
+
})
|
|
62
|
+
}) : /*#__PURE__*/ jsxs(BlockStack, {
|
|
63
|
+
children: [
|
|
64
|
+
customers.map((customer)=>/*#__PURE__*/ jsx(InlineStack, {
|
|
65
|
+
stack: "full",
|
|
66
|
+
className: classnames('lg:cursor-pointer border-t border-t-[#ebebeb]!', {
|
|
67
|
+
'bg-[#f1f1f1ab] cursor-default!': !selectedCustomer.includes(customer._id) && isReached
|
|
68
|
+
}),
|
|
69
|
+
gapX: 60,
|
|
70
|
+
padding: 60,
|
|
71
|
+
onClick: ()=>handleSelectCustomer(String(customer._id)),
|
|
72
|
+
children: /*#__PURE__*/ jsx(BlockStack, {
|
|
73
|
+
children: /*#__PURE__*/ jsxs(InlineStack, {
|
|
74
|
+
alignItems: "center",
|
|
75
|
+
gapX: 70,
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ jsx(Box, {
|
|
78
|
+
children: /*#__PURE__*/ jsx(Checkbox, {
|
|
79
|
+
disabled: !selectedCustomer.includes(customer._id) && isReached,
|
|
80
|
+
checked: selectedCustomer.includes(String(customer._id)),
|
|
81
|
+
onChange: ()=>{}
|
|
82
|
+
})
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ jsxs(BlockStack, {
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ jsx(Text, {
|
|
87
|
+
size: "md",
|
|
88
|
+
weight: "medium",
|
|
89
|
+
className: "capitalize!",
|
|
90
|
+
children: customer.first_name + " " + customer.last_name
|
|
91
|
+
}),
|
|
92
|
+
/*#__PURE__*/ jsx(Text, {
|
|
93
|
+
size: "sm",
|
|
94
|
+
color: "secondary",
|
|
95
|
+
truncate: "truncate-1",
|
|
96
|
+
children: customer.email?.address
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
})),
|
|
104
|
+
pageInfo?.hasNextPage && /*#__PURE__*/ jsx(InfinityScroll, {
|
|
105
|
+
onFetch: fetchMoreCustomers
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
const ui_CustomersPicker = CustomersPicker;
|
|
114
|
+
export { ui_CustomersPicker as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const meta: {
|
|
2
|
+
title: string;
|
|
3
|
+
component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: {
|
|
4
|
+
title?: string;
|
|
5
|
+
initialIds?: string[];
|
|
6
|
+
limit?: number;
|
|
7
|
+
okButtonLoading?: boolean;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
onOk?: (customers: string[]) => void;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
export declare const Default: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import CustomersPicker from "./CustomersPicker.js";
|
|
3
|
+
const meta = {
|
|
4
|
+
title: "Example/CustomersPicker",
|
|
5
|
+
component: CustomersPicker
|
|
6
|
+
};
|
|
7
|
+
const CustomersPicker_stories = meta;
|
|
8
|
+
const Default = ()=>/*#__PURE__*/ jsx(CustomersPicker, {
|
|
9
|
+
title: "Select Customer"
|
|
10
|
+
});
|
|
11
|
+
export { Default, CustomersPicker_stories as default };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./articles-picker";
|
|
2
2
|
export * from "./blogs-picker";
|
|
3
3
|
export * from "./collections-pciker";
|
|
4
|
+
export * from "./country-picker";
|
|
5
|
+
export * from "./customers-picker";
|
|
4
6
|
export * from "./link-list-picker";
|
|
5
7
|
export * from "./media";
|
|
6
8
|
export * from "./meta-data";
|
|
@@ -9,4 +11,5 @@ export * from "./metaobjects-picker";
|
|
|
9
11
|
export * from "./pages-picker";
|
|
10
12
|
export * from "./products-picker";
|
|
11
13
|
export * from "./savebar";
|
|
14
|
+
export * from "./segments-picker";
|
|
12
15
|
export * from "./variants-picker";
|
package/dist/components/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./articles-picker/index.js";
|
|
2
2
|
export * from "./blogs-picker/index.js";
|
|
3
3
|
export * from "./collections-pciker/index.js";
|
|
4
|
+
export * from "./country-picker/index.js";
|
|
5
|
+
export * from "./customers-picker/index.js";
|
|
4
6
|
export * from "./link-list-picker/index.js";
|
|
5
7
|
export * from "./media/index.js";
|
|
6
8
|
export * from "./meta-data/index.js";
|
|
@@ -9,4 +11,5 @@ export * from "./metaobjects-picker/index.js";
|
|
|
9
11
|
export * from "./pages-picker/index.js";
|
|
10
12
|
export * from "./products-picker/index.js";
|
|
11
13
|
export * from "./savebar/index.js";
|
|
14
|
+
export * from "./segments-picker/index.js";
|
|
12
15
|
export * from "./variants-picker/index.js";
|
|
@@ -2,8 +2,9 @@ type Props = {
|
|
|
2
2
|
title?: string;
|
|
3
3
|
initialIds?: string[];
|
|
4
4
|
limit?: number;
|
|
5
|
+
okButtonLoading?: boolean;
|
|
5
6
|
onClose?: () => void;
|
|
6
7
|
onOk?: (linklist: string[]) => void;
|
|
7
8
|
};
|
|
8
|
-
declare const LinkListPicker: ({ title, initialIds, limit, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const LinkListPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export default LinkListPicker;
|
|
@@ -6,7 +6,7 @@ import classnames from "classnames";
|
|
|
6
6
|
import lodash from "lodash";
|
|
7
7
|
import { useState } from "react";
|
|
8
8
|
import { useLinklist } from "../model/useLinkList.js";
|
|
9
|
-
const LinkListPicker = ({ title = "Linklist", initialIds = [], limit = 1 / 0, onClose, onOk })=>{
|
|
9
|
+
const LinkListPicker = ({ title = "Linklist", initialIds = [], limit = 1 / 0, okButtonLoading, onClose, onOk })=>{
|
|
10
10
|
const [selectedLinklist, setSelectedLinklist] = useState(initialIds);
|
|
11
11
|
const { query, debounceQuery, onChangeQuery } = useFilterQuery();
|
|
12
12
|
const { linklists, isLoadingLinklist, fetchMoreLinklists, pageInfo } = useLinklist({
|
|
@@ -29,6 +29,7 @@ const LinkListPicker = ({ title = "Linklist", initialIds = [], limit = 1 / 0, on
|
|
|
29
29
|
const ButtonJSX = /*#__PURE__*/ jsx(InlineStack, {
|
|
30
30
|
justifyContent: "end",
|
|
31
31
|
children: /*#__PURE__*/ jsx(Button, {
|
|
32
|
+
loading: okButtonLoading,
|
|
32
33
|
disabled: lodash.isEmpty(selectedLinklist) || isDisabled,
|
|
33
34
|
onClick: handleOk,
|
|
34
35
|
children: "Add"
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
declare const meta: {
|
|
2
2
|
title: string;
|
|
3
|
-
component: ({ title, initialIds, limit, onClose, onOk }: {
|
|
3
|
+
component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: {
|
|
4
4
|
title?: string;
|
|
5
5
|
initialIds?: string[];
|
|
6
6
|
limit?: number;
|
|
7
|
+
okButtonLoading?: boolean;
|
|
7
8
|
onClose?: () => void;
|
|
8
9
|
onOk?: (linklist: string[]) => void;
|
|
9
10
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,8 +4,9 @@ type MediaProps = {
|
|
|
4
4
|
types?: MediaType[];
|
|
5
5
|
limit?: number;
|
|
6
6
|
isFilterByTypes?: boolean;
|
|
7
|
+
okButtonLoading?: boolean;
|
|
7
8
|
onClose?: () => void;
|
|
8
9
|
onOk?: (medias: string[]) => void;
|
|
9
10
|
};
|
|
10
|
-
declare const Media: ({ title, types, isFilterByTypes, limit, onClose, onOk, }: MediaProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
declare const Media: ({ title, types, isFilterByTypes, limit, okButtonLoading, onClose, onOk, }: MediaProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export default Media;
|
|
@@ -23,7 +23,7 @@ const Media_Media = ({ title = "Media", types = [
|
|
|
23
23
|
MediaType.file,
|
|
24
24
|
MediaType.image,
|
|
25
25
|
MediaType.video
|
|
26
|
-
], isFilterByTypes = false, limit = 1 / 0, onClose, onOk })=>{
|
|
26
|
+
], isFilterByTypes = false, limit = 1 / 0, okButtonLoading, onClose, onOk })=>{
|
|
27
27
|
const { query, debounceQuery, onChangeQuery } = useMediaFilter();
|
|
28
28
|
const { sorting, onChangeSorting } = useMediaSorting();
|
|
29
29
|
const [selectedMedias, setSelectedMedias] = useState([]);
|
|
@@ -131,6 +131,7 @@ const Media_Media = ({ title = "Media", types = [
|
|
|
131
131
|
stack: "full",
|
|
132
132
|
justifyContent: "end",
|
|
133
133
|
children: /*#__PURE__*/ jsx(Button, {
|
|
134
|
+
loading: okButtonLoading,
|
|
134
135
|
size: "xs",
|
|
135
136
|
disabled: !isValidMedia(),
|
|
136
137
|
onClick: handleOk,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
declare const meta: {
|
|
2
2
|
title: string;
|
|
3
|
-
component: ({ title, types, isFilterByTypes, limit, onClose, onOk, }: {
|
|
3
|
+
component: ({ title, types, isFilterByTypes, limit, okButtonLoading, onClose, onOk, }: {
|
|
4
4
|
title?: string;
|
|
5
5
|
types?: import("../../shared/graphql/graphql").MediaType[];
|
|
6
6
|
limit?: number;
|
|
7
7
|
isFilterByTypes?: boolean;
|
|
8
|
+
okButtonLoading?: boolean;
|
|
8
9
|
onClose?: () => void;
|
|
9
10
|
onOk?: (medias: string[]) => void;
|
|
10
11
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,8 +3,9 @@ type Props = {
|
|
|
3
3
|
initialIds?: string[];
|
|
4
4
|
limit?: number;
|
|
5
5
|
metaobjects?: string[];
|
|
6
|
+
okButtonLoading?: boolean;
|
|
6
7
|
onClose?: () => void;
|
|
7
8
|
onOk?: (metaobjectEntries: string[]) => void;
|
|
8
9
|
};
|
|
9
|
-
declare const MetaobjectEntriesPicker: ({ title, initialIds, limit, metaobjects, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare const MetaobjectEntriesPicker: ({ title, initialIds, limit, metaobjects, okButtonLoading, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export default MetaobjectEntriesPicker;
|
|
@@ -6,7 +6,7 @@ import classnames from "classnames";
|
|
|
6
6
|
import lodash from "lodash";
|
|
7
7
|
import { useState } from "react";
|
|
8
8
|
import { useMetaobjectEntries } from "../model/useMetaobjectEntries.js";
|
|
9
|
-
const MetaobjectEntriesPicker = ({ title = "Metaobject entries", initialIds = [], limit = 1 / 0, metaobjects = [], onClose, onOk })=>{
|
|
9
|
+
const MetaobjectEntriesPicker = ({ title = "Metaobject entries", initialIds = [], limit = 1 / 0, metaobjects = [], okButtonLoading, onClose, onOk })=>{
|
|
10
10
|
const [selectedMetaobjectEntries, setSelectedMetaobjectEntries] = useState(initialIds);
|
|
11
11
|
const { query, debounceQuery, onChangeQuery } = useFilterQuery();
|
|
12
12
|
const { metaobjectEntries, isLoadingMetaobjectEntries, fetchMoreMetaobjectEntries, pageInfo } = useMetaobjectEntries({
|
|
@@ -32,6 +32,7 @@ const MetaobjectEntriesPicker = ({ title = "Metaobject entries", initialIds = []
|
|
|
32
32
|
const ButtonJSX = /*#__PURE__*/ jsx(InlineStack, {
|
|
33
33
|
justifyContent: "end",
|
|
34
34
|
children: /*#__PURE__*/ jsx(Button, {
|
|
35
|
+
loading: okButtonLoading,
|
|
35
36
|
disabled: lodash.isEmpty(selectedMetaobjectEntries) || isDisabled,
|
|
36
37
|
onClick: handleOk,
|
|
37
38
|
children: "Add"
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
declare const meta: {
|
|
2
2
|
title: string;
|
|
3
|
-
component: ({ title, initialIds, limit, metaobjects, onClose, onOk }: {
|
|
3
|
+
component: ({ title, initialIds, limit, metaobjects, okButtonLoading, onClose, onOk }: {
|
|
4
4
|
title?: string;
|
|
5
5
|
initialIds?: string[];
|
|
6
6
|
limit?: number;
|
|
7
7
|
metaobjects?: string[];
|
|
8
|
+
okButtonLoading?: boolean;
|
|
8
9
|
onClose?: () => void;
|
|
9
10
|
onOk?: (metaobjectEntries: string[]) => void;
|
|
10
11
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,8 +2,9 @@ type Props = {
|
|
|
2
2
|
title?: string;
|
|
3
3
|
initialIds?: string[];
|
|
4
4
|
limit?: number;
|
|
5
|
+
okButtonLoading?: boolean;
|
|
5
6
|
onClose?: () => void;
|
|
6
7
|
onOk?: (metaobjectEntries: string[]) => void;
|
|
7
8
|
};
|
|
8
|
-
declare const MetaobjectsPicker: ({ title, initialIds, limit, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const MetaobjectsPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export default MetaobjectsPicker;
|
|
@@ -6,7 +6,7 @@ import classnames from "classnames";
|
|
|
6
6
|
import lodash from "lodash";
|
|
7
7
|
import { useState } from "react";
|
|
8
8
|
import { useMetaobjects } from "../model/useMetaobjects.js";
|
|
9
|
-
const MetaobjectsPicker = ({ title = "Metaobjects", initialIds = [], limit = 1 / 0, onClose, onOk })=>{
|
|
9
|
+
const MetaobjectsPicker = ({ title = "Metaobjects", initialIds = [], limit = 1 / 0, okButtonLoading, onClose, onOk })=>{
|
|
10
10
|
const [selectedMetaobject, setSelectedMetaobject] = useState(initialIds);
|
|
11
11
|
const { query, debounceQuery, onChangeQuery } = useFilterQuery();
|
|
12
12
|
const { metaobjects, isMetaobjectsLoading, fetchMoreMetaobjects, pageInfo } = useMetaobjects({
|
|
@@ -29,6 +29,7 @@ const MetaobjectsPicker = ({ title = "Metaobjects", initialIds = [], limit = 1 /
|
|
|
29
29
|
const ButtonJSX = /*#__PURE__*/ jsx(InlineStack, {
|
|
30
30
|
justifyContent: "end",
|
|
31
31
|
children: /*#__PURE__*/ jsx(Button, {
|
|
32
|
+
loading: okButtonLoading,
|
|
32
33
|
disabled: lodash.isEmpty(selectedMetaobject) || isDisabled,
|
|
33
34
|
onClick: handleOk,
|
|
34
35
|
children: "Add"
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
declare const meta: {
|
|
2
2
|
title: string;
|
|
3
|
-
component: ({ title, initialIds, limit, onClose, onOk }: {
|
|
3
|
+
component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: {
|
|
4
4
|
title?: string;
|
|
5
5
|
initialIds?: string[];
|
|
6
6
|
limit?: number;
|
|
7
|
+
okButtonLoading?: boolean;
|
|
7
8
|
onClose?: () => void;
|
|
8
9
|
onOk?: (metaobjectEntries: string[]) => void;
|
|
9
10
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,8 +2,9 @@ type Props = {
|
|
|
2
2
|
title?: string;
|
|
3
3
|
initialIds?: string[];
|
|
4
4
|
limit?: number;
|
|
5
|
+
okButtonLoading?: boolean;
|
|
5
6
|
onClose?: () => void;
|
|
6
7
|
onOk?: (pages: string[]) => void;
|
|
7
8
|
};
|
|
8
|
-
declare const PagesPicker: ({ title, initialIds, limit, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const PagesPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export default PagesPicker;
|
|
@@ -6,7 +6,7 @@ import classnames from "classnames";
|
|
|
6
6
|
import lodash from "lodash";
|
|
7
7
|
import { useState } from "react";
|
|
8
8
|
import { usePages } from "../model/usePages.js";
|
|
9
|
-
const PagesPicker = ({ title = "Pages", initialIds = [], limit = 1 / 0, onClose, onOk })=>{
|
|
9
|
+
const PagesPicker = ({ title = "Pages", initialIds = [], limit = 1 / 0, okButtonLoading, onClose, onOk })=>{
|
|
10
10
|
const [selectedPage, setSelectedPage] = useState(initialIds);
|
|
11
11
|
const { query, debounceQuery, onChangeQuery } = useFilterQuery();
|
|
12
12
|
const { pages, fetchMorePages, isLoadingPages, pageInfo } = usePages({
|
|
@@ -29,6 +29,7 @@ const PagesPicker = ({ title = "Pages", initialIds = [], limit = 1 / 0, onClose,
|
|
|
29
29
|
const ButtonJSX = /*#__PURE__*/ jsx(InlineStack, {
|
|
30
30
|
justifyContent: "end",
|
|
31
31
|
children: /*#__PURE__*/ jsx(Button, {
|
|
32
|
+
loading: okButtonLoading,
|
|
32
33
|
disabled: lodash.isEmpty(selectedPage) || isDisabled,
|
|
33
34
|
onClick: handleOk,
|
|
34
35
|
children: "Add"
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
declare const meta: {
|
|
2
2
|
title: string;
|
|
3
|
-
component: ({ title, initialIds, limit, onClose, onOk }: {
|
|
3
|
+
component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: {
|
|
4
4
|
title?: string;
|
|
5
5
|
initialIds?: string[];
|
|
6
6
|
limit?: number;
|
|
7
|
+
okButtonLoading?: boolean;
|
|
7
8
|
onClose?: () => void;
|
|
8
9
|
onOk?: (pages: string[]) => void;
|
|
9
10
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,8 +2,9 @@ type Props = {
|
|
|
2
2
|
title?: string;
|
|
3
3
|
initialIds?: string[];
|
|
4
4
|
limit?: number;
|
|
5
|
+
okButtonLoading?: boolean;
|
|
5
6
|
onClose?: () => void;
|
|
6
7
|
onOk?: (products: string[]) => void;
|
|
7
8
|
};
|
|
8
|
-
declare const ProductsPicker: ({ title, initialIds, limit, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const ProductsPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export default ProductsPicker;
|
|
@@ -6,7 +6,7 @@ import classnames from "classnames";
|
|
|
6
6
|
import lodash from "lodash";
|
|
7
7
|
import { useState } from "react";
|
|
8
8
|
import { useProducts } from "../model/useProducts.js";
|
|
9
|
-
const ProductsPicker = ({ title = "Products", initialIds = [], limit = 1 / 0, onClose, onOk })=>{
|
|
9
|
+
const ProductsPicker = ({ title = "Products", initialIds = [], limit = 1 / 0, okButtonLoading, onClose, onOk })=>{
|
|
10
10
|
const [selectedProduct, setSelectedProduct] = useState(initialIds);
|
|
11
11
|
const { query, debounceQuery, onChangeQuery } = useFilterQuery();
|
|
12
12
|
const { products, pageInfo, isLoadingProducts, fetchMoreProducts } = useProducts({
|
|
@@ -30,6 +30,7 @@ const ProductsPicker = ({ title = "Products", initialIds = [], limit = 1 / 0, on
|
|
|
30
30
|
gap: 50,
|
|
31
31
|
justifyContent: "end",
|
|
32
32
|
children: /*#__PURE__*/ jsx(Button, {
|
|
33
|
+
loading: okButtonLoading,
|
|
33
34
|
disabled: lodash.isEmpty(selectedProduct) || isDisabled,
|
|
34
35
|
onClick: handleOk,
|
|
35
36
|
children: "Add"
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
declare const meta: {
|
|
2
2
|
title: string;
|
|
3
|
-
component: ({ title, initialIds, limit, onClose, onOk }: {
|
|
3
|
+
component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: {
|
|
4
4
|
title?: string;
|
|
5
5
|
initialIds?: string[];
|
|
6
6
|
limit?: number;
|
|
7
|
+
okButtonLoading?: boolean;
|
|
7
8
|
onClose?: () => void;
|
|
8
9
|
onOk?: (products: string[]) => void;
|
|
9
10
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const segmentsQuery: import("@graphql-typed-document-node/core").TypedDocumentNode<import("../../../shared/graphql/graphql").CustomerSegmentsQuery, import("../../../shared/graphql/graphql").Exact<{
|
|
2
|
+
after?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["ID"]["input"]>;
|
|
3
|
+
before?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["ID"]["input"]>;
|
|
4
|
+
first?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["Int"]["input"]>;
|
|
5
|
+
last?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["Int"]["input"]>;
|
|
6
|
+
query?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["String"]["input"]>;
|
|
7
|
+
filterKeys?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").CustomerSegmentFilterKeys>;
|
|
8
|
+
}>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { graphql } from "../../../shared/graphql/index.js";
|
|
2
|
+
const segmentsQuery = graphql(`query CustomerSegments($after: ID, $before: ID, $first: Int, $last: Int, $query: String, $filterKeys: CustomerSegmentFilterKeys) {
|
|
3
|
+
customerSegments(after: $after, before: $before, first: $first, last: $last, query: $query, filterKeys: $filterKeys) {
|
|
4
|
+
pageInfo {
|
|
5
|
+
endCursor
|
|
6
|
+
hasNextPage
|
|
7
|
+
hasPreviousPage
|
|
8
|
+
startCursor
|
|
9
|
+
}
|
|
10
|
+
edges {
|
|
11
|
+
node {
|
|
12
|
+
_id
|
|
13
|
+
title
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}`);
|
|
18
|
+
export { segmentsQuery };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SegmentPicker } from "./ui/SegmentsPicker";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CustomerSegmentFilterKeys } from "../../../shared/graphql/graphql";
|
|
2
|
+
type Props = {
|
|
3
|
+
skip?: boolean;
|
|
4
|
+
first?: number;
|
|
5
|
+
query?: string | null;
|
|
6
|
+
filterKeys?: CustomerSegmentFilterKeys | null;
|
|
7
|
+
};
|
|
8
|
+
export declare const useSegments: (props?: Props) => {
|
|
9
|
+
segments: {
|
|
10
|
+
__typename: "CustomerSegment";
|
|
11
|
+
_id?: string | null;
|
|
12
|
+
title?: string | null;
|
|
13
|
+
}[];
|
|
14
|
+
pageInfo: {
|
|
15
|
+
__typename: "PageInfo";
|
|
16
|
+
endCursor?: string | null;
|
|
17
|
+
hasNextPage?: boolean | null;
|
|
18
|
+
hasPreviousPage?: boolean | null;
|
|
19
|
+
startCursor?: string | null;
|
|
20
|
+
} | null | undefined;
|
|
21
|
+
isLoadingSegments: boolean;
|
|
22
|
+
error: import("@apollo/client").ErrorLike | undefined;
|
|
23
|
+
fetchMoreSegments: () => void;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useQuery } from "@apollo/client/react";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import { segmentsQuery } from "../api/query.js";
|
|
4
|
+
const useSegments = (props = {})=>{
|
|
5
|
+
const { skip, first, query, filterKeys } = props;
|
|
6
|
+
const refArray = useRef([]);
|
|
7
|
+
const { data, loading: isLoadingSegments, error, fetchMore } = useQuery(segmentsQuery, {
|
|
8
|
+
skip,
|
|
9
|
+
variables: {
|
|
10
|
+
first,
|
|
11
|
+
query,
|
|
12
|
+
filterKeys
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
const pageInfo = data?.customerSegments?.pageInfo;
|
|
16
|
+
const segments = data?.customerSegments?.edges?.map((edge)=>edge?.node).filter((node)=>null != node) ?? refArray.current;
|
|
17
|
+
const fetchMoreSegments = ()=>{
|
|
18
|
+
if (!pageInfo?.hasNextPage) return;
|
|
19
|
+
fetchMore({
|
|
20
|
+
variables: {
|
|
21
|
+
first,
|
|
22
|
+
query,
|
|
23
|
+
after: pageInfo.endCursor,
|
|
24
|
+
filterKeys
|
|
25
|
+
},
|
|
26
|
+
updateQuery (prev, { fetchMoreResult }) {
|
|
27
|
+
if (!fetchMoreResult.customerSegments?.edges || !prev.customerSegments?.edges) return prev;
|
|
28
|
+
return {
|
|
29
|
+
customerSegments: {
|
|
30
|
+
...fetchMoreResult.customerSegments,
|
|
31
|
+
edges: [
|
|
32
|
+
...prev.customerSegments.edges,
|
|
33
|
+
...fetchMoreResult.customerSegments.edges
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
segments,
|
|
42
|
+
pageInfo,
|
|
43
|
+
isLoadingSegments,
|
|
44
|
+
error,
|
|
45
|
+
fetchMoreSegments
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export { useSegments };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
title?: string;
|
|
3
|
+
initialIds?: string[];
|
|
4
|
+
limit?: number;
|
|
5
|
+
okButtonLoading?: boolean;
|
|
6
|
+
onClose?: () => void;
|
|
7
|
+
onOk?: (customers: string[]) => void;
|
|
8
|
+
};
|
|
9
|
+
declare const SegmentPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default SegmentPicker;
|