@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,595 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction, useCallback } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
attendChatRoomByHistory,
|
|
4
|
+
chatUserUpdate as apiChatUserUpdate,
|
|
5
|
+
chatWorkFlow,
|
|
6
|
+
chatWorkFlowBack,
|
|
7
|
+
generateChatInquiry,
|
|
8
|
+
getChatInquiryDetailNew,
|
|
9
|
+
getChatInquiryMessageList,
|
|
10
|
+
sendChatMessage,
|
|
11
|
+
ageCheckUpdate
|
|
12
|
+
} from '../../_api';
|
|
13
|
+
import { convertApiMessageObjectToUiMessageObject, convertApiMessageToUiMessage } from '../../_lib';
|
|
14
|
+
import { IChatInquiryMainDataResponse } from '../../_api/daeryuntalk/type/response';
|
|
15
|
+
import { Message } from '../../_types/message';
|
|
16
|
+
import { MessageObject } from '../../_types/message_object';
|
|
17
|
+
import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
|
|
18
|
+
import { useFullURL } from './useFullURL';
|
|
19
|
+
import { getErrorMessageMap } from '../../_enums/error';
|
|
20
|
+
import { consoleFn } from '../../_lib/utils';
|
|
21
|
+
import { AgeCheckStatusEnums } from '../../_enums/ags_check_status';
|
|
22
|
+
|
|
23
|
+
interface props {
|
|
24
|
+
setIsLoading: Dispatch<SetStateAction<boolean>>;
|
|
25
|
+
inquiryMainData: IChatInquiryMainDataResponse | null;
|
|
26
|
+
setChatInquiryNumber: Dispatch<SetStateAction<string | null>>;
|
|
27
|
+
setMessages: Dispatch<SetStateAction<Message[]>>;
|
|
28
|
+
setInquiryStatus: Dispatch<SetStateAction<string>>;
|
|
29
|
+
setMessageObject: Dispatch<SetStateAction<MessageObject | null>>;
|
|
30
|
+
chatInquiryNumber: string | null;
|
|
31
|
+
setIsNextPage: Dispatch<SetStateAction<boolean | null>>;
|
|
32
|
+
setWorkFlowStack: Dispatch<SetStateAction<string[]>>;
|
|
33
|
+
setInquiryMainData: Dispatch<SetStateAction<IChatInquiryMainDataResponse | null>>;
|
|
34
|
+
centerCode: string;
|
|
35
|
+
setAgeCheckStatus: Dispatch<SetStateAction<AgeCheckStatusEnums | null>>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const useChatHandler = ({
|
|
39
|
+
setIsLoading,
|
|
40
|
+
inquiryMainData,
|
|
41
|
+
setChatInquiryNumber,
|
|
42
|
+
setMessages,
|
|
43
|
+
setInquiryStatus,
|
|
44
|
+
setMessageObject,
|
|
45
|
+
chatInquiryNumber,
|
|
46
|
+
setIsNextPage,
|
|
47
|
+
setWorkFlowStack,
|
|
48
|
+
setInquiryMainData,
|
|
49
|
+
centerCode,
|
|
50
|
+
setAgeCheckStatus
|
|
51
|
+
}: props) => {
|
|
52
|
+
const toast = useDaeryunTalkToast();
|
|
53
|
+
const fullUrl = useFullURL();
|
|
54
|
+
|
|
55
|
+
const resetData = useCallback(() => {
|
|
56
|
+
setMessages([]);
|
|
57
|
+
setInquiryStatus('');
|
|
58
|
+
setMessageObject(null);
|
|
59
|
+
setIsNextPage(null);
|
|
60
|
+
}, []);
|
|
61
|
+
// const resetData = () => {};
|
|
62
|
+
|
|
63
|
+
// 채팅 시작 (문의하기 버튼 클릭 시)
|
|
64
|
+
const startChat = useCallback(
|
|
65
|
+
async (inquiryNumber?: string) => {
|
|
66
|
+
try {
|
|
67
|
+
setIsLoading(true);
|
|
68
|
+
consoleFn('[DaeryuntalkContext] 채팅 시작 요청');
|
|
69
|
+
|
|
70
|
+
// 기존 문의가 있는지 확인
|
|
71
|
+
const hasExistingInquiry =
|
|
72
|
+
inquiryMainData?.progress_inquiry_number && inquiryMainData?.progress_inquiry_number.trim() !== '';
|
|
73
|
+
|
|
74
|
+
let currentChatInquiryNumber = '';
|
|
75
|
+
|
|
76
|
+
if (hasExistingInquiry || inquiryNumber) {
|
|
77
|
+
// 기존 문의가 있는 경우, 해당 문의번호 사용
|
|
78
|
+
currentChatInquiryNumber = inquiryNumber
|
|
79
|
+
? inquiryNumber
|
|
80
|
+
: inquiryMainData?.progress_inquiry_number || '';
|
|
81
|
+
consoleFn('[DaeryuntalkContext] 기존 문의 사용:', currentChatInquiryNumber);
|
|
82
|
+
} else {
|
|
83
|
+
// 새 문의 생성
|
|
84
|
+
consoleFn('[DaeryuntalkContext] 새 문의 생성 시작');
|
|
85
|
+
const createResponse = await generateChatInquiry(
|
|
86
|
+
inquiryMainData?.channel_number || '',
|
|
87
|
+
fullUrl,
|
|
88
|
+
centerCode
|
|
89
|
+
);
|
|
90
|
+
if (
|
|
91
|
+
!(
|
|
92
|
+
createResponse.result_info.result_cd === 'OK' ||
|
|
93
|
+
createResponse.result_info.result_type_cd === 'OK'
|
|
94
|
+
)
|
|
95
|
+
) {
|
|
96
|
+
resetData();
|
|
97
|
+
toast.error(getErrorMessageMap(createResponse));
|
|
98
|
+
return createResponse;
|
|
99
|
+
}
|
|
100
|
+
currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 문의 상세 조회
|
|
104
|
+
consoleFn('[DaeryuntalkContext] 문의 상세 조회 시작:', currentChatInquiryNumber);
|
|
105
|
+
const detailResponse = await getChatInquiryDetailNew(currentChatInquiryNumber);
|
|
106
|
+
if (
|
|
107
|
+
!(
|
|
108
|
+
detailResponse.result_info.result_cd === 'OK' ||
|
|
109
|
+
detailResponse.result_info.result_type_cd === 'OK'
|
|
110
|
+
)
|
|
111
|
+
) {
|
|
112
|
+
resetData();
|
|
113
|
+
toast.error(getErrorMessageMap(detailResponse));
|
|
114
|
+
return detailResponse;
|
|
115
|
+
}
|
|
116
|
+
consoleFn('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
|
|
117
|
+
|
|
118
|
+
consoleFn('[DaeryuntalkContext] 문의 채팅 리스트 조회 시작:', currentChatInquiryNumber);
|
|
119
|
+
const chatList = await getChatInquiryMessageList(currentChatInquiryNumber);
|
|
120
|
+
if (!(chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK')) {
|
|
121
|
+
resetData();
|
|
122
|
+
toast.error(getErrorMessageMap(chatList));
|
|
123
|
+
return chatList;
|
|
124
|
+
}
|
|
125
|
+
consoleFn('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
|
|
126
|
+
|
|
127
|
+
// 문의 정보 저장
|
|
128
|
+
setChatInquiryNumber(currentChatInquiryNumber);
|
|
129
|
+
|
|
130
|
+
consoleFn('detailResponse.data.message_list', chatList?.data?.message_list);
|
|
131
|
+
|
|
132
|
+
// 메시지 처리
|
|
133
|
+
// 메세지 리스트 후처리
|
|
134
|
+
if (chatList.data.message_list.length > 0) {
|
|
135
|
+
const uiMessages = chatList.data.message_list
|
|
136
|
+
.sort((a, b) => a.timestamp - b.timestamp)
|
|
137
|
+
.map(item => {
|
|
138
|
+
return convertApiMessageToUiMessage(item, 'basic');
|
|
139
|
+
});
|
|
140
|
+
setMessages(uiMessages);
|
|
141
|
+
consoleFn('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
142
|
+
}
|
|
143
|
+
if (chatList.data?.next_page_yn !== null) {
|
|
144
|
+
setIsNextPage(chatList.data.next_page_yn);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 해당 문의 상태
|
|
148
|
+
if (detailResponse.data?.chat_inquiry_state_code) {
|
|
149
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
150
|
+
}
|
|
151
|
+
// 해당 문의 오브젝트
|
|
152
|
+
if (detailResponse.data?.object_expose_info) {
|
|
153
|
+
const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
|
|
154
|
+
setMessageObject(uiObject);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 해당 문의 상태
|
|
158
|
+
if (detailResponse.data?.chat_inquiry_state_code) {
|
|
159
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
160
|
+
}
|
|
161
|
+
// 워크플로우 스택 업데이트
|
|
162
|
+
if (detailResponse.data?.work_flow_progress_stack) {
|
|
163
|
+
setWorkFlowStack(detailResponse.data?.work_flow_progress_stack ?? []);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return currentChatInquiryNumber;
|
|
167
|
+
} catch (error) {
|
|
168
|
+
toast.error('문의 시작에 실패했습니다.');
|
|
169
|
+
console.error('[DaeryuntalkContext] 채팅 시작 오류:', error);
|
|
170
|
+
return { error }; // 에러를 던지지 않고 그대로 반환
|
|
171
|
+
|
|
172
|
+
// throw error;
|
|
173
|
+
} finally {
|
|
174
|
+
setIsLoading(false);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
[inquiryMainData, fullUrl]
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
// 선택된 히스토리의 채팅창 시작
|
|
181
|
+
const startSelectedChat = useCallback(
|
|
182
|
+
async (chatInquiryNumber: string) => {
|
|
183
|
+
try {
|
|
184
|
+
setIsLoading(true);
|
|
185
|
+
|
|
186
|
+
// 문의 상세 조회
|
|
187
|
+
const detailResponse = await getChatInquiryDetailNew(chatInquiryNumber);
|
|
188
|
+
if (
|
|
189
|
+
!(
|
|
190
|
+
detailResponse.result_info.result_cd === 'OK' ||
|
|
191
|
+
detailResponse.result_info.result_type_cd === 'OK'
|
|
192
|
+
)
|
|
193
|
+
) {
|
|
194
|
+
resetData();
|
|
195
|
+
toast.error(getErrorMessageMap(detailResponse));
|
|
196
|
+
return detailResponse;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
consoleFn('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
|
|
200
|
+
|
|
201
|
+
const chatList = await getChatInquiryMessageList(chatInquiryNumber);
|
|
202
|
+
consoleFn('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
|
|
203
|
+
if (!(chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK')) {
|
|
204
|
+
resetData();
|
|
205
|
+
toast.error(getErrorMessageMap(chatList));
|
|
206
|
+
return chatList;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
consoleFn('detailResponse.data.message_list', chatList?.data?.message_list);
|
|
210
|
+
|
|
211
|
+
// 메시지 처리
|
|
212
|
+
// 문의 정보 저장
|
|
213
|
+
setChatInquiryNumber(chatInquiryNumber);
|
|
214
|
+
//
|
|
215
|
+
setInquiryMainData(prev => {
|
|
216
|
+
if (prev) {
|
|
217
|
+
return {
|
|
218
|
+
...prev,
|
|
219
|
+
progress_inquiry_number: chatInquiryNumber
|
|
220
|
+
};
|
|
221
|
+
} else {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
// 메세지 리스트 후처리
|
|
226
|
+
if (chatList.data.message_list.length > 0) {
|
|
227
|
+
const uiMessages = chatList.data.message_list
|
|
228
|
+
.sort((a, b) => a.timestamp - b.timestamp)
|
|
229
|
+
.map(item => {
|
|
230
|
+
return convertApiMessageToUiMessage(item, 'basic');
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// const uiMessages = chatList.data.message_list.map(convertApiMessageToUiMessage);
|
|
234
|
+
setMessages(uiMessages);
|
|
235
|
+
|
|
236
|
+
consoleFn('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
237
|
+
}
|
|
238
|
+
if (chatList.data?.next_page_yn !== null) {
|
|
239
|
+
setIsNextPage(chatList.data.next_page_yn);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// 해당 문의 상태
|
|
243
|
+
if (detailResponse.data?.chat_inquiry_state_code) {
|
|
244
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
245
|
+
}
|
|
246
|
+
// 해당 문의 연령 체크
|
|
247
|
+
if (detailResponse.data?.age_consent_state_code) {
|
|
248
|
+
setAgeCheckStatus(detailResponse.data.age_consent_state_code);
|
|
249
|
+
}
|
|
250
|
+
// 해당 문의 오브젝트
|
|
251
|
+
if (detailResponse.data?.object_expose_info) {
|
|
252
|
+
const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
|
|
253
|
+
setMessageObject(uiObject);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// 해당 문의 상태
|
|
257
|
+
if (detailResponse.data?.chat_inquiry_state_code) {
|
|
258
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
259
|
+
}
|
|
260
|
+
// 워크플로우 스택 업데이트
|
|
261
|
+
if (detailResponse.data?.work_flow_progress_stack) {
|
|
262
|
+
setWorkFlowStack(detailResponse.data?.work_flow_progress_stack ?? []);
|
|
263
|
+
}
|
|
264
|
+
return chatInquiryNumber;
|
|
265
|
+
} catch (error) {
|
|
266
|
+
toast.error('채팅 시작에 실패했습니다.');
|
|
267
|
+
console.error('[DaeryuntalkContext] 채팅 시작 오류:', error);
|
|
268
|
+
throw error;
|
|
269
|
+
} finally {
|
|
270
|
+
setIsLoading(false);
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
[inquiryMainData]
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
// 메시지 전송
|
|
277
|
+
const sendMessage = useCallback(
|
|
278
|
+
async (htmlContent: string, jsonData: any, retry?: boolean) => {
|
|
279
|
+
try {
|
|
280
|
+
setIsLoading?.(true);
|
|
281
|
+
consoleFn('chatInquiryNumber', chatInquiryNumber);
|
|
282
|
+
const response = await sendChatMessage(chatInquiryNumber as string, htmlContent, jsonData);
|
|
283
|
+
if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
|
|
284
|
+
toast.error(getErrorMessageMap(response));
|
|
285
|
+
}
|
|
286
|
+
return response;
|
|
287
|
+
} catch (error) {
|
|
288
|
+
toast.error('메시지 전송에 실패했습니다.');
|
|
289
|
+
console.error('[DaeryuntalkContext] 메시지 전송 중 오류 발생:', error);
|
|
290
|
+
} finally {
|
|
291
|
+
setIsLoading?.(false);
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
[chatInquiryNumber]
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
// 신규 채팅 문의 생성
|
|
298
|
+
const createNewChat = useCallback(
|
|
299
|
+
async (version?: string) => {
|
|
300
|
+
try {
|
|
301
|
+
if (!inquiryMainData) {
|
|
302
|
+
toast.error('채널이 존재하지 않습니다.');
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
setIsLoading?.(true);
|
|
306
|
+
consoleFn('chatInquiryNumber', chatInquiryNumber);
|
|
307
|
+
const createResponse = await generateChatInquiry(
|
|
308
|
+
inquiryMainData?.channel_number || '',
|
|
309
|
+
fullUrl,
|
|
310
|
+
centerCode
|
|
311
|
+
);
|
|
312
|
+
if (
|
|
313
|
+
!(
|
|
314
|
+
createResponse.result_info.result_cd === 'OK' ||
|
|
315
|
+
createResponse.result_info.result_type_cd === 'OK'
|
|
316
|
+
)
|
|
317
|
+
) {
|
|
318
|
+
toast.error(getErrorMessageMap(createResponse));
|
|
319
|
+
return createResponse;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
consoleFn('[DaeryuntalkContext] 새 문의 생성 완료:', createResponse);
|
|
323
|
+
const currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
324
|
+
// 문의 상세 조회
|
|
325
|
+
consoleFn('[DaeryuntalkContext] 문의 상세 조회 시작:', currentChatInquiryNumber);
|
|
326
|
+
const detailResponse = await getChatInquiryDetailNew(currentChatInquiryNumber);
|
|
327
|
+
consoleFn('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
|
|
328
|
+
if (
|
|
329
|
+
!(
|
|
330
|
+
detailResponse.result_info.result_cd === 'OK' ||
|
|
331
|
+
detailResponse.result_info.result_type_cd === 'OK'
|
|
332
|
+
)
|
|
333
|
+
) {
|
|
334
|
+
resetData();
|
|
335
|
+
toast.error(getErrorMessageMap(detailResponse));
|
|
336
|
+
return detailResponse;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// 메세지 리스트
|
|
340
|
+
consoleFn('[DaeryuntalkContext] 문의 채팅 리스트 조회 시작:', currentChatInquiryNumber);
|
|
341
|
+
const chatList = await getChatInquiryMessageList(currentChatInquiryNumber);
|
|
342
|
+
consoleFn('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
|
|
343
|
+
|
|
344
|
+
if (!(chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK')) {
|
|
345
|
+
resetData();
|
|
346
|
+
toast.error(getErrorMessageMap(chatList));
|
|
347
|
+
return chatList;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// 메시지 처리
|
|
351
|
+
setChatInquiryNumber(currentChatInquiryNumber);
|
|
352
|
+
// 메세지 리스트 후처리
|
|
353
|
+
if (chatList.data?.message_list && chatList.data.message_list.length > 0) {
|
|
354
|
+
const uiMessages = chatList.data.message_list
|
|
355
|
+
.sort((a, b) => a.timestamp - b.timestamp)
|
|
356
|
+
.map(item => {
|
|
357
|
+
return convertApiMessageToUiMessage(item, 'basic');
|
|
358
|
+
});
|
|
359
|
+
setMessages(uiMessages);
|
|
360
|
+
consoleFn('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
361
|
+
}
|
|
362
|
+
if (chatList.data?.next_page_yn !== null) {
|
|
363
|
+
setIsNextPage(chatList.data.next_page_yn);
|
|
364
|
+
}
|
|
365
|
+
// 해당 문의 상태
|
|
366
|
+
if (detailResponse.data?.chat_inquiry_state_code) {
|
|
367
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
368
|
+
}
|
|
369
|
+
// 해당 문의 연령 체크
|
|
370
|
+
if (detailResponse.data?.age_consent_state_code) {
|
|
371
|
+
setAgeCheckStatus(detailResponse.data.age_consent_state_code);
|
|
372
|
+
}
|
|
373
|
+
// 워크플로우 스택 업데이트
|
|
374
|
+
if (detailResponse.data?.work_flow_progress_stack) {
|
|
375
|
+
setWorkFlowStack(detailResponse.data?.work_flow_progress_stack ?? []);
|
|
376
|
+
}
|
|
377
|
+
// 해당 문의 오브젝트
|
|
378
|
+
if (detailResponse.data?.object_expose_info) {
|
|
379
|
+
const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
|
|
380
|
+
setMessageObject(uiObject);
|
|
381
|
+
}
|
|
382
|
+
} catch (error) {
|
|
383
|
+
toast.error('채팅 문의 생성에 실패했습니다.');
|
|
384
|
+
console.error('[DaeryuntalkContext] 신규 채팅문의 생성:', error);
|
|
385
|
+
} finally {
|
|
386
|
+
setIsLoading(false);
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
[inquiryMainData, chatInquiryNumber]
|
|
390
|
+
);
|
|
391
|
+
|
|
392
|
+
const startWorkFlow = useCallback(
|
|
393
|
+
async (data: {
|
|
394
|
+
chatInquiryNumber: string;
|
|
395
|
+
messageNumber: string;
|
|
396
|
+
workFlowNumber: string;
|
|
397
|
+
objectNumber: string;
|
|
398
|
+
}) => {
|
|
399
|
+
const { chatInquiryNumber, messageNumber, workFlowNumber, objectNumber } = data;
|
|
400
|
+
|
|
401
|
+
if (!chatInquiryNumber) {
|
|
402
|
+
toast.error('채팅 문의 번호가 없습니다.');
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (!messageNumber) {
|
|
406
|
+
toast.error('메시지 번호가 없습니다.');
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
if (!workFlowNumber) {
|
|
410
|
+
toast.error('워크플로우 번호가 없습니다.');
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
if (!objectNumber) {
|
|
414
|
+
toast.error('오브젝트 번호가 없습니다.');
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
try {
|
|
418
|
+
setIsLoading?.(true);
|
|
419
|
+
const response = await chatWorkFlow(chatInquiryNumber, messageNumber, workFlowNumber, objectNumber);
|
|
420
|
+
if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
|
|
421
|
+
toast.error(getErrorMessageMap(response));
|
|
422
|
+
}
|
|
423
|
+
return response;
|
|
424
|
+
} catch (error) {
|
|
425
|
+
toast.error('워크플로우 생성에 실패했습니다.');
|
|
426
|
+
console.error('[워크 플로우 생성 실패]:', error);
|
|
427
|
+
} finally {
|
|
428
|
+
setIsLoading?.(false);
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
[]
|
|
432
|
+
);
|
|
433
|
+
|
|
434
|
+
const workFlowBack = useCallback(
|
|
435
|
+
async (data: { chatInquiryNumber: string; messageNumber: string; workFlowNavigationCode: string }) => {
|
|
436
|
+
const { chatInquiryNumber, messageNumber, workFlowNavigationCode } = data;
|
|
437
|
+
|
|
438
|
+
if (!chatInquiryNumber) {
|
|
439
|
+
toast.error('채팅 문의 번호가 없습니다.');
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
if (!messageNumber) {
|
|
443
|
+
toast.error('메시지 번호가 없습니다.');
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
if (!workFlowNavigationCode) {
|
|
447
|
+
toast.error('워크플로우 네비게이션 코드가 없습니다.');
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
try {
|
|
451
|
+
setIsLoading?.(true);
|
|
452
|
+
const response = await chatWorkFlowBack(chatInquiryNumber, messageNumber, workFlowNavigationCode);
|
|
453
|
+
if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
|
|
454
|
+
toast.error(getErrorMessageMap(response));
|
|
455
|
+
}
|
|
456
|
+
return response;
|
|
457
|
+
} catch (error) {
|
|
458
|
+
toast.error('동작에 실패했습니다.');
|
|
459
|
+
console.error('[워크 플로우 생성 실패]:', error);
|
|
460
|
+
} finally {
|
|
461
|
+
setIsLoading?.(false);
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
[]
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
const chatUserUpdate = useCallback(
|
|
468
|
+
async (data: { chatInquiryNumber: string; messageNumber: string; name: string; cellPhoneNumber: string }) => {
|
|
469
|
+
const { chatInquiryNumber, messageNumber, name, cellPhoneNumber } = data;
|
|
470
|
+
|
|
471
|
+
// if (!chatInquiryNumber) {
|
|
472
|
+
// toast.error('채팅 개인 정보 업데이트: 문의 번호가 없음');
|
|
473
|
+
// return;
|
|
474
|
+
// }
|
|
475
|
+
|
|
476
|
+
// console.log('chatInquiryNumber', chatInquiryNumber);
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
if (!cellPhoneNumber) {
|
|
480
|
+
toast.error('이름과 휴대폰 번호를 입력해 주세요');
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
if (!name) {
|
|
485
|
+
toast.error('이름과 휴대폰 번호를 입력해 주세요');
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// if (!cellPhoneNumber) {
|
|
490
|
+
// toast.error('채팅 개인 정보 업데이트: 메시지 번호 없음');
|
|
491
|
+
// return;
|
|
492
|
+
// }
|
|
493
|
+
|
|
494
|
+
try {
|
|
495
|
+
setIsLoading?.(true);
|
|
496
|
+
const response = await apiChatUserUpdate(chatInquiryNumber, messageNumber, name, cellPhoneNumber);
|
|
497
|
+
if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
|
|
498
|
+
toast.error(getErrorMessageMap(response));
|
|
499
|
+
}
|
|
500
|
+
return response;
|
|
501
|
+
} catch (error) {
|
|
502
|
+
// toast.error('개인정보 업데이트에 실패했습니다.');
|
|
503
|
+
console.error('[워크 플로우 생성 실패]:', error);
|
|
504
|
+
} finally {
|
|
505
|
+
setIsLoading?.(false);
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
[]
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
// 무한스크롤 실행
|
|
512
|
+
const getNextMessageList = useCallback(async (chatInquiryNumber: string, standardTimestamp: number) => {
|
|
513
|
+
try {
|
|
514
|
+
const response = await getChatInquiryMessageList(chatInquiryNumber, standardTimestamp);
|
|
515
|
+
|
|
516
|
+
if (response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK') {
|
|
517
|
+
const newMessageList = response.data.message_list
|
|
518
|
+
.sort((a, b) => a.timestamp - b.timestamp)
|
|
519
|
+
.map(item => convertApiMessageToUiMessage(item, 'prev'));
|
|
520
|
+
|
|
521
|
+
setIsNextPage(response.data.next_page_yn);
|
|
522
|
+
|
|
523
|
+
setMessages(prev => {
|
|
524
|
+
if (!newMessageList || newMessageList.length === 0) return prev;
|
|
525
|
+
|
|
526
|
+
const existingMessageNumbers = new Set(prev.map(msg => msg.messageNumber));
|
|
527
|
+
|
|
528
|
+
const filteredNewMessages = newMessageList.filter(
|
|
529
|
+
msg => !existingMessageNumbers.has(msg.messageNumber)
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
return [...filteredNewMessages, ...prev];
|
|
533
|
+
});
|
|
534
|
+
} else {
|
|
535
|
+
toast.error(getErrorMessageMap(response));
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
} catch (error: any) {
|
|
539
|
+
console.error(`[실패]:`, error);
|
|
540
|
+
}
|
|
541
|
+
}, []);
|
|
542
|
+
|
|
543
|
+
const attendRoomByHistory = useCallback(
|
|
544
|
+
async (chatInquiryNumber: string) => {
|
|
545
|
+
try {
|
|
546
|
+
const response = await attendChatRoomByHistory({ chatInquiryNumber });
|
|
547
|
+
if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
|
|
548
|
+
toast.error(getErrorMessageMap(response));
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
return response;
|
|
552
|
+
} catch (error: any) {
|
|
553
|
+
console.error(`[실패]:`, error);
|
|
554
|
+
// toast.error(error?.message || '오류가 발생했습니다.');
|
|
555
|
+
} finally {
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
[chatInquiryNumber]
|
|
559
|
+
);
|
|
560
|
+
|
|
561
|
+
const ageConfirm = useCallback(
|
|
562
|
+
async (
|
|
563
|
+
chatInquiryNumber: string,
|
|
564
|
+
ageConsentStateCode: AgeCheckStatusEnums
|
|
565
|
+
) => {
|
|
566
|
+
try {
|
|
567
|
+
const response = await ageCheckUpdate(chatInquiryNumber, ageConsentStateCode);
|
|
568
|
+
|
|
569
|
+
if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
|
|
570
|
+
toast.error(getErrorMessageMap(response));
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
setAgeCheckStatus(ageConsentStateCode);
|
|
574
|
+
return response;
|
|
575
|
+
} catch (error: any) {
|
|
576
|
+
console.error(`[연령 확인 실패]:`, error);
|
|
577
|
+
} finally {
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
[]
|
|
581
|
+
);
|
|
582
|
+
|
|
583
|
+
return {
|
|
584
|
+
attendRoomByHistory,
|
|
585
|
+
startChat,
|
|
586
|
+
sendMessage,
|
|
587
|
+
createNewChat,
|
|
588
|
+
startWorkFlow,
|
|
589
|
+
workFlowBack,
|
|
590
|
+
chatUserUpdate,
|
|
591
|
+
getNextMessageList,
|
|
592
|
+
startSelectedChat,
|
|
593
|
+
ageConfirm
|
|
594
|
+
};
|
|
595
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useFullURL(): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { usePathname, useSearchParams } from 'next/navigation';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
export function useFullURL() {
|
|
4
|
+
const pathname = usePathname();
|
|
5
|
+
const searchParams = useSearchParams();
|
|
6
|
+
const fullUrl = useMemo(() => {
|
|
7
|
+
if (typeof window === 'undefined')
|
|
8
|
+
return '';
|
|
9
|
+
const origin = window.location.origin;
|
|
10
|
+
const query = searchParams.toString();
|
|
11
|
+
const hash = window.location.hash;
|
|
12
|
+
return origin + pathname + (query ? `?${query}` : '') + hash;
|
|
13
|
+
}, [pathname, searchParams]);
|
|
14
|
+
return fullUrl;
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { usePathname, useSearchParams } from 'next/navigation';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
export function useFullURL() {
|
|
5
|
+
const pathname = usePathname();
|
|
6
|
+
const searchParams = useSearchParams();
|
|
7
|
+
|
|
8
|
+
const fullUrl = useMemo(() => {
|
|
9
|
+
if (typeof window === 'undefined') return '';
|
|
10
|
+
const origin = window.location.origin;
|
|
11
|
+
const query = searchParams.toString();
|
|
12
|
+
const hash = window.location.hash;
|
|
13
|
+
return origin + pathname + (query ? `?${query}` : '') + hash;
|
|
14
|
+
}, [pathname, searchParams]);
|
|
15
|
+
|
|
16
|
+
return fullUrl;
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { History } from '../../_api/daeryuntalk/type/response';
|
|
3
|
+
interface props {
|
|
4
|
+
setLoading?: (loading: boolean) => void;
|
|
5
|
+
setIsAuthenticated?: Dispatch<SetStateAction<boolean>>;
|
|
6
|
+
setHistoryList?: Dispatch<SetStateAction<History[]>>;
|
|
7
|
+
}
|
|
8
|
+
export declare const useHistoryHandler: ({ setLoading, setIsAuthenticated, setHistoryList }: props) => {
|
|
9
|
+
goRequestPhone: ({ name, cellPhoneNumber, version }: {
|
|
10
|
+
name: string;
|
|
11
|
+
cellPhoneNumber: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
}) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<import("../../_api/daeryuntalk/type/response").RequestConfirmNumberResponse> | undefined>;
|
|
14
|
+
goHistoryPhoneAuth: ({ name, cellPhoneNumber, certificationNumber, version }: {
|
|
15
|
+
name: string;
|
|
16
|
+
cellPhoneNumber: string;
|
|
17
|
+
certificationNumber: string;
|
|
18
|
+
version?: string;
|
|
19
|
+
}) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<unknown> | undefined>;
|
|
20
|
+
goGetHistoryList: ({ version }: {
|
|
21
|
+
version?: string;
|
|
22
|
+
}) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<import("../../_api/daeryuntalk/type/response").HistoryListResponse> | undefined>;
|
|
23
|
+
};
|
|
24
|
+
export {};
|