@wix/ditto-codegen-public 1.0.135 → 1.0.137
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/examples-apps/ai-chatbot/src/dashboard/pages/product/ProductChat.tsx +26 -20
- package/dist/examples-apps/ai-chatbot/src/dashboard/pages/product/page.tsx +12 -11
- package/dist/out.js +26356 -26323
- package/package.json +2 -2
- package/dist/examples-apps/ai-chatbot/src/backend/api/chat/api.ts +0 -62
- package/dist/examples-apps/ai-chatbot/src/backend/api/settings/api.ts +0 -39
- package/dist/examples-apps/ai-chatbot/src/backend/database.ts +0 -86
- package/dist/examples-apps/ai-chatbot/src/dashboard/pages/product/page.json +0 -6
- package/dist/examples-apps/ai-chatbot/src/dashboard/pages/settings/page.json +0 -6
- package/dist/examples-apps/ai-chatbot/src/dashboard/pages/settings/page.tsx +0 -105
- package/dist/examples-apps/ai-chatbot/src/dashboard/pages/wix_logo.svg +0 -18
- package/dist/examples-apps/ai-chatbot/src/dashboard/utils.ts +0 -27
- package/dist/examples-apps/custom-products-catalog/.nvmrc +0 -1
- package/dist/examples-apps/custom-products-catalog/README.md +0 -21
- package/dist/examples-apps/custom-products-catalog/package-lock.json +0 -8694
- package/dist/examples-apps/custom-products-catalog/package.json +0 -33
- package/dist/examples-apps/custom-products-catalog/src/dashboard/components/create-product.tsx +0 -54
- package/dist/examples-apps/custom-products-catalog/src/dashboard/hooks/stores.ts +0 -60
- package/dist/examples-apps/custom-products-catalog/src/dashboard/pages/page.json +0 -5
- package/dist/examples-apps/custom-products-catalog/src/dashboard/pages/page.tsx +0 -297
- package/dist/examples-apps/custom-products-catalog/src/dashboard/pages/wix_logo.svg +0 -18
- package/dist/examples-apps/custom-products-catalog/src/dashboard/withProviders.tsx +0 -16
- package/dist/examples-apps/custom-products-catalog/src/env.d.ts +0 -4
- package/dist/examples-apps/custom-products-catalog/tsconfig.json +0 -8
- package/dist/examples-apps/custom-products-catalog/wix.config.json +0 -5
- package/dist/examples-apps/site-popup/.nvmrc +0 -1
- package/dist/examples-apps/site-popup/README.md +0 -21
- package/dist/examples-apps/site-popup/package.json +0 -51
- package/dist/examples-apps/site-popup/src/components/activation-configuration.tsx +0 -49
- package/dist/examples-apps/site-popup/src/components/close-button.css +0 -33
- package/dist/examples-apps/site-popup/src/components/close-button.tsx +0 -31
- package/dist/examples-apps/site-popup/src/components/date-range-picker.tsx +0 -49
- package/dist/examples-apps/site-popup/src/components/image-picker.tsx +0 -33
- package/dist/examples-apps/site-popup/src/components/popup/index.css +0 -133
- package/dist/examples-apps/site-popup/src/components/popup/index.tsx +0 -71
- package/dist/examples-apps/site-popup/src/components/site-popup-settings.tsx +0 -120
- package/dist/examples-apps/site-popup/src/dashboard/hooks/wix-embeds.ts +0 -33
- package/dist/examples-apps/site-popup/src/dashboard/pages/page.tsx +0 -78
- package/dist/examples-apps/site-popup/src/dashboard/withProviders.tsx +0 -22
- package/dist/examples-apps/site-popup/src/extensions.ts +0 -20
- package/dist/examples-apps/site-popup/src/site/embedded-scripts/site-popup/embedded.html +0 -13
- package/dist/examples-apps/site-popup/src/site/embedded-scripts/site-popup/popup-overlay/index.css +0 -21
- package/dist/examples-apps/site-popup/src/site/embedded-scripts/site-popup/popup-overlay/index.tsx +0 -57
- package/dist/examples-apps/site-popup/src/types.ts +0 -14
- package/dist/examples-apps/site-popup/tsconfig.json +0 -9
- package/dist/examples-apps/site-popup/wix.config.json +0 -5
- package/dist/examples-apps/spis-examples/src/dashboard/pages/page.tsx +0 -59
- package/dist/examples-apps/spis-examples/src/dashboard/pages/wix_logo.svg +0 -18
- package/dist/examples-apps/top-blog-posts/.nvmrc +0 -1
- package/dist/examples-apps/top-blog-posts/README.md +0 -21
- package/dist/examples-apps/top-blog-posts/package-lock.json +0 -6406
- package/dist/examples-apps/top-blog-posts/package.json +0 -31
- package/dist/examples-apps/top-blog-posts/src/dashboard/pages/blog-utils.ts +0 -44
- package/dist/examples-apps/top-blog-posts/src/dashboard/pages/page.tsx +0 -129
- package/dist/examples-apps/top-blog-posts/src/dashboard/pages/wix_logo.svg +0 -18
- package/dist/examples-apps/top-blog-posts/src/env.d.ts +0 -4
- package/dist/examples-apps/top-blog-posts/tsconfig.json +0 -8
- package/dist/examples-apps/top-blog-posts/wix.config.json +0 -5
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { httpClient } from "@wix/essentials";
|
|
1
|
+
import { useCallback, useState, type FC } from "react";
|
|
2
|
+
import { productsV3 } from "@wix/stores";
|
|
4
3
|
import { Text, Box, Card, Input, Loader } from "@wix/design-system";
|
|
5
4
|
import * as Icons from "@wix/wix-ui-icons-common";
|
|
6
|
-
import type { ChatMessage } from '../../../types';
|
|
7
5
|
import styles from "./ProductChat.module.css";
|
|
8
6
|
|
|
7
|
+
export type ChatMessage = {
|
|
8
|
+
text: string;
|
|
9
|
+
author: "Business Buddy" | "User";
|
|
10
|
+
};
|
|
11
|
+
|
|
9
12
|
async function submitProductChatMessage(
|
|
10
13
|
messages: ChatMessage[],
|
|
11
|
-
product:
|
|
14
|
+
product: productsV3.V3Product,
|
|
12
15
|
) {
|
|
13
16
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const response = await fetch("/api/chat", {
|
|
18
|
+
method: "POST",
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
},
|
|
22
|
+
body: JSON.stringify({
|
|
23
|
+
messages,
|
|
24
|
+
product,
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
21
27
|
const message = await response.json();
|
|
22
28
|
|
|
23
29
|
return message;
|
|
@@ -27,7 +33,7 @@ async function submitProductChatMessage(
|
|
|
27
33
|
}
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
export const ProductChat: FC<{ product:
|
|
36
|
+
export const ProductChat: FC<{ product: productsV3.V3Product }> = ({ product }) => {
|
|
31
37
|
const [isWaitingForReply, setIsWaitingForReply] = useState<boolean>(false);
|
|
32
38
|
const [messageDraft, setMessageDraft] = useState<string>();
|
|
33
39
|
const [chatMessages, setChatMessages] = useState<ChatMessage[]>([]);
|
|
@@ -61,7 +67,7 @@ export const ProductChat: FC<{ product: products.Product }> = ({ product }) => {
|
|
|
61
67
|
<Card>
|
|
62
68
|
<Card.Header
|
|
63
69
|
title={`Ask Business Buddy about "${product.name}"`}
|
|
64
|
-
subtitle={`
|
|
70
|
+
subtitle={`Product ID: ${product._id}`}
|
|
65
71
|
/>
|
|
66
72
|
<Card.Content>
|
|
67
73
|
{chatMessages.map((message) => (
|
|
@@ -73,19 +79,19 @@ export const ProductChat: FC<{ product: products.Product }> = ({ product }) => {
|
|
|
73
79
|
))}
|
|
74
80
|
<Box width="100%" marginTop="SP6">
|
|
75
81
|
<Input
|
|
76
|
-
|
|
82
|
+
{...(styles.userInput && { className: styles.userInput })}
|
|
77
83
|
onChange={(e) => setMessageDraft(e.target.value)}
|
|
78
84
|
onEnterPressed={submitMessage}
|
|
79
85
|
disabled={isWaitingForReply}
|
|
80
|
-
value={messageDraft}
|
|
86
|
+
value={messageDraft ?? ""}
|
|
81
87
|
placeholder="Ask Business Buddy something..."
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
{...(isWaitingForReply && {
|
|
89
|
+
prefix: (
|
|
84
90
|
<Input.Affix>
|
|
85
91
|
<Loader size="tiny" />
|
|
86
92
|
</Input.Affix>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
93
|
+
),
|
|
94
|
+
})}
|
|
89
95
|
suffix={
|
|
90
96
|
<Input.IconAffix>
|
|
91
97
|
<Icons.Send onClick={submitMessage} />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useState, type FC } from "react";
|
|
2
2
|
import { useQuery } from "react-query";
|
|
3
|
-
import {
|
|
3
|
+
import { productsV3 } from "@wix/stores";
|
|
4
4
|
import {
|
|
5
5
|
AutoComplete,
|
|
6
6
|
Card,
|
|
@@ -14,16 +14,17 @@ import { withProviders } from "../../withProviders";
|
|
|
14
14
|
import { ProductChat } from "./ProductChat";
|
|
15
15
|
|
|
16
16
|
const ProductsPage: FC = () => {
|
|
17
|
-
const [currentProduct, setCurrentProduct] = useState<
|
|
17
|
+
const [currentProduct, setCurrentProduct] = useState<productsV3.V3Product>();
|
|
18
18
|
const [searchQuery, setSearchQuery] = useState<string>("");
|
|
19
19
|
|
|
20
20
|
const {
|
|
21
21
|
data: storeProducts,
|
|
22
22
|
isLoading,
|
|
23
23
|
error,
|
|
24
|
-
} = useQuery(["products", searchQuery], () =>
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
} = useQuery(["products", searchQuery], async () => {
|
|
25
|
+
const result = await productsV3.queryProducts().find();
|
|
26
|
+
return { items: result.items || [] };
|
|
27
|
+
});
|
|
27
28
|
|
|
28
29
|
const options = useMemo(
|
|
29
30
|
() =>
|
|
@@ -35,10 +36,10 @@ const ProductsPage: FC = () => {
|
|
|
35
36
|
);
|
|
36
37
|
|
|
37
38
|
const handleSelect = useCallback(
|
|
38
|
-
(event) => {
|
|
39
|
+
(event: { id: string | number }) => {
|
|
39
40
|
setCurrentProduct(
|
|
40
41
|
storeProducts!.items.find(
|
|
41
|
-
(product) => product._id === (event.id
|
|
42
|
+
(product) => product._id === String(event.id),
|
|
42
43
|
),
|
|
43
44
|
);
|
|
44
45
|
},
|
|
@@ -46,7 +47,7 @@ const ProductsPage: FC = () => {
|
|
|
46
47
|
);
|
|
47
48
|
|
|
48
49
|
const handleChange = useCallback(
|
|
49
|
-
(event) => {
|
|
50
|
+
(event: React.ChangeEvent<HTMLInputElement>) => {
|
|
50
51
|
setSearchQuery(event.target.value);
|
|
51
52
|
setCurrentProduct(undefined);
|
|
52
53
|
},
|
|
@@ -74,11 +75,11 @@ const ProductsPage: FC = () => {
|
|
|
74
75
|
<Card.Content>
|
|
75
76
|
<AutoComplete
|
|
76
77
|
size="large"
|
|
77
|
-
|
|
78
|
-
options
|
|
78
|
+
{...(isLoading && { status: "loading"})}
|
|
79
|
+
{...(options && { options })}
|
|
79
80
|
onSelect={handleSelect}
|
|
80
81
|
onChange={handleChange}
|
|
81
|
-
|
|
82
|
+
{...(currentProduct?.name && { value: currentProduct.name })}
|
|
82
83
|
placeholder="Select a product to chat about"
|
|
83
84
|
/>
|
|
84
85
|
</Card.Content>
|