@daeryun/dr_components 1.2.18 → 1.2.19
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/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/components/Daeryuntalk/ChatButton.jsx +1 -1
- package/dist/components/Daeryuntalk/ChatButton.tsx +1 -1
- package/dist/components/Daeryuntalk/ChatWidget.d.ts +1 -0
- package/dist/components/Daeryuntalk/ChatWidget.jsx +114 -31
- package/dist/components/Daeryuntalk/ChatWidget.tsx +120 -37
- package/dist/components/Daeryuntalk/Viewer/TbPcViewer.tsx +0 -9
- package/dist/components/Daeryuntalk/index.jsx +17 -1
- package/dist/components/Daeryuntalk/index.tsx +26 -2
- package/dist/components/DaeryuntalkBackup/ChatButton.d.ts +11 -0
- package/dist/components/DaeryuntalkBackup/ChatButton.jsx +123 -0
- package/dist/components/DaeryuntalkBackup/ChatButton.tsx +157 -0
- package/dist/components/DaeryuntalkBackup/ChatConversation.d.ts +21 -0
- package/dist/components/DaeryuntalkBackup/ChatConversation.jsx +259 -0
- package/dist/components/DaeryuntalkBackup/ChatConversation.tsx +390 -0
- package/dist/components/DaeryuntalkBackup/ChatConversationItem/ChatConversationHeader.d.ts +16 -0
- package/dist/components/DaeryuntalkBackup/ChatConversationItem/ChatConversationHeader.jsx +50 -0
- package/dist/components/DaeryuntalkBackup/ChatConversationItem/ChatConversationHeader.tsx +108 -0
- package/dist/components/DaeryuntalkBackup/ChatHomeView.d.ts +14 -0
- package/dist/components/DaeryuntalkBackup/ChatHomeView.jsx +147 -0
- package/dist/components/DaeryuntalkBackup/ChatHomeView.tsx +262 -0
- package/dist/components/DaeryuntalkBackup/ChatInput.d.ts +8 -0
- package/dist/components/DaeryuntalkBackup/ChatInput.jsx +64 -0
- package/dist/components/DaeryuntalkBackup/ChatInput.tsx +98 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/AgeCheckBox.d.ts +6 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/AgeCheckBox.jsx +19 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/AgeCheckBox.tsx +27 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/ChatFile.d.ts +10 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/ChatFile.jsx +165 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/ChatFile.tsx +244 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/ChatLoading.d.ts +6 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/ChatLoading.jsx +12 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/ChatLoading.tsx +25 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/ChatPrivacyAuth.d.ts +8 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/ChatPrivacyAuth.jsx +100 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/ChatPrivacyAuth.tsx +135 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/ChatWrapper.d.ts +8 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/ChatWrapper.jsx +14 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/ChatWrapper.tsx +26 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/RichText.d.ts +7 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/RichText.jsx +37 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/RichText.tsx +45 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/TimeWrapper.d.ts +9 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/TimeWrapper.jsx +10 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/TimeWrapper.tsx +21 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/TypingComp.d.ts +3 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/TypingComp.jsx +34 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/TypingComp.tsx +43 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowAuthForm.d.ts +8 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowAuthForm.jsx +20 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowAuthForm.tsx +32 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowClickData.d.ts +7 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowClickData.jsx +21 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowClickData.tsx +37 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowImg.d.ts +9 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowImg.jsx +178 -0
- package/dist/components/DaeryuntalkBackup/ChatItem/WorkFlowImg.tsx +233 -0
- package/dist/components/DaeryuntalkBackup/ChatMessage.d.ts +20 -0
- package/dist/components/DaeryuntalkBackup/ChatMessage.jsx +198 -0
- package/dist/components/DaeryuntalkBackup/ChatMessage.tsx +295 -0
- package/dist/components/DaeryuntalkBackup/ChatObject/FieldWorkObject.d.ts +9 -0
- package/dist/components/DaeryuntalkBackup/ChatObject/FieldWorkObject.jsx +39 -0
- package/dist/components/DaeryuntalkBackup/ChatObject/FieldWorkObject.tsx +75 -0
- package/dist/components/DaeryuntalkBackup/ChatObject/ObjectBack.d.ts +7 -0
- package/dist/components/DaeryuntalkBackup/ChatObject/ObjectBack.jsx +20 -0
- package/dist/components/DaeryuntalkBackup/ChatObject/ObjectBack.tsx +39 -0
- package/dist/components/DaeryuntalkBackup/ChatObject/ObjectButton.d.ts +10 -0
- package/dist/components/DaeryuntalkBackup/ChatObject/ObjectButton.jsx +138 -0
- package/dist/components/DaeryuntalkBackup/ChatObject/ObjectButton.tsx +177 -0
- package/dist/components/DaeryuntalkBackup/ChatWidget.d.ts +13 -0
- package/dist/components/DaeryuntalkBackup/ChatWidget.jsx +154 -0
- package/dist/components/DaeryuntalkBackup/ChatWidget.tsx +221 -0
- package/dist/components/DaeryuntalkBackup/DaeryuntalkContext.d.ts +103 -0
- package/dist/components/DaeryuntalkBackup/DaeryuntalkContext.jsx +207 -0
- package/dist/components/DaeryuntalkBackup/DaeryuntalkContext.tsx +350 -0
- package/dist/components/DaeryuntalkBackup/DateSeparator.d.ts +6 -0
- package/dist/components/DaeryuntalkBackup/DateSeparator.jsx +14 -0
- package/dist/components/DaeryuntalkBackup/DateSeparator.tsx +24 -0
- package/dist/components/DaeryuntalkBackup/FixedErrorBox.d.ts +7 -0
- package/dist/components/DaeryuntalkBackup/FixedErrorBox.jsx +34 -0
- package/dist/components/DaeryuntalkBackup/FixedErrorBox.tsx +73 -0
- package/dist/components/DaeryuntalkBackup/History/AuthForm.d.ts +10 -0
- package/dist/components/DaeryuntalkBackup/History/AuthForm.jsx +157 -0
- package/dist/components/DaeryuntalkBackup/History/AuthForm.tsx +206 -0
- package/dist/components/DaeryuntalkBackup/HistoryView.d.ts +19 -0
- package/dist/components/DaeryuntalkBackup/HistoryView.jsx +94 -0
- package/dist/components/DaeryuntalkBackup/HistoryView.tsx +182 -0
- package/dist/components/DaeryuntalkBackup/HomeView.d.ts +12 -0
- package/dist/components/DaeryuntalkBackup/HomeView.jsx +178 -0
- package/dist/components/DaeryuntalkBackup/HomeView.tsx +261 -0
- package/dist/components/DaeryuntalkBackup/NavigationFooter.d.ts +11 -0
- package/dist/components/DaeryuntalkBackup/NavigationFooter.jsx +44 -0
- package/dist/components/DaeryuntalkBackup/NavigationFooter.tsx +98 -0
- package/dist/components/DaeryuntalkBackup/NoticeMessage.d.ts +7 -0
- package/dist/components/DaeryuntalkBackup/NoticeMessage.jsx +40 -0
- package/dist/components/DaeryuntalkBackup/NoticeMessage.tsx +60 -0
- package/dist/components/DaeryuntalkBackup/Tiptap/DisabledInput.d.ts +6 -0
- package/dist/components/DaeryuntalkBackup/Tiptap/DisabledInput.jsx +17 -0
- package/dist/components/DaeryuntalkBackup/Tiptap/DisabledInput.tsx +28 -0
- package/dist/components/DaeryuntalkBackup/Tiptap/Tiptap.d.ts +20 -0
- package/dist/components/DaeryuntalkBackup/Tiptap/Tiptap.jsx +130 -0
- package/dist/components/DaeryuntalkBackup/Tiptap/Tiptap.tsx +181 -0
- package/dist/components/DaeryuntalkBackup/Toast/DaeryuntalkToastProvider.d.ts +23 -0
- package/dist/components/DaeryuntalkBackup/Toast/DaeryuntalkToastProvider.jsx +40 -0
- package/dist/components/DaeryuntalkBackup/Toast/DaeryuntalkToastProvider.tsx +70 -0
- package/dist/components/DaeryuntalkBackup/Toast/Toast.d.ts +11 -0
- package/dist/components/DaeryuntalkBackup/Toast/Toast.jsx +64 -0
- package/dist/components/DaeryuntalkBackup/Toast/Toast.tsx +98 -0
- package/dist/components/DaeryuntalkBackup/Toast/ToastRender.d.ts +1 -0
- package/dist/components/DaeryuntalkBackup/Toast/ToastRender.jsx +22 -0
- package/dist/components/DaeryuntalkBackup/Toast/ToastRender.tsx +30 -0
- package/dist/components/DaeryuntalkBackup/Viewer/ImageViewer.d.ts +9 -0
- package/dist/components/DaeryuntalkBackup/Viewer/ImageViewer.jsx +98 -0
- package/dist/components/DaeryuntalkBackup/Viewer/ImageViewer.tsx +138 -0
- package/dist/components/DaeryuntalkBackup/Viewer/MobileViewer.d.ts +18 -0
- package/dist/components/DaeryuntalkBackup/Viewer/MobileViewer.jsx +104 -0
- package/dist/components/DaeryuntalkBackup/Viewer/MobileViewer.tsx +182 -0
- package/dist/components/DaeryuntalkBackup/Viewer/TbPcViewer.d.ts +24 -0
- package/dist/components/DaeryuntalkBackup/Viewer/TbPcViewer.jsx +141 -0
- package/dist/components/DaeryuntalkBackup/Viewer/TbPcViewer.tsx +278 -0
- package/dist/components/DaeryuntalkBackup/ViewportHandler.d.ts +6 -0
- package/dist/components/DaeryuntalkBackup/ViewportHandler.jsx +25 -0
- package/dist/components/DaeryuntalkBackup/ViewportHandler.tsx +32 -0
- package/dist/components/DaeryuntalkBackup/_api/daeryuntalk/index.d.ts +177 -0
- package/dist/components/DaeryuntalkBackup/_api/daeryuntalk/index.js +801 -0
- package/dist/components/DaeryuntalkBackup/_api/daeryuntalk/index.ts +1097 -0
- package/dist/components/DaeryuntalkBackup/_api/daeryuntalk/type/response.d.ts +131 -0
- package/dist/components/DaeryuntalkBackup/_api/daeryuntalk/type/response.js +1 -0
- package/dist/components/DaeryuntalkBackup/_api/daeryuntalk/type/response.ts +159 -0
- package/dist/components/DaeryuntalkBackup/_api/index.d.ts +6 -0
- package/dist/components/DaeryuntalkBackup/_api/index.js +6 -0
- package/dist/components/DaeryuntalkBackup/_api/index.ts +7 -0
- package/dist/components/DaeryuntalkBackup/_enums/ags_check_status.d.ts +5 -0
- package/dist/components/DaeryuntalkBackup/_enums/ags_check_status.js +9 -0
- package/dist/components/DaeryuntalkBackup/_enums/ags_check_status.ts +9 -0
- package/dist/components/DaeryuntalkBackup/_enums/ask-status.d.ts +13 -0
- package/dist/components/DaeryuntalkBackup/_enums/ask-status.js +25 -0
- package/dist/components/DaeryuntalkBackup/_enums/ask-status.ts +26 -0
- package/dist/components/DaeryuntalkBackup/_enums/error.d.ts +109 -0
- package/dist/components/DaeryuntalkBackup/_enums/error.js +254 -0
- package/dist/components/DaeryuntalkBackup/_enums/error.ts +289 -0
- package/dist/components/DaeryuntalkBackup/_enums/message_type.d.ts +6 -0
- package/dist/components/DaeryuntalkBackup/_enums/message_type.js +13 -0
- package/dist/components/DaeryuntalkBackup/_enums/message_type.ts +13 -0
- package/dist/components/DaeryuntalkBackup/_enums/sender_type.d.ts +8 -0
- package/dist/components/DaeryuntalkBackup/_enums/sender_type.js +16 -0
- package/dist/components/DaeryuntalkBackup/_enums/sender_type.ts +16 -0
- package/dist/components/DaeryuntalkBackup/_enums/socket_type.d.ts +34 -0
- package/dist/components/DaeryuntalkBackup/_enums/socket_type.js +46 -0
- package/dist/components/DaeryuntalkBackup/_enums/socket_type.ts +56 -0
- package/dist/components/DaeryuntalkBackup/_enums/template.d.ts +32 -0
- package/dist/components/DaeryuntalkBackup/_enums/template.js +76 -0
- package/dist/components/DaeryuntalkBackup/_enums/template.ts +81 -0
- package/dist/components/DaeryuntalkBackup/_enums/work_flow_object_expose.d.ts +33 -0
- package/dist/components/DaeryuntalkBackup/_enums/work_flow_object_expose.js +66 -0
- package/dist/components/DaeryuntalkBackup/_enums/work_flow_object_expose.ts +71 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useChatHandler.d.ts +48 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useChatHandler.js +465 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useChatHandler.ts +595 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useFullURL.d.ts +1 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useFullURL.jsx +15 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useFullURL.tsx +17 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useHistoryHandler.d.ts +24 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useHistoryHandler.js +112 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useHistoryHandler.ts +144 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useSocketEventHandler.d.ts +44 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useSocketEventHandler.js +534 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useSocketEventHandler.ts +706 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useViewerHook.d.ts +8 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useViewerHook.js +18 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useViewerHook.ts +23 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useWorkFlow.d.ts +9 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useWorkFlow.js +109 -0
- package/dist/components/DaeryuntalkBackup/_hooks/talkprovider/useWorkFlow.ts +121 -0
- package/dist/components/DaeryuntalkBackup/_hooks/useHoverScrollbar.d.ts +12 -0
- package/dist/components/DaeryuntalkBackup/_hooks/useHoverScrollbar.js +48 -0
- package/dist/components/DaeryuntalkBackup/_hooks/useHoverScrollbar.ts +73 -0
- package/dist/components/DaeryuntalkBackup/_hooks/useScrollShadow.d.ts +7 -0
- package/dist/components/DaeryuntalkBackup/_hooks/useScrollShadow.js +42 -0
- package/dist/components/DaeryuntalkBackup/_hooks/useScrollShadow.ts +52 -0
- package/dist/components/DaeryuntalkBackup/_hooks/useWindowSize.d.ts +6 -0
- package/dist/components/DaeryuntalkBackup/_hooks/useWindowSize.js +20 -0
- package/dist/components/DaeryuntalkBackup/_hooks/useWindowSize.ts +30 -0
- package/dist/components/DaeryuntalkBackup/_hooks/view/useChatSocketState.d.ts +2 -0
- package/dist/components/DaeryuntalkBackup/_hooks/view/useChatSocketState.js +26 -0
- package/dist/components/DaeryuntalkBackup/_hooks/view/useChatSocketState.ts +43 -0
- package/dist/components/DaeryuntalkBackup/_hooks/view/useHistoryView.d.ts +27 -0
- package/dist/components/DaeryuntalkBackup/_hooks/view/useHistoryView.js +80 -0
- package/dist/components/DaeryuntalkBackup/_hooks/view/useHistoryView.ts +101 -0
- package/dist/components/DaeryuntalkBackup/_hooks/view/useHomeView.d.ts +18 -0
- package/dist/components/DaeryuntalkBackup/_hooks/view/useHomeView.js +66 -0
- package/dist/components/DaeryuntalkBackup/_hooks/view/useHomeView.ts +75 -0
- package/dist/components/DaeryuntalkBackup/_lib/index.d.ts +7 -0
- package/dist/components/DaeryuntalkBackup/_lib/index.js +103 -0
- package/dist/components/DaeryuntalkBackup/_lib/index.ts +136 -0
- package/dist/components/DaeryuntalkBackup/_lib/utils.d.ts +17 -0
- package/dist/components/DaeryuntalkBackup/_lib/utils.js +94 -0
- package/dist/components/DaeryuntalkBackup/_lib/utils.ts +119 -0
- package/dist/components/DaeryuntalkBackup/_types/message.d.ts +92 -0
- package/dist/components/DaeryuntalkBackup/_types/message.js +25 -0
- package/dist/components/DaeryuntalkBackup/_types/message.ts +156 -0
- package/dist/components/DaeryuntalkBackup/_types/message_object.d.ts +17 -0
- package/dist/components/DaeryuntalkBackup/_types/message_object.js +1 -0
- package/dist/components/DaeryuntalkBackup/_types/message_object.ts +18 -0
- package/dist/components/DaeryuntalkBackup/_types/socket/workflow.d.ts +15 -0
- package/dist/components/DaeryuntalkBackup/_types/socket/workflow.js +1 -0
- package/dist/components/DaeryuntalkBackup/_types/socket/workflow.ts +15 -0
- package/dist/components/DaeryuntalkBackup/_ui/ShadowBox.d.ts +6 -0
- package/dist/components/DaeryuntalkBackup/_ui/ShadowBox.jsx +5 -0
- package/dist/components/DaeryuntalkBackup/_ui/ShadowBox.tsx +15 -0
- package/dist/components/DaeryuntalkBackup/_ui/buttons/Button1.d.ts +10 -0
- package/dist/components/DaeryuntalkBackup/_ui/buttons/Button1.jsx +12 -0
- package/dist/components/DaeryuntalkBackup/_ui/buttons/Button1.tsx +29 -0
- package/dist/components/DaeryuntalkBackup/_ui/buttons/Button2.d.ts +10 -0
- package/dist/components/DaeryuntalkBackup/_ui/buttons/Button2.jsx +12 -0
- package/dist/components/DaeryuntalkBackup/_ui/buttons/Button2.tsx +29 -0
- package/dist/components/DaeryuntalkBackup/_ui/buttons/Button3.d.ts +10 -0
- package/dist/components/DaeryuntalkBackup/_ui/buttons/Button3.jsx +12 -0
- package/dist/components/DaeryuntalkBackup/_ui/buttons/Button3.tsx +29 -0
- package/dist/components/DaeryuntalkBackup/_ui/buttons/Button4.d.ts +10 -0
- package/dist/components/DaeryuntalkBackup/_ui/buttons/Button4.jsx +12 -0
- package/dist/components/DaeryuntalkBackup/_ui/buttons/Button4.tsx +29 -0
- package/dist/components/DaeryuntalkBackup/_ui/checkboxs/CheckBox1.d.ts +8 -0
- package/dist/components/DaeryuntalkBackup/_ui/checkboxs/CheckBox1.jsx +15 -0
- package/dist/components/DaeryuntalkBackup/_ui/checkboxs/CheckBox1.tsx +38 -0
- package/dist/components/DaeryuntalkBackup/_ui/checkboxs/CheckBox2.d.ts +8 -0
- package/dist/components/DaeryuntalkBackup/_ui/checkboxs/CheckBox2.jsx +21 -0
- package/dist/components/DaeryuntalkBackup/_ui/checkboxs/CheckBox2.tsx +50 -0
- package/dist/components/DaeryuntalkBackup/_ui/inputs/Input1.d.ts +12 -0
- package/dist/components/DaeryuntalkBackup/_ui/inputs/Input1.jsx +9 -0
- package/dist/components/DaeryuntalkBackup/_ui/inputs/Input1.tsx +39 -0
- package/dist/components/DaeryuntalkBackup/_ui/inputs/Input2.d.ts +13 -0
- package/dist/components/DaeryuntalkBackup/_ui/inputs/Input2.jsx +10 -0
- package/dist/components/DaeryuntalkBackup/_ui/inputs/Input2.tsx +43 -0
- package/dist/components/DaeryuntalkBackup/index.d.ts +8 -0
- package/dist/components/DaeryuntalkBackup/index.jsx +190 -0
- package/dist/components/DaeryuntalkBackup/index.tsx +261 -0
- package/dist/components/common/integrate/index.d.ts +1 -1
- package/dist/styles/globals.css +415 -410
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
11
|
+
import { authenticateUser, getChatInquiryMain, getHistoryList, initializeDaeryuntalk as apiInitializeDaeryuntalk, initializeWebSocket, connectWebSocket, getChatInquiryMessageList, generateChatInquiry, getChatInquiryDetailNew } from '../../_api/daeryuntalk';
|
|
12
|
+
import { convertApiMessageObjectToUiMessageObject, convertApiMessageToUiMessage, convertSocketObjectToUiMessage } from '../../_lib';
|
|
13
|
+
import { MessageSendSocketType, MessageSocketType } from '../../_enums/socket_type';
|
|
14
|
+
import { InquiryStatusEnum } from '../../_enums/ask-status';
|
|
15
|
+
import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
|
|
16
|
+
import { getErrorMessageMap } from '../../_enums/error';
|
|
17
|
+
import { consoleFn } from '../../_lib/utils';
|
|
18
|
+
import { useFullURL } from './useFullURL';
|
|
19
|
+
export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessages, setInquiryMainData, socketRef, setWorkFlowStack, setMessageObject, setInquiryStatus, setHistoryList, historyList, inquiryMainData, isMobile, setIsAuthenticated, setIsTyping, onClose, centerCode, setPreviewState, setIsUserExpried, chatInquiryNumber, setIsNextPage, setInitialLoading, setChatInquiryNumber, setAgeCheckStatus, isOpen }) => {
|
|
20
|
+
var _a;
|
|
21
|
+
const typingBlockRef = useRef(null);
|
|
22
|
+
const typingTimeoutRef = useRef(null);
|
|
23
|
+
const toast = useDaeryunTalkToast();
|
|
24
|
+
const userExpiredRef = useRef(false);
|
|
25
|
+
const fullUrl = useFullURL();
|
|
26
|
+
// 현재 화면 가시성 상태
|
|
27
|
+
const [isVisible, setIsVisible] = useState(typeof document !== 'undefined' ? document.visibilityState === 'visible' : true);
|
|
28
|
+
// 재연결 시도 횟수
|
|
29
|
+
const reconnectCountRef = useRef(0);
|
|
30
|
+
// 최대 재연결 시도 횟수
|
|
31
|
+
const maxReconnectAttempts = 10;
|
|
32
|
+
// 재연결 중인지 여부
|
|
33
|
+
const isSocketReconnectingRef = useRef(false);
|
|
34
|
+
// 재연결 시도 딜레이 시간
|
|
35
|
+
const reconnectDelay = 3000;
|
|
36
|
+
const openTyping = () => {
|
|
37
|
+
setIsTyping(true);
|
|
38
|
+
};
|
|
39
|
+
const closeTyping = () => {
|
|
40
|
+
setIsTyping(false);
|
|
41
|
+
};
|
|
42
|
+
const chatInquiryNumberRef = useRef(chatInquiryNumber);
|
|
43
|
+
// 상태가 바뀔 때마다 ref도 갱신
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
chatInquiryNumberRef.current = chatInquiryNumber;
|
|
46
|
+
}, [chatInquiryNumber]);
|
|
47
|
+
consoleFn('chatInquiryNumber', chatInquiryNumber);
|
|
48
|
+
consoleFn('socketRef.current', (_a = socketRef.current) === null || _a === void 0 ? void 0 : _a.readyState);
|
|
49
|
+
/**
|
|
50
|
+
* 1. heartbeat
|
|
51
|
+
* - 목적: 사용자의 이탈 여부를 추적하기 위한 주기적 하트비트 전송
|
|
52
|
+
* - 설명: N초 주기로 전송되며, 이탈 판단 로직에 사용됨
|
|
53
|
+
* - 예시:
|
|
54
|
+
* {
|
|
55
|
+
* "type": "heartbeat",
|
|
56
|
+
* "payload": {
|
|
57
|
+
* "chat_inquiry_number": "C3213638792875684353"
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
*/
|
|
61
|
+
const sendHeartbeat = useCallback(() => {
|
|
62
|
+
const socket = socketRef.current;
|
|
63
|
+
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
64
|
+
socket.send(JSON.stringify({
|
|
65
|
+
type: MessageSendSocketType.HEARTBEAT,
|
|
66
|
+
payload: {}
|
|
67
|
+
}));
|
|
68
|
+
consoleFn(`[WebSocket] ${MessageSendSocketType.HEARTBEAT} 전송`);
|
|
69
|
+
}
|
|
70
|
+
}, []);
|
|
71
|
+
const sendInquiryWatching = useCallback((chatInquiryNumber) => {
|
|
72
|
+
const socket = socketRef.current;
|
|
73
|
+
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
74
|
+
socket.send(JSON.stringify({
|
|
75
|
+
type: MessageSendSocketType.INQUIRY_WATCHING,
|
|
76
|
+
payload: { chat_inquiry_number: chatInquiryNumber }
|
|
77
|
+
}));
|
|
78
|
+
consoleFn(`[WebSocket] ${MessageSendSocketType.INQUIRY_WATCHING} 전송`);
|
|
79
|
+
}
|
|
80
|
+
}, []);
|
|
81
|
+
/**
|
|
82
|
+
* 2. inquiry.joined
|
|
83
|
+
* - 목적: 특정 문의 세션에 참여를 알림
|
|
84
|
+
* - 설명: 이 요청 이후부터 해당 문의의 메시지 이벤트를 수신 가능
|
|
85
|
+
* - 예시:
|
|
86
|
+
* {
|
|
87
|
+
* "type": "inquiry.joined",
|
|
88
|
+
* "payload": {
|
|
89
|
+
* "chat_inquiry_number": "C3213638792875684353"
|
|
90
|
+
* }
|
|
91
|
+
* }
|
|
92
|
+
*/
|
|
93
|
+
const sendInquiryJoined = useCallback((chatInquiryNumber) => {
|
|
94
|
+
const socket = socketRef.current;
|
|
95
|
+
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
96
|
+
socket.send(JSON.stringify({
|
|
97
|
+
type: MessageSendSocketType.INQUIRY_JOINED,
|
|
98
|
+
payload: { chat_inquiry_number: chatInquiryNumber }
|
|
99
|
+
}));
|
|
100
|
+
consoleFn(`[WebSocket] ${MessageSendSocketType.INQUIRY_JOINED} 전송`);
|
|
101
|
+
}
|
|
102
|
+
}, []);
|
|
103
|
+
/**
|
|
104
|
+
* 3. inquiry.left
|
|
105
|
+
* - 목적: 특정 문의 세션에서 이탈을 알림
|
|
106
|
+
* - 설명: 이 요청 이후 해당 문의의 메시지 이벤트는 수신되지 않음
|
|
107
|
+
* - 예시:
|
|
108
|
+
* {
|
|
109
|
+
* "type": "inquiry.left",
|
|
110
|
+
* "payload": {
|
|
111
|
+
* "chat_inquiry_number": "C3213638792875684353"
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
*/
|
|
115
|
+
const sendInquiryLeft = useCallback((chatInquiryNumber) => {
|
|
116
|
+
const socket = socketRef.current;
|
|
117
|
+
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
118
|
+
socket.send(JSON.stringify({
|
|
119
|
+
type: MessageSendSocketType.INQUIRY_LEFT,
|
|
120
|
+
payload: { chat_inquiry_number: chatInquiryNumber }
|
|
121
|
+
}));
|
|
122
|
+
consoleFn(`[WebSocket] ${MessageSendSocketType.INQUIRY_LEFT} 전송`);
|
|
123
|
+
}
|
|
124
|
+
}, []);
|
|
125
|
+
/**
|
|
126
|
+
* 4. history.entered -> 사용 X
|
|
127
|
+
* - 목적: 히스토리 목록 화면 진입 시, 여러 문의의 메시지 이벤트 수신을 요청
|
|
128
|
+
* - 설명: 복수 문의 번호를 등록함으로써 여러 문의에 대한 변경사항을 동시에 수신
|
|
129
|
+
* - 예시:
|
|
130
|
+
* {
|
|
131
|
+
* "type": "history.entered",
|
|
132
|
+
* "payload": {
|
|
133
|
+
* "chat_inquiry_numbers": [
|
|
134
|
+
* "C3213638792875684353",
|
|
135
|
+
* "C3213638792875689999",
|
|
136
|
+
* "C3213638792875777"
|
|
137
|
+
* ]
|
|
138
|
+
* }
|
|
139
|
+
* }
|
|
140
|
+
*/
|
|
141
|
+
const sendHistoryEntered = useCallback((chatInquiryNumbers) => {
|
|
142
|
+
const socket = socketRef.current;
|
|
143
|
+
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
144
|
+
socket.send(JSON.stringify({
|
|
145
|
+
type: MessageSendSocketType.HISTORY_ENTERED,
|
|
146
|
+
payload: { chat_inquiry_numbers: chatInquiryNumbers }
|
|
147
|
+
}));
|
|
148
|
+
consoleFn(`[WebSocket] ${MessageSendSocketType.HISTORY_ENTERED} 전송`);
|
|
149
|
+
}
|
|
150
|
+
}, []);
|
|
151
|
+
// -> 사용 X
|
|
152
|
+
const sendHistoryLeft = useCallback((chatInquiryNumbers) => {
|
|
153
|
+
const socket = socketRef.current;
|
|
154
|
+
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
155
|
+
socket.send(JSON.stringify({
|
|
156
|
+
type: MessageSendSocketType.HISTORY_EXITED,
|
|
157
|
+
payload: { chat_inquiry_numbers: chatInquiryNumbers }
|
|
158
|
+
}));
|
|
159
|
+
consoleFn(`[WebSocket] ${MessageSendSocketType.HISTORY_EXITED} 전송`);
|
|
160
|
+
}
|
|
161
|
+
}, []);
|
|
162
|
+
/** 화면 전환 이벤트 (백그라운드 ↔ 포그라운드) */
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
const handleVisibilityChange = () => {
|
|
165
|
+
const visible = document.visibilityState === 'visible';
|
|
166
|
+
setIsVisible(visible);
|
|
167
|
+
consoleFn('visible', visible);
|
|
168
|
+
if (!isOpen)
|
|
169
|
+
return;
|
|
170
|
+
if (visible) {
|
|
171
|
+
consoleFn('socketRef.current', socketRef.current);
|
|
172
|
+
consoleFn('화면 켜짐 확인 - 재연결 시도');
|
|
173
|
+
if (!socketRef.current || socketRef.current.readyState !== WebSocket.OPEN) {
|
|
174
|
+
consoleFn('📱 포그라운드 전환 → 재연결 카운트 리셋 후 재시도');
|
|
175
|
+
reconnectCountRef.current = 0; // 카운트 리셋
|
|
176
|
+
reconnectWithNewTokenSocket();
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
consoleFn('socketRef.current 준비 상태');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
184
|
+
return () => document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
185
|
+
}, [isOpen]);
|
|
186
|
+
const webSocketMessageHandler = useCallback((event) => {
|
|
187
|
+
var _a;
|
|
188
|
+
consoleFn('[DaeryuntalkContext] 웹소켓 메시지 수신됨');
|
|
189
|
+
try {
|
|
190
|
+
const data = typeof event === 'string' ? JSON.parse(event) : event;
|
|
191
|
+
consoleFn('socket data', data);
|
|
192
|
+
// 메시지 생성
|
|
193
|
+
if (data.type === MessageSocketType.MESSAGE_CREATED && ((_a = data.payload) === null || _a === void 0 ? void 0 : _a.message)) {
|
|
194
|
+
const newMessage = convertApiMessageToUiMessage(data.payload.message, 'live');
|
|
195
|
+
setMessages(prev => {
|
|
196
|
+
const isDuplicate = prev.some(msg => msg.messageNumber === newMessage.messageNumber);
|
|
197
|
+
return isDuplicate ? prev : [...prev, newMessage];
|
|
198
|
+
});
|
|
199
|
+
closeTyping();
|
|
200
|
+
}
|
|
201
|
+
if (data.type === MessageSocketType.MESSAGE_UPDATED) {
|
|
202
|
+
const newMessage = convertApiMessageToUiMessage(data.payload.message, 'basic');
|
|
203
|
+
setMessages(prev => {
|
|
204
|
+
const index = prev.findIndex(msg => msg.messageNumber === newMessage.messageNumber);
|
|
205
|
+
if (index !== -1) {
|
|
206
|
+
// 기존 메시지가 있으면 해당 위치에 새 메시지로 교체
|
|
207
|
+
const updated = [...prev];
|
|
208
|
+
updated[index] = newMessage;
|
|
209
|
+
return updated;
|
|
210
|
+
}
|
|
211
|
+
// 없으면 새 메시지를 추가
|
|
212
|
+
return [...prev, newMessage];
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// 메세지 회수됨 -> 이거는 관리자에서는 필요없는듯?
|
|
216
|
+
if (data.type === MessageSocketType.MESSAGE_COLLECTED) {
|
|
217
|
+
// 여기서는
|
|
218
|
+
const payload = data.payload;
|
|
219
|
+
setMessages(prev => prev.filter(fil => fil.messageNumber !== payload.message_number));
|
|
220
|
+
}
|
|
221
|
+
// 안읽음 count
|
|
222
|
+
if (data.type === MessageSocketType.INQUIRY_PREVIEW_UPDATED) {
|
|
223
|
+
const socketData = data === null || data === void 0 ? void 0 : data.payload;
|
|
224
|
+
setHistoryList((prev) => prev.map(item => item.chat_inquiry_number === socketData.chat_inquiry_number
|
|
225
|
+
? {
|
|
226
|
+
chat_inquiry_number: socketData.chat_inquiry_number,
|
|
227
|
+
customer_name: item.customer_name,
|
|
228
|
+
recent_message_content: socketData.recent_message_content,
|
|
229
|
+
recent_message_date_time: socketData.recent_message_date_time,
|
|
230
|
+
unread_message_count: Number(socketData.unread_message_count)
|
|
231
|
+
}
|
|
232
|
+
: item));
|
|
233
|
+
}
|
|
234
|
+
// 새로운 문의가 생성됨
|
|
235
|
+
if (data.type === MessageSocketType.INQUIRY_OPENED) {
|
|
236
|
+
}
|
|
237
|
+
// 문의 워크플로우 변경됨
|
|
238
|
+
if (data.type === MessageSocketType.INQUIRY_WORKFLOW_UPDATED) {
|
|
239
|
+
const socketPayloadData = data === null || data === void 0 ? void 0 : data.payload;
|
|
240
|
+
// 워크플로우 스택 업데이트
|
|
241
|
+
setWorkFlowStack(socketPayloadData.work_flow_progress_stack);
|
|
242
|
+
// 오브젝트 업데이트
|
|
243
|
+
setMessageObject(convertSocketObjectToUiMessage(data === null || data === void 0 ? void 0 : data.payload));
|
|
244
|
+
}
|
|
245
|
+
// 문의가 종료됨
|
|
246
|
+
if (data.type === MessageSocketType.INQUIRY_CLOSED) {
|
|
247
|
+
setInquiryStatus(InquiryStatusEnum.CLOSED);
|
|
248
|
+
}
|
|
249
|
+
// 업무 관리자 배정
|
|
250
|
+
if (data.type === MessageSocketType.INQUIRY_ASSIGNED) {
|
|
251
|
+
const payload = data.payload;
|
|
252
|
+
}
|
|
253
|
+
// 할당된 상담원이 해제됨
|
|
254
|
+
if (data.type === MessageSocketType.INQUIRY_UNASSIGNED) {
|
|
255
|
+
}
|
|
256
|
+
// 고객 정보가 갱신됨
|
|
257
|
+
if (data.type === MessageSocketType.CUSTOMER_INFO_UPDATED) {
|
|
258
|
+
}
|
|
259
|
+
// 오퍼레이터 타이핑 이벤트
|
|
260
|
+
if (data.type === MessageSocketType.TYPING_STARTED) {
|
|
261
|
+
const payload = data.payload;
|
|
262
|
+
handleTypingStarted();
|
|
263
|
+
}
|
|
264
|
+
if (data.type === MessageSocketType.USER_EXPIRED) {
|
|
265
|
+
setIsUserExpried(true);
|
|
266
|
+
localStorage.removeItem('daeryunchatinquirytoken');
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
console.error('[DaeryuntalkContext] 웹소켓 메시지 처리 오류:', error);
|
|
271
|
+
}
|
|
272
|
+
}, []);
|
|
273
|
+
/** util: 소켓 정리 */
|
|
274
|
+
const cleanupWebSocketInstance = useCallback((socket) => {
|
|
275
|
+
if (!socket)
|
|
276
|
+
return;
|
|
277
|
+
socket.onopen = null;
|
|
278
|
+
socket.onclose = null;
|
|
279
|
+
socket.onmessage = null;
|
|
280
|
+
socket.onerror = null;
|
|
281
|
+
try {
|
|
282
|
+
socket.close();
|
|
283
|
+
}
|
|
284
|
+
catch (_a) { }
|
|
285
|
+
}, []);
|
|
286
|
+
/** util: 소켓 재연결 (새 토큰 발급 후 재연결) */
|
|
287
|
+
const reconnectWithNewTokenSocket = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
288
|
+
var _a, _b, _c, _d;
|
|
289
|
+
consoleFn('재연결 시도');
|
|
290
|
+
// 화면 꺼진 경우 재연결 X
|
|
291
|
+
if (!isVisible)
|
|
292
|
+
return;
|
|
293
|
+
// 재연결 중이면 중복 방지
|
|
294
|
+
if (isSocketReconnectingRef.current)
|
|
295
|
+
return;
|
|
296
|
+
try {
|
|
297
|
+
// 최대 시도 횟수 초과 시 종료
|
|
298
|
+
if (reconnectCountRef.current >= maxReconnectAttempts) {
|
|
299
|
+
consoleFn('❌ 재연결 최대 횟수 초과, 더 이상 시도하지 않음');
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
reconnectCountRef.current++;
|
|
303
|
+
consoleFn(`[DaeryuntalkContext] 소켓 재연결 시도 ${reconnectCountRef.current}회...`);
|
|
304
|
+
// 기존 소켓 정리
|
|
305
|
+
if (socketRef.current) {
|
|
306
|
+
cleanupWebSocketInstance(socketRef.current);
|
|
307
|
+
socketRef.current = null;
|
|
308
|
+
}
|
|
309
|
+
isSocketReconnectingRef.current = true;
|
|
310
|
+
// 새 토큰 발급
|
|
311
|
+
const wsInitData = yield initializeWebSocket();
|
|
312
|
+
if (((_a = wsInitData === null || wsInitData === void 0 ? void 0 : wsInitData.result_info) === null || _a === void 0 ? void 0 : _a.result_cd) === 'OK' || ((_b = wsInitData === null || wsInitData === void 0 ? void 0 : wsInitData.result_info) === null || _b === void 0 ? void 0 : _b.result_type_cd) === 'OK') {
|
|
313
|
+
const socket = connectWebSocket(wsInitData.data.connection_url, wsInitData.data.connection_token, true, setIsConnected, userExpiredRef, webSocketMessageHandler, // onMessage
|
|
314
|
+
() => {
|
|
315
|
+
// onOpen
|
|
316
|
+
consoleFn('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 성공');
|
|
317
|
+
setIsConnected(true);
|
|
318
|
+
isSocketReconnectingRef.current = false; // 성공 시 초기화
|
|
319
|
+
setInitialLoading(false);
|
|
320
|
+
if (chatInquiryNumberRef.current) {
|
|
321
|
+
sendInquiryJoined(chatInquiryNumberRef.current || '');
|
|
322
|
+
sendInquiryWatching(chatInquiryNumberRef.current || '');
|
|
323
|
+
}
|
|
324
|
+
}, () => {
|
|
325
|
+
// onClose
|
|
326
|
+
consoleFn('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 종료');
|
|
327
|
+
setIsConnected(false);
|
|
328
|
+
isSocketReconnectingRef.current = false; // 실패 시 초기화
|
|
329
|
+
setTimeout(() => reconnectWithNewTokenSocket(), reconnectDelay);
|
|
330
|
+
}, event => {
|
|
331
|
+
// onError
|
|
332
|
+
console.error('[DaeryuntalkContext] 웹소켓 오류:', event);
|
|
333
|
+
setIsConnected(false);
|
|
334
|
+
isSocketReconnectingRef.current = false; // 오류 시 초기화
|
|
335
|
+
setTimeout(() => reconnectWithNewTokenSocket(), reconnectDelay);
|
|
336
|
+
});
|
|
337
|
+
socketRef.current = socket;
|
|
338
|
+
if (chatInquiryNumberRef.current) {
|
|
339
|
+
consoleFn('chatList 실행');
|
|
340
|
+
const chatList = yield getChatInquiryMessageList(chatInquiryNumberRef.current || '');
|
|
341
|
+
if (chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK') {
|
|
342
|
+
//
|
|
343
|
+
if (((_c = chatList.data) === null || _c === void 0 ? void 0 : _c.message_list) && chatList.data.message_list.length > 0) {
|
|
344
|
+
const uiMessages = chatList.data.message_list
|
|
345
|
+
.sort((a, b) => a.timestamp - b.timestamp)
|
|
346
|
+
.map(item => {
|
|
347
|
+
return convertApiMessageToUiMessage(item, 'basic');
|
|
348
|
+
});
|
|
349
|
+
setMessages(uiMessages);
|
|
350
|
+
consoleFn('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
351
|
+
}
|
|
352
|
+
if (((_d = chatList.data) === null || _d === void 0 ? void 0 : _d.next_page_yn) !== null) {
|
|
353
|
+
setIsNextPage(chatList.data.next_page_yn);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
// console.log('chatInquiryNumber 없음')
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
// console.error("❌ 웹소켓 토큰 발급 실패:", wsInitData);
|
|
363
|
+
isSocketReconnectingRef.current = false; // ✅ 토큰 발급 실패도 초기화
|
|
364
|
+
setTimeout(() => reconnectWithNewTokenSocket(), reconnectDelay);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
catch (error) {
|
|
368
|
+
// console.error('[DaeryuntalkContext] 소켓 재연결 오류:', error);
|
|
369
|
+
isSocketReconnectingRef.current = false; // ✅ 예외 발생 시 초기화
|
|
370
|
+
setTimeout(() => reconnectWithNewTokenSocket(), reconnectDelay);
|
|
371
|
+
}
|
|
372
|
+
}), [cleanupWebSocketInstance, chatInquiryNumber]);
|
|
373
|
+
const handleTypingStarted = () => {
|
|
374
|
+
openTyping();
|
|
375
|
+
if (typingTimeoutRef.current) {
|
|
376
|
+
clearTimeout(typingTimeoutRef.current);
|
|
377
|
+
}
|
|
378
|
+
// 일정 시간 타이핑 이벤트 없으면 UI 제거
|
|
379
|
+
typingTimeoutRef.current = setTimeout(() => {
|
|
380
|
+
setIsTyping(false);
|
|
381
|
+
}, 3000);
|
|
382
|
+
};
|
|
383
|
+
// Daeryuntalk API 초기화 메소드
|
|
384
|
+
const initializeDaeryuntalk = useCallback((hashValue, isOpen, centerCode, version) => __awaiter(void 0, void 0, void 0, function* () {
|
|
385
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
386
|
+
if (userExpiredRef.current) {
|
|
387
|
+
consoleFn('유저 만료 상태로 초기화 X');
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
consoleFn('[DaeryuntalkContext] 초기화 메소드 호출됨', version ? `버전: ${version}` : '기본 버전 사용');
|
|
391
|
+
try {
|
|
392
|
+
// setIsLoading(true);
|
|
393
|
+
// consoleFn('[DaeryuntalkContext] 로딩 상태 설정: true');
|
|
394
|
+
const { inquiryData, socket, hashAuth, errorCode } = yield apiInitializeDaeryuntalk(hashValue || '', isOpen, setIsConnected, isMobile, centerCode, userExpiredRef, socket => {
|
|
395
|
+
consoleFn('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 성공');
|
|
396
|
+
setIsConnected(true);
|
|
397
|
+
setInitialLoading(true);
|
|
398
|
+
}, event => {
|
|
399
|
+
// onMessage
|
|
400
|
+
webSocketMessageHandler(event);
|
|
401
|
+
}, event => {
|
|
402
|
+
// onClose
|
|
403
|
+
consoleFn('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 실패');
|
|
404
|
+
setIsConnected(false);
|
|
405
|
+
setTimeout(() => reconnectWithNewTokenSocket(), reconnectDelay);
|
|
406
|
+
}, event => {
|
|
407
|
+
// onError
|
|
408
|
+
console.error('[DaeryuntalkContext] 웹소켓 오류:', event);
|
|
409
|
+
setIsConnected(false);
|
|
410
|
+
setTimeout(() => reconnectWithNewTokenSocket(), reconnectDelay);
|
|
411
|
+
});
|
|
412
|
+
const response = yield getHistoryList({ version });
|
|
413
|
+
if (response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK') {
|
|
414
|
+
setIsAuthenticated === null || setIsAuthenticated === void 0 ? void 0 : setIsAuthenticated(true);
|
|
415
|
+
setHistoryList === null || setHistoryList === void 0 ? void 0 : setHistoryList((_a = response.data.chat_inquiry_list) !== null && _a !== void 0 ? _a : []);
|
|
416
|
+
}
|
|
417
|
+
if (errorCode || !inquiryData || !socket) {
|
|
418
|
+
errorCode && toast.error(getErrorMessageMap(errorCode));
|
|
419
|
+
}
|
|
420
|
+
if (hashValue) {
|
|
421
|
+
if (((_b = hashAuth === null || hashAuth === void 0 ? void 0 : hashAuth.result_info) === null || _b === void 0 ? void 0 : _b.result_cd) === 'OK' || ((_c = hashAuth === null || hashAuth === void 0 ? void 0 : hashAuth.result_info) === null || _c === void 0 ? void 0 : _c.result_type_cd) === 'OK') {
|
|
422
|
+
consoleFn('해쉬 인증 완료');
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
toast.error('링크가 만료되었거나 존재하지 않습니다.');
|
|
426
|
+
setTimeout(() => {
|
|
427
|
+
onClose();
|
|
428
|
+
window.location.href = '/';
|
|
429
|
+
}, 500);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
if (!(((_d = inquiryData === null || inquiryData === void 0 ? void 0 : inquiryData.result_info) === null || _d === void 0 ? void 0 : _d.result_cd) === 'OK' || ((_e = inquiryData === null || inquiryData === void 0 ? void 0 : inquiryData.result_info) === null || _e === void 0 ? void 0 : _e.result_type_cd) === 'OK')) {
|
|
433
|
+
inquiryData && toast.error(getErrorMessageMap(inquiryData));
|
|
434
|
+
return inquiryData;
|
|
435
|
+
}
|
|
436
|
+
let detailResponse = null;
|
|
437
|
+
let chatList = null;
|
|
438
|
+
let chatNumber = '';
|
|
439
|
+
// 기존 문의가 있는 경우
|
|
440
|
+
if ((_f = inquiryData.data) === null || _f === void 0 ? void 0 : _f.progress_inquiry_number) {
|
|
441
|
+
chatNumber = (_g = inquiryData.data) === null || _g === void 0 ? void 0 : _g.progress_inquiry_number;
|
|
442
|
+
detailResponse = yield getChatInquiryDetailNew((_h = inquiryData.data) === null || _h === void 0 ? void 0 : _h.progress_inquiry_number);
|
|
443
|
+
chatList = yield getChatInquiryMessageList((_j = inquiryData.data) === null || _j === void 0 ? void 0 : _j.progress_inquiry_number);
|
|
444
|
+
}
|
|
445
|
+
// 기존 문의가 없는 경우
|
|
446
|
+
else {
|
|
447
|
+
// 채팅 생성
|
|
448
|
+
const createResponse = yield generateChatInquiry(((_k = inquiryData.data) === null || _k === void 0 ? void 0 : _k.channel_number) || '', fullUrl, centerCode);
|
|
449
|
+
if (!(createResponse.result_info.result_cd === 'OK' ||
|
|
450
|
+
createResponse.result_info.result_type_cd === 'OK')) {
|
|
451
|
+
toast.error(getErrorMessageMap(createResponse));
|
|
452
|
+
return createResponse;
|
|
453
|
+
}
|
|
454
|
+
chatNumber = ((_l = createResponse === null || createResponse === void 0 ? void 0 : createResponse.data) === null || _l === void 0 ? void 0 : _l.chat_inquiry_number) || '';
|
|
455
|
+
// 채팅 상세 조회
|
|
456
|
+
detailResponse = yield getChatInquiryDetailNew(chatNumber);
|
|
457
|
+
// 채팅 메시지 리스트 조회
|
|
458
|
+
chatList = yield getChatInquiryMessageList(chatNumber);
|
|
459
|
+
}
|
|
460
|
+
if (!(((_m = detailResponse === null || detailResponse === void 0 ? void 0 : detailResponse.result_info) === null || _m === void 0 ? void 0 : _m.result_cd) === 'OK' ||
|
|
461
|
+
((_o = detailResponse === null || detailResponse === void 0 ? void 0 : detailResponse.result_info) === null || _o === void 0 ? void 0 : _o.result_type_cd) === 'OK')) {
|
|
462
|
+
toast.error(getErrorMessageMap(detailResponse));
|
|
463
|
+
return detailResponse;
|
|
464
|
+
}
|
|
465
|
+
if (!(((_p = chatList === null || chatList === void 0 ? void 0 : chatList.result_info) === null || _p === void 0 ? void 0 : _p.result_cd) === 'OK' || ((_q = chatList === null || chatList === void 0 ? void 0 : chatList.result_info) === null || _q === void 0 ? void 0 : _q.result_type_cd) === 'OK')) {
|
|
466
|
+
toast.error(getErrorMessageMap(chatList));
|
|
467
|
+
return chatList;
|
|
468
|
+
}
|
|
469
|
+
setChatInquiryNumber(chatNumber);
|
|
470
|
+
if (chatList.data.message_list.length > 0) {
|
|
471
|
+
const uiMessages = chatList.data.message_list
|
|
472
|
+
.sort((a, b) => a.timestamp - b.timestamp)
|
|
473
|
+
.map(item => {
|
|
474
|
+
return convertApiMessageToUiMessage(item, 'basic');
|
|
475
|
+
});
|
|
476
|
+
setMessages(uiMessages);
|
|
477
|
+
consoleFn('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
478
|
+
}
|
|
479
|
+
if (((_r = chatList.data) === null || _r === void 0 ? void 0 : _r.next_page_yn) !== null) {
|
|
480
|
+
setIsNextPage(chatList.data.next_page_yn);
|
|
481
|
+
}
|
|
482
|
+
// 해당 문의 오브젝트
|
|
483
|
+
if ((_s = detailResponse.data) === null || _s === void 0 ? void 0 : _s.object_expose_info) {
|
|
484
|
+
const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
|
|
485
|
+
setMessageObject(uiObject);
|
|
486
|
+
}
|
|
487
|
+
// 해당 문의 연령 체크
|
|
488
|
+
if ((_t = detailResponse.data) === null || _t === void 0 ? void 0 : _t.age_consent_state_code) {
|
|
489
|
+
setAgeCheckStatus(detailResponse.data.age_consent_state_code);
|
|
490
|
+
}
|
|
491
|
+
// 해당 문의 상태
|
|
492
|
+
if ((_u = detailResponse.data) === null || _u === void 0 ? void 0 : _u.chat_inquiry_state_code) {
|
|
493
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
494
|
+
}
|
|
495
|
+
// 워크플로우 스택 업데이트
|
|
496
|
+
if ((_v = detailResponse.data) === null || _v === void 0 ? void 0 : _v.work_flow_progress_stack) {
|
|
497
|
+
setWorkFlowStack((_x = (_w = detailResponse.data) === null || _w === void 0 ? void 0 : _w.work_flow_progress_stack) !== null && _x !== void 0 ? _x : []);
|
|
498
|
+
}
|
|
499
|
+
setInquiryMainData(Object.assign(Object.assign({}, inquiryData.data), { progress_inquiry_number: chatNumber }));
|
|
500
|
+
if (socket) {
|
|
501
|
+
socketRef.current = socket;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
catch (error) {
|
|
505
|
+
console.error('[DaeryuntalkContext] 초기화 오류:', error);
|
|
506
|
+
}
|
|
507
|
+
finally {
|
|
508
|
+
consoleFn('[DaeryuntalkContext] 로딩 상태 설정: false');
|
|
509
|
+
// setIsLoading(false);
|
|
510
|
+
}
|
|
511
|
+
}), [historyList]);
|
|
512
|
+
// C2121045680881362573
|
|
513
|
+
const retryInquiryMain = useCallback((channelNumber) => __awaiter(void 0, void 0, void 0, function* () {
|
|
514
|
+
const result = yield getChatInquiryMain(channelNumber || '');
|
|
515
|
+
setInquiryMainData(result.data);
|
|
516
|
+
return result;
|
|
517
|
+
}), [inquiryMainData]);
|
|
518
|
+
const retryInitData = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
519
|
+
const authRes = yield authenticateUser(centerCode);
|
|
520
|
+
const result = yield getChatInquiryMain(authRes.data.channel_number);
|
|
521
|
+
setInquiryMainData(result.data);
|
|
522
|
+
}), []);
|
|
523
|
+
return {
|
|
524
|
+
initializeDaeryuntalk,
|
|
525
|
+
sendInquiryWatching,
|
|
526
|
+
retryInquiryMain,
|
|
527
|
+
retryInitData,
|
|
528
|
+
sendHeartbeat,
|
|
529
|
+
sendInquiryJoined,
|
|
530
|
+
sendInquiryLeft,
|
|
531
|
+
sendHistoryEntered,
|
|
532
|
+
sendHistoryLeft
|
|
533
|
+
};
|
|
534
|
+
};
|