shopify-chatbot-widget 0.8.4 → 0.8.6
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/jaweb-chatbot.css +1 -1
- package/dist/jaweb-chatbot.iife.js +148 -148
- package/package.json +1 -1
- package/src/Chatbot/Chatbot.tsx +4 -3
- package/src/Chatbot/components/Messages/Carousel/CardSwiperSalla.tsx +50 -29
- package/src/Chatbot/components/Messages/Carousel/CardSwiperZid.tsx +55 -27
- package/src/hooks/useChatbotData.tsx +4 -1
- package/src/types/chatbot.ts +1 -0
package/package.json
CHANGED
package/src/Chatbot/Chatbot.tsx
CHANGED
|
@@ -11,7 +11,7 @@ import { Spin } from 'antd';
|
|
|
11
11
|
import { motion, AnimatePresence } from 'framer-motion';
|
|
12
12
|
|
|
13
13
|
const Chatbot: React.FC = () => {
|
|
14
|
-
const [open, setOpen] = useState(
|
|
14
|
+
const [open, setOpen] = useState(true);
|
|
15
15
|
const [viewMode, setViewMode] = useState<'sessions' | 'create' | 'messenger'>('sessions');
|
|
16
16
|
const [activeSessionId, setActiveSessionId] = useState<string | null>(null);
|
|
17
17
|
const [HasInfo, setHasInfo] = useState(false);
|
|
@@ -30,6 +30,7 @@ const Chatbot: React.FC = () => {
|
|
|
30
30
|
isFetchingDetails,
|
|
31
31
|
calendly,
|
|
32
32
|
disbleCheckout,
|
|
33
|
+
chatbotName,
|
|
33
34
|
} = useChatbotData();
|
|
34
35
|
|
|
35
36
|
const [visitorData, setVisitorData] = useState<{ visitorId: string; country: string } | null>(null);
|
|
@@ -43,7 +44,7 @@ const Chatbot: React.FC = () => {
|
|
|
43
44
|
const newSessionId = crypto.randomUUID();
|
|
44
45
|
setActiveSessionId(newSessionId);
|
|
45
46
|
setActiveAgentImage(chatbotLogo);
|
|
46
|
-
setActiveAgentName(
|
|
47
|
+
setActiveAgentName(chatbotName);
|
|
47
48
|
setNewSession(true);
|
|
48
49
|
setViewMode('messenger');
|
|
49
50
|
}
|
|
@@ -188,7 +189,7 @@ const Chatbot: React.FC = () => {
|
|
|
188
189
|
<Messenger
|
|
189
190
|
sessionId={activeSessionId}
|
|
190
191
|
chatbotLogo={activeAgentImage || chatbotLogo}
|
|
191
|
-
agentName={activeAgentName ||
|
|
192
|
+
agentName={activeAgentName || chatbotName || "Ai Assistant"}
|
|
192
193
|
colorCode={colorCode}
|
|
193
194
|
messagesSuggestions={messagesSuggestions}
|
|
194
195
|
newSession={newSession}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React,{useState} from 'react';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import 'keen-slider/keen-slider.min.css';
|
|
4
4
|
import type { KeenSliderInstance } from 'keen-slider/react';
|
|
5
5
|
import './SallaSwiper.css';
|
|
6
|
+
import { Button } from 'antd';
|
|
7
|
+
import TryOnBox from "./TryOn";
|
|
6
8
|
|
|
7
9
|
interface ProductVariant {
|
|
8
10
|
variant_id: string;
|
|
@@ -35,10 +37,10 @@ const SallaProductCarousel: FC<Props> = ({
|
|
|
35
37
|
groupedProducts,
|
|
36
38
|
selectedVariants,
|
|
37
39
|
setSelectedVariants,
|
|
38
|
-
counts,
|
|
39
|
-
setCounts,
|
|
40
|
-
handleAddToCart,
|
|
41
|
-
handleRemoveFromCart,
|
|
40
|
+
// counts,
|
|
41
|
+
// setCounts,
|
|
42
|
+
// handleAddToCart,
|
|
43
|
+
// handleRemoveFromCart,
|
|
42
44
|
colorCode = '#7F28F8',
|
|
43
45
|
shortenName,
|
|
44
46
|
sliderRef,
|
|
@@ -47,6 +49,7 @@ const SallaProductCarousel: FC<Props> = ({
|
|
|
47
49
|
totalSlides,
|
|
48
50
|
}) => {
|
|
49
51
|
if (!totalSlides || totalSlides === 0) return null;
|
|
52
|
+
const [openTryOn, setOpenTryOn] = useState<string | null>(null);
|
|
50
53
|
|
|
51
54
|
return (
|
|
52
55
|
<section
|
|
@@ -69,7 +72,7 @@ const SallaProductCarousel: FC<Props> = ({
|
|
|
69
72
|
|
|
70
73
|
if (!currentVariant) return null;
|
|
71
74
|
|
|
72
|
-
const count = counts[currentVariant.variant_id] || 0;
|
|
75
|
+
// const count = counts[currentVariant.variant_id] || 0;
|
|
73
76
|
|
|
74
77
|
// Build unique, cleaned list of options (exclude empty/'none')
|
|
75
78
|
const options = Array.from(
|
|
@@ -91,27 +94,30 @@ const SallaProductCarousel: FC<Props> = ({
|
|
|
91
94
|
}
|
|
92
95
|
};
|
|
93
96
|
|
|
94
|
-
const increment = async () => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const decrement = async () => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
};
|
|
97
|
+
// const increment = async () => {
|
|
98
|
+
// setCounts(prev => ({
|
|
99
|
+
// ...prev,
|
|
100
|
+
// [currentVariant.variant_id]: (prev[currentVariant.variant_id] || 0) + 1,
|
|
101
|
+
// }));
|
|
102
|
+
// await handleAddToCart(currentVariant.variant_id, currentVariant.name, 1);
|
|
103
|
+
// };
|
|
104
|
+
|
|
105
|
+
// const decrement = async () => {
|
|
106
|
+
// if (count === 0) return;
|
|
107
|
+
// setCounts(prev => ({
|
|
108
|
+
// ...prev,
|
|
109
|
+
// [currentVariant.variant_id]: Math.max(
|
|
110
|
+
// 0,
|
|
111
|
+
// (prev[currentVariant.variant_id] || 0) - 1
|
|
112
|
+
// ),
|
|
113
|
+
// }));
|
|
114
|
+
// await handleRemoveFromCart(currentVariant.variant_id, 1);
|
|
115
|
+
// };
|
|
113
116
|
|
|
114
117
|
// Ensure the select has a stable value (fallback to first option)
|
|
118
|
+
|
|
119
|
+
const isTryOnOpen = openTryOn === currentVariant.variant_id;
|
|
120
|
+
|
|
115
121
|
const selectValue = (currentVariant.option ?? options[0] ?? '');
|
|
116
122
|
|
|
117
123
|
return (
|
|
@@ -174,8 +180,17 @@ const SallaProductCarousel: FC<Props> = ({
|
|
|
174
180
|
</div>
|
|
175
181
|
)}
|
|
176
182
|
|
|
177
|
-
|
|
178
|
-
<
|
|
183
|
+
|
|
184
|
+
<Button
|
|
185
|
+
style={{ backgroundColor: colorCode, color: "white" }}
|
|
186
|
+
className="px-6 py-2 rounded-lg shadow-md transition"
|
|
187
|
+
onClick={() =>
|
|
188
|
+
setOpenTryOn(isTryOnOpen ? null : currentVariant.variant_id)
|
|
189
|
+
}
|
|
190
|
+
>
|
|
191
|
+
{isTryOnOpen ? "Close Try On" : "Try On"}
|
|
192
|
+
</Button>
|
|
193
|
+
{/* <button
|
|
179
194
|
type="button"
|
|
180
195
|
className="sallaX-qty sallaX-qty--minus"
|
|
181
196
|
onClick={decrement}
|
|
@@ -194,8 +209,14 @@ const SallaProductCarousel: FC<Props> = ({
|
|
|
194
209
|
aria-label="Increase quantity"
|
|
195
210
|
>
|
|
196
211
|
+
|
|
197
|
-
</button>
|
|
198
|
-
|
|
212
|
+
</button> */}
|
|
213
|
+
|
|
214
|
+
{ isTryOnOpen && (
|
|
215
|
+
<div className="mt-4">
|
|
216
|
+
<TryOnBox productID={currentVariant.variant_id} productImage={currentVariant.image} />
|
|
217
|
+
</div>
|
|
218
|
+
)}
|
|
219
|
+
|
|
199
220
|
</div>
|
|
200
221
|
</article>
|
|
201
222
|
);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React,{useState} from 'react';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import 'keen-slider/keen-slider.min.css';
|
|
4
4
|
import type { KeenSliderInstance } from 'keen-slider/react';
|
|
5
|
+
import { Button } from 'antd';
|
|
5
6
|
import './SallaSwiper.css';
|
|
7
|
+
import TryOnBox from "./TryOn";
|
|
6
8
|
|
|
7
9
|
interface ProductVariant {
|
|
8
10
|
variant_id: string;
|
|
@@ -31,14 +33,16 @@ interface Props {
|
|
|
31
33
|
totalSlides: number;
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
|
|
37
|
+
|
|
34
38
|
const ZidProductCarousel: FC<Props> = ({
|
|
35
39
|
groupedProducts,
|
|
36
40
|
selectedVariants,
|
|
37
41
|
setSelectedVariants,
|
|
38
|
-
counts,
|
|
39
|
-
setCounts,
|
|
40
|
-
handleAddToCart,
|
|
41
|
-
handleRemoveFromCart,
|
|
42
|
+
// counts,
|
|
43
|
+
// setCounts,
|
|
44
|
+
// handleAddToCart,
|
|
45
|
+
// handleRemoveFromCart,
|
|
42
46
|
colorCode = '#7F28F8',
|
|
43
47
|
shortenName,
|
|
44
48
|
sliderRef,
|
|
@@ -46,6 +50,9 @@ const ZidProductCarousel: FC<Props> = ({
|
|
|
46
50
|
// currentSlide, // currently unused
|
|
47
51
|
totalSlides,
|
|
48
52
|
}) => {
|
|
53
|
+
|
|
54
|
+
const [openTryOn, setOpenTryOn] = useState<string | null>(null);
|
|
55
|
+
|
|
49
56
|
if (!totalSlides || totalSlides === 0) return null;
|
|
50
57
|
|
|
51
58
|
return (
|
|
@@ -69,7 +76,7 @@ const ZidProductCarousel: FC<Props> = ({
|
|
|
69
76
|
|
|
70
77
|
if (!currentVariant) return null;
|
|
71
78
|
|
|
72
|
-
const count = counts[currentVariant.variant_id] || 0;
|
|
79
|
+
// const count = counts[currentVariant.variant_id] || 0;
|
|
73
80
|
|
|
74
81
|
// Build unique, cleaned list of options (exclude empty/'none')
|
|
75
82
|
const options = Array.from(
|
|
@@ -91,25 +98,27 @@ const ZidProductCarousel: FC<Props> = ({
|
|
|
91
98
|
}
|
|
92
99
|
};
|
|
93
100
|
|
|
94
|
-
const increment = async () => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const decrement = async () => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
};
|
|
101
|
+
// const increment = async () => {
|
|
102
|
+
// setCounts(prev => ({
|
|
103
|
+
// ...prev,
|
|
104
|
+
// [currentVariant.variant_id]: (prev[currentVariant.variant_id] || 0) + 1,
|
|
105
|
+
// }));
|
|
106
|
+
// await handleAddToCart(currentVariant.variant_id, currentVariant.name, 1);
|
|
107
|
+
// };
|
|
108
|
+
|
|
109
|
+
// const decrement = async () => {
|
|
110
|
+
// if (count === 0) return;
|
|
111
|
+
// setCounts(prev => ({
|
|
112
|
+
// ...prev,
|
|
113
|
+
// [currentVariant.variant_id]: Math.max(
|
|
114
|
+
// 0,
|
|
115
|
+
// (prev[currentVariant.variant_id] || 0) - 1
|
|
116
|
+
// ),
|
|
117
|
+
// }));
|
|
118
|
+
// await handleRemoveFromCart(currentVariant.variant_id, 1);
|
|
119
|
+
// };
|
|
120
|
+
|
|
121
|
+
const isTryOnOpen = openTryOn === currentVariant.variant_id;
|
|
113
122
|
|
|
114
123
|
// Ensure the select has a stable value (fallback to first option)
|
|
115
124
|
const selectValue = (currentVariant.option ?? options[0] ?? '');
|
|
@@ -174,7 +183,20 @@ const ZidProductCarousel: FC<Props> = ({
|
|
|
174
183
|
</div>
|
|
175
184
|
)}
|
|
176
185
|
|
|
177
|
-
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
<Button
|
|
189
|
+
style={{ backgroundColor: colorCode, color: "white" }}
|
|
190
|
+
className="px-6 py-2 rounded-lg shadow-md transition"
|
|
191
|
+
onClick={() =>
|
|
192
|
+
setOpenTryOn(isTryOnOpen ? null : currentVariant.variant_id)
|
|
193
|
+
}
|
|
194
|
+
>
|
|
195
|
+
{isTryOnOpen ? "Close Try On" : "Try On"}
|
|
196
|
+
</Button>
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
{/* <div className="sallaX-cta" aria-label="Quantity controls">
|
|
178
200
|
<button
|
|
179
201
|
type="button"
|
|
180
202
|
className="sallaX-qty sallaX-qty--minus"
|
|
@@ -195,7 +217,13 @@ const ZidProductCarousel: FC<Props> = ({
|
|
|
195
217
|
>
|
|
196
218
|
+
|
|
197
219
|
</button>
|
|
198
|
-
</div>
|
|
220
|
+
</div> */}
|
|
221
|
+
{ isTryOnOpen && (
|
|
222
|
+
<div className="mt-4">
|
|
223
|
+
<TryOnBox productID={currentVariant.variant_id} productImage={currentVariant.image} />
|
|
224
|
+
</div>
|
|
225
|
+
)}
|
|
226
|
+
|
|
199
227
|
</div>
|
|
200
228
|
</article>
|
|
201
229
|
);
|
|
@@ -25,6 +25,7 @@ export const useChatbotData = () => {
|
|
|
25
25
|
const [restSuggestions, setRestSuggestions] = useState<string[]>([]);
|
|
26
26
|
const [userType,setUserType]=useState('')
|
|
27
27
|
const [disbleCheckout, setDisbleCheckout] = useState(false);
|
|
28
|
+
const [chatbotName,setchatbotName]=useState('')
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
const fetchData = async (retryCount = 0) => {
|
|
@@ -67,6 +68,7 @@ export const useChatbotData = () => {
|
|
|
67
68
|
setUserType(data.mode)
|
|
68
69
|
setCalendly(data.calendly_link ?? null);
|
|
69
70
|
setDisbleCheckout(data.disable_checkout)
|
|
71
|
+
setchatbotName(data.chatbot_name)
|
|
70
72
|
|
|
71
73
|
|
|
72
74
|
|
|
@@ -127,6 +129,7 @@ export const useChatbotData = () => {
|
|
|
127
129
|
messagesSuggestions,
|
|
128
130
|
restSuggestions,
|
|
129
131
|
userType,
|
|
130
|
-
disbleCheckout
|
|
132
|
+
disbleCheckout,
|
|
133
|
+
chatbotName
|
|
131
134
|
};
|
|
132
135
|
};
|