shopify-chatbot-widget 0.0.4 → 0.0.7

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.
Files changed (46) hide show
  1. package/dist/jaweb-chatbot.css +1 -0
  2. package/dist/jaweb-chatbot.iife.js +685 -0
  3. package/dist/vite.svg +1 -0
  4. package/package.json +1 -1
  5. package/src/App.css +0 -42
  6. package/src/App.tsx +0 -13
  7. package/src/Chatbot/Chatbot.css +0 -154
  8. package/src/Chatbot/Chatbot.tsx +0 -207
  9. package/src/Chatbot/components/ChatInput.css +0 -127
  10. package/src/Chatbot/components/ChatInput.tsx +0 -262
  11. package/src/Chatbot/components/Messages/Addcart.tsx +0 -70
  12. package/src/Chatbot/components/Messages/AgentStatus.tsx +0 -37
  13. package/src/Chatbot/components/Messages/AssistantMesage.tsx +0 -316
  14. package/src/Chatbot/components/Messages/AudioMessage.tsx +0 -123
  15. package/src/Chatbot/components/Messages/CartWidget.tsx +0 -116
  16. package/src/Chatbot/components/Messages/ChatImage.tsx +0 -46
  17. package/src/Chatbot/components/Messages/ChatImageText.tsx +0 -74
  18. package/src/Chatbot/components/Messages/ChatImageTextAssis.tsx +0 -72
  19. package/src/Chatbot/components/Messages/ChatMessages.css +0 -5
  20. package/src/Chatbot/components/Messages/ChatMessages.tsx +0 -284
  21. package/src/Chatbot/components/Messages/Support.tsx +0 -177
  22. package/src/Chatbot/components/Messages/Typing.css +0 -27
  23. package/src/Chatbot/components/Messages/Typing.tsx +0 -14
  24. package/src/Chatbot/components/Messages/ZidAssistantMesage.tsx +0 -142
  25. package/src/Chatbot/components/Messenger/Messenger.tsx +0 -521
  26. package/src/Chatbot/components/Notification.tsx +0 -27
  27. package/src/Chatbot/components/Powered.css +0 -16
  28. package/src/Chatbot/components/Powered.tsx +0 -13
  29. package/src/Chatbot/components/Sessions/CreateSession.tsx +0 -139
  30. package/src/Chatbot/components/Sessions/RenderList.tsx +0 -202
  31. package/src/Chatbot/components/Suggestions.css +0 -34
  32. package/src/Chatbot/components/Suggestions.tsx +0 -28
  33. package/src/assets/react.svg +0 -1
  34. package/src/chatbot-widget/index.tsx +0 -14
  35. package/src/hooks/config.tsx +0 -13
  36. package/src/hooks/useCart.tsx +0 -99
  37. package/src/hooks/useChatbotAPI.tsx +0 -160
  38. package/src/hooks/useChatbotData.tsx +0 -129
  39. package/src/hooks/useSessionMessages.tsx +0 -51
  40. package/src/hooks/useWebsocke.tsx +0 -45
  41. package/src/i18n.tsx +0 -30
  42. package/src/index.css +0 -1
  43. package/src/main.tsx +0 -10
  44. package/src/types/chatbot.ts +0 -38
  45. package/src/utils/cookies.tsx +0 -14
  46. package/src/vite-env.d.ts +0 -1
@@ -1,51 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import axios from 'axios';
3
- import { getCookie } from '../utils/cookies';
4
- import config from './config';
5
- import type { ChatMessage } from '../types/chatbot';
6
-
7
- export const useChatbotMessage = (sessionId: string | null) => {
8
- const [messages, setMessages] = useState<ChatMessage[]>([]);
9
- const [isFetchingMessages, setisFetchingMessages] = useState(false);
10
-
11
-
12
- const loadHistory = async () => {
13
- const sid = sessionId
14
- if (!sid) return;
15
-
16
- setisFetchingMessages(true);
17
-
18
-
19
- try {
20
- const res = await axios.get<{ messages: ChatMessage[] }>(
21
- `${config.apiUrl}chat-message-history/`,
22
- {
23
- withCredentials: true,
24
- params: {
25
- session_id: sid,
26
- username: getCookie('company_username'),
27
- },
28
- }
29
- );
30
-
31
-
32
- if (res.data?.messages?.length > 0) {
33
- setMessages(res.data.messages);
34
- setisFetchingMessages(false)
35
-
36
- }
37
- } catch (err) {
38
- console.error("Couldn't load history", err);
39
- }
40
- };
41
-
42
- useEffect(() => {
43
- loadHistory();
44
- }, [sessionId]);
45
-
46
- return {
47
- messages,
48
- setMessages,
49
- isFetchingMessages
50
- };
51
- };
@@ -1,45 +0,0 @@
1
- // hooks/useChatSocket.ts
2
- import { useEffect, useRef } from 'react';
3
- import config from './config';
4
-
5
- export default function useChatSocket(
6
- session_id: string,
7
- onMessage: (data: any) => void
8
- ) {
9
- const socketRef = useRef<WebSocket | null>(null);
10
- // keep a stable ref to the latest onMessage
11
- const onMessageRef = useRef(onMessage);
12
- useEffect(() => {
13
- onMessageRef.current = onMessage;
14
- }, [onMessage]);
15
-
16
- useEffect(() => {
17
- if (!session_id) return;
18
-
19
- const ws = new WebSocket(`${config.websocketUrl}/chat/${session_id}/`);
20
- socketRef.current = ws;
21
-
22
- // precise add/remove so we never leak handlers
23
- const handle = (event: MessageEvent) => {
24
- try {
25
- const data = JSON.parse(event.data);
26
- onMessageRef.current(data);
27
- } catch (e) {
28
- console.error('Invalid JSON', e);
29
- }
30
- };
31
- ws.addEventListener('message', handle);
32
-
33
- // you can still do onopen/onclose, but tear them down too if you attach them
34
- const handleClose = () => { /* reconnect logic… */ };
35
- ws.addEventListener('close', handleClose);
36
-
37
- return () => {
38
- ws.removeEventListener('message', handle);
39
- ws.removeEventListener('close', handleClose);
40
- ws.close();
41
- };
42
- }, [session_id]);
43
-
44
- return socketRef.current;
45
- }
package/src/i18n.tsx DELETED
@@ -1,30 +0,0 @@
1
- // src/i18n.ts
2
- import i18n from 'i18next';
3
- import { initReactI18next } from 'react-i18next';
4
-
5
- const resources = {
6
- en: {
7
- translation: {
8
- welcome: "Hi there, you’re speaking with Jaweb AI Assistant.",
9
- // Add more English translations here
10
- },
11
- },
12
- ar: {
13
- translation: {
14
- welcome: "مرحبًا، أنت تتحدث إلى مساعد Jaweb AI.",
15
- // Add more Arabic translations here
16
- },
17
- },
18
- };
19
-
20
- i18n.use(initReactI18next).init({
21
- resources,
22
- lng: 'en', // default language
23
- fallbackLng: 'en',
24
-
25
- interpolation: {
26
- escapeValue: false, // React already escapes
27
- },
28
- });
29
-
30
- export default i18n;
package/src/index.css DELETED
@@ -1 +0,0 @@
1
- @import "tailwindcss";
package/src/main.tsx DELETED
@@ -1,10 +0,0 @@
1
- import { StrictMode } from 'react'
2
- import { createRoot } from 'react-dom/client'
3
- import './index.css'
4
- import App from './App.tsx'
5
-
6
- createRoot(document.getElementById('root')!).render(
7
- <StrictMode>
8
- <App />
9
- </StrictMode>,
10
- )
@@ -1,38 +0,0 @@
1
- // types/chatbot.ts
2
-
3
- export interface ChatbotDetailsResponse {
4
- data: {
5
- language: string;
6
- chatbot_form: boolean;
7
- chatbot_color: string;
8
- chatbot_logo: string;
9
- disable_chatbot_globally: boolean;
10
- remove_powered_by_jaweb: boolean;
11
- chatbot_initial_msg: string;
12
- status: string;
13
- calendly_link?: string | null;
14
- phone_number_id?: string | null;
15
- mode:string;
16
- };
17
- }
18
-
19
- export interface SuggestionResponse {
20
- data?: string[]; // when data is returned directly
21
- user_questions?: string[] | null; // when API sends it here
22
- }
23
-
24
-
25
- export interface ChatMessage {
26
- role?: 'user' | 'bot' | 'assistant' | 'system';
27
- content?:string;
28
- isBusiness?:boolean;
29
- sender?:string;
30
- typing?: boolean;
31
- id?:Number;
32
- image_url?:string;
33
- status?:string;
34
- audio_url?: string;
35
- isConnect?:boolean;
36
-
37
-
38
- }
@@ -1,14 +0,0 @@
1
- // utils/cookies.ts
2
- import Cookies from 'js-cookie';
3
-
4
- export const getCookie = (key: string): string | undefined => {
5
- return Cookies.get(key);
6
- };
7
-
8
- export const setCookie = (key: string, value: string, days = 30): void => {
9
- Cookies.set(key, value, { expires: days });
10
- };
11
-
12
- export const removeCookie = (key: string): void => {
13
- Cookies.remove(key);
14
- };
package/src/vite-env.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />