@daeryun/dr_components 0.7.79 → 0.7.81
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/asset/images/daeryuntalk/download.svg +5 -0
- package/dist/asset/images/daeryuntalk/firstGo.svg +5 -0
- package/dist/asset/images/daeryuntalk/objectBack.svg +4 -0
- package/dist/asset/images/daeryuntalk/viewer/close.svg +4 -0
- package/dist/asset/images/daeryuntalk/viewer/gray-download.svg +7 -0
- package/dist/asset/images/daeryuntalk/viewer/move-button.svg +4 -0
- package/dist/asset/images/daeryuntalk/viewer/rotate.svg +17 -0
- package/dist/asset/images/daeryuntalk/viewer/zoom-in.svg +5 -0
- package/dist/asset/images/daeryuntalk/viewer/zoom-out.svg +6 -0
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/components/Daeryuntalk/ChatButton.jsx +1 -0
- package/dist/components/Daeryuntalk/ChatButton.tsx +1 -0
- package/dist/components/Daeryuntalk/ChatConversation.d.ts +1 -0
- package/dist/components/Daeryuntalk/ChatConversation.jsx +19 -12
- package/dist/components/Daeryuntalk/ChatConversation.tsx +48 -11
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +27 -6
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +39 -8
- package/dist/components/Daeryuntalk/ChatInput.jsx +23 -3
- package/dist/components/Daeryuntalk/ChatInput.tsx +26 -10
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.d.ts +10 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.jsx +186 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.tsx +252 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatPrivacyAuth.d.ts +8 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatPrivacyAuth.jsx +87 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatPrivacyAuth.tsx +115 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.d.ts +8 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.jsx +13 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.tsx +25 -0
- package/dist/components/Daeryuntalk/ChatItem/RichText.d.ts +7 -0
- package/dist/components/Daeryuntalk/ChatItem/RichText.jsx +25 -0
- package/dist/components/Daeryuntalk/ChatItem/RichText.tsx +32 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowAuthForm.d.ts +8 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowAuthForm.jsx +19 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowAuthForm.tsx +31 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.d.ts +7 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.jsx +20 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.tsx +36 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.d.ts +7 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.jsx +9 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.tsx +16 -0
- package/dist/components/Daeryuntalk/ChatMessage.d.ts +11 -1
- package/dist/components/Daeryuntalk/ChatMessage.jsx +116 -14
- package/dist/components/Daeryuntalk/ChatMessage.tsx +175 -20
- package/dist/components/Daeryuntalk/ChatObject/ObjectBack.d.ts +7 -0
- package/dist/components/Daeryuntalk/ChatObject/ObjectBack.jsx +16 -0
- package/dist/components/Daeryuntalk/ChatObject/ObjectBack.tsx +28 -0
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.d.ts +10 -0
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.jsx +118 -0
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.tsx +162 -0
- package/dist/components/Daeryuntalk/ChatWidget.jsx +7 -3
- package/dist/components/Daeryuntalk/ChatWidget.tsx +9 -5
- package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +37 -5
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +71 -157
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +128 -189
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.d.ts +17 -0
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.jsx +57 -0
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.tsx +82 -0
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.d.ts +3 -0
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +172 -0
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +236 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +133 -0
- package/dist/{lib/api → components/Daeryuntalk/_api}/daeryuntalk/index.js +251 -46
- package/dist/{lib/api → components/Daeryuntalk/_api}/daeryuntalk/index.ts +353 -129
- package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.d.ts +115 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.js +1 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.ts +135 -0
- package/dist/components/Daeryuntalk/_enums/ask-status.d.ts +6 -0
- package/dist/components/Daeryuntalk/_enums/ask-status.js +11 -0
- package/dist/components/Daeryuntalk/_enums/ask-status.ts +11 -0
- package/dist/components/Daeryuntalk/_enums/message_type.d.ts +6 -0
- package/dist/components/Daeryuntalk/_enums/message_type.js +13 -0
- package/dist/components/Daeryuntalk/_enums/message_type.ts +13 -0
- package/dist/components/Daeryuntalk/_enums/sender_type.d.ts +8 -0
- package/dist/components/Daeryuntalk/_enums/sender_type.js +16 -0
- package/dist/components/Daeryuntalk/_enums/sender_type.ts +16 -0
- package/dist/components/Daeryuntalk/_enums/socket_type.d.ts +22 -0
- package/dist/components/Daeryuntalk/_enums/socket_type.js +23 -0
- package/dist/components/Daeryuntalk/_enums/socket_type.ts +31 -0
- package/dist/components/Daeryuntalk/_enums/template.d.ts +32 -0
- package/dist/components/Daeryuntalk/_enums/template.js +49 -0
- package/dist/components/Daeryuntalk/_enums/template.ts +53 -0
- package/dist/components/Daeryuntalk/_enums/work_flow_object_expose.d.ts +34 -0
- package/dist/components/Daeryuntalk/_enums/work_flow_object_expose.js +66 -0
- package/dist/components/Daeryuntalk/_enums/work_flow_object_expose.ts +69 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +46 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +296 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +364 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.d.ts +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.js +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.ts +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.d.ts +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.js +22 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.ts +30 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +21 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +205 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +240 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useViewerHook.d.ts +8 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useViewerHook.js +18 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useViewerHook.ts +23 -0
- package/dist/components/Daeryuntalk/_lib/index.d.ts +7 -0
- package/dist/components/Daeryuntalk/_lib/index.js +101 -0
- package/dist/components/Daeryuntalk/_lib/index.ts +137 -0
- package/dist/components/Daeryuntalk/_lib/utils.d.ts +2 -0
- package/dist/components/Daeryuntalk/_lib/utils.js +16 -0
- package/dist/components/Daeryuntalk/_lib/utils.ts +17 -0
- package/dist/components/Daeryuntalk/{types.d.ts → _types/message.d.ts} +33 -17
- package/dist/components/Daeryuntalk/_types/message.js +19 -0
- package/dist/components/Daeryuntalk/{types.ts → _types/message.ts} +64 -19
- package/dist/components/Daeryuntalk/_types/message_object.d.ts +16 -0
- package/dist/components/Daeryuntalk/_types/message_object.js +1 -0
- package/dist/components/Daeryuntalk/_types/message_object.ts +20 -0
- package/dist/components/Daeryuntalk/_types/socket/message.d.ts +0 -0
- package/dist/components/Daeryuntalk/_types/socket/message.js +1 -0
- package/dist/components/Daeryuntalk/_types/socket/message.ts +0 -0
- package/dist/components/Daeryuntalk/_types/socket/workflow.d.ts +15 -0
- package/dist/components/Daeryuntalk/_types/socket/workflow.js +1 -0
- package/dist/components/Daeryuntalk/_types/socket/workflow.ts +15 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button1.d.ts +10 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button1.jsx +11 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button1.tsx +28 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input1.d.ts +12 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input1.jsx +9 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input1.tsx +39 -0
- package/dist/components/Daeryuntalk/index.tsx +1 -0
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.ts +1 -1
- package/dist/styles/globals.css +161 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -2
- package/dist/components/Daeryuntalk/types.js +0 -8
- package/dist/lib/api/daeryuntalk/index.d.ts +0 -143
- /package/dist/{lib/api → components/Daeryuntalk/_api}/index.d.ts +0 -0
- /package/dist/{lib/api → components/Daeryuntalk/_api}/index.js +0 -0
- /package/dist/{lib/api → components/Daeryuntalk/_api}/index.ts +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// 워크플로우 관련
|
|
2
|
+
export var ObjectNumber;
|
|
3
|
+
(function (ObjectNumber) {
|
|
4
|
+
ObjectNumber["FIRST_VISIT"] = "OB14897658423548P001";
|
|
5
|
+
ObjectNumber["START_CHAT"] = "OB14897658423548P002";
|
|
6
|
+
ObjectNumber["OTHER_RESERVATION"] = "OB14897658423548P003";
|
|
7
|
+
ObjectNumber["ASK_AI"] = "OB14897658423548P004";
|
|
8
|
+
ObjectNumber["FAQ"] = "OB14897658423548P005";
|
|
9
|
+
})(ObjectNumber || (ObjectNumber = {}));
|
|
10
|
+
export const ObjectNumberMap = {
|
|
11
|
+
[ObjectNumber.FIRST_VISIT]: '대륜에 처음 방문하셨나요?',
|
|
12
|
+
[ObjectNumber.START_CHAT]: '채팅 문의 시작하기',
|
|
13
|
+
[ObjectNumber.OTHER_RESERVATION]: '다른 예약 방법 보기',
|
|
14
|
+
[ObjectNumber.ASK_AI]: 'AI 대륜에게 질문하기',
|
|
15
|
+
[ObjectNumber.FAQ]: '자주 묻는 질문'
|
|
16
|
+
};
|
|
17
|
+
export var WorkFlowButtonUiCode;
|
|
18
|
+
(function (WorkFlowButtonUiCode) {
|
|
19
|
+
WorkFlowButtonUiCode["LEFT_FIT_BUTTON"] = "WFL01400001";
|
|
20
|
+
WorkFlowButtonUiCode["FULL_BUTTON"] = "WFL01400002";
|
|
21
|
+
WorkFlowButtonUiCode["TILE_BUTTON"] = "WFL01400003";
|
|
22
|
+
})(WorkFlowButtonUiCode || (WorkFlowButtonUiCode = {}));
|
|
23
|
+
export const WorkFlowButtonUiCodeMap = {
|
|
24
|
+
[WorkFlowButtonUiCode.LEFT_FIT_BUTTON]: '왼쪽 오브젝트 배치',
|
|
25
|
+
[WorkFlowButtonUiCode.FULL_BUTTON]: '가운데 오브젝트 배치',
|
|
26
|
+
[WorkFlowButtonUiCode.TILE_BUTTON]: '타일 오브젝트 배치'
|
|
27
|
+
};
|
|
28
|
+
// 유형
|
|
29
|
+
export var WorkFlowObjectUICode;
|
|
30
|
+
(function (WorkFlowObjectUICode) {
|
|
31
|
+
WorkFlowObjectUICode["BUTTON"] = "WFL01000001";
|
|
32
|
+
WorkFlowObjectUICode["TEXTBOX"] = "WFL01000002";
|
|
33
|
+
WorkFlowObjectUICode["UNKNOWN"] = "WFL01000003";
|
|
34
|
+
})(WorkFlowObjectUICode || (WorkFlowObjectUICode = {}));
|
|
35
|
+
export const WorkFlowObjectUICodeMap = {
|
|
36
|
+
[WorkFlowObjectUICode.BUTTON]: '버튼형',
|
|
37
|
+
[WorkFlowObjectUICode.TEXTBOX]: '텍스트박스형',
|
|
38
|
+
[WorkFlowObjectUICode.UNKNOWN]: ''
|
|
39
|
+
};
|
|
40
|
+
// 뒤로가기 or 처음으로
|
|
41
|
+
export var WorkFlowBackOrInit;
|
|
42
|
+
(function (WorkFlowBackOrInit) {
|
|
43
|
+
WorkFlowBackOrInit["BACK"] = "WFL01300001";
|
|
44
|
+
WorkFlowBackOrInit["INIT"] = "WFL01300002";
|
|
45
|
+
})(WorkFlowBackOrInit || (WorkFlowBackOrInit = {}));
|
|
46
|
+
export const WorkFlowBackOrInitMap = {
|
|
47
|
+
[WorkFlowBackOrInit.BACK]: '이전단계',
|
|
48
|
+
[WorkFlowBackOrInit.INIT]: '최초단계'
|
|
49
|
+
};
|
|
50
|
+
export var WorkFlowButtonActionType;
|
|
51
|
+
(function (WorkFlowButtonActionType) {
|
|
52
|
+
WorkFlowButtonActionType["INTERNAL_LINK"] = "WFL00900001";
|
|
53
|
+
WorkFlowButtonActionType["EXTERNAL_LINK"] = "WFL00900002";
|
|
54
|
+
WorkFlowButtonActionType["INPUT"] = "WFL00900003";
|
|
55
|
+
WorkFlowButtonActionType["WORKFLOW_CALL"] = "WFL00900004";
|
|
56
|
+
WorkFlowButtonActionType["PHONE_CALL"] = "WFL00900005";
|
|
57
|
+
WorkFlowButtonActionType["KAKAO_CONNECT"] = "WFL00900006"; // 카카오연동
|
|
58
|
+
})(WorkFlowButtonActionType || (WorkFlowButtonActionType = {}));
|
|
59
|
+
export const WorkFlowButtonActionMap = {
|
|
60
|
+
[WorkFlowButtonActionType.INTERNAL_LINK]: '내부링크',
|
|
61
|
+
[WorkFlowButtonActionType.EXTERNAL_LINK]: '외부링크',
|
|
62
|
+
[WorkFlowButtonActionType.INPUT]: '입력',
|
|
63
|
+
[WorkFlowButtonActionType.WORKFLOW_CALL]: '워크플로우호출',
|
|
64
|
+
[WorkFlowButtonActionType.PHONE_CALL]: '전화연결',
|
|
65
|
+
[WorkFlowButtonActionType.KAKAO_CONNECT]: '카카오연동'
|
|
66
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// 워크플로우 관련
|
|
2
|
+
|
|
3
|
+
export enum ObjectNumber {
|
|
4
|
+
FIRST_VISIT = 'OB14897658423548P001',
|
|
5
|
+
START_CHAT = 'OB14897658423548P002',
|
|
6
|
+
OTHER_RESERVATION = 'OB14897658423548P003',
|
|
7
|
+
ASK_AI = 'OB14897658423548P004',
|
|
8
|
+
FAQ = 'OB14897658423548P005'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const ObjectNumberMap: Record<ObjectNumber, string> = {
|
|
12
|
+
[ObjectNumber.FIRST_VISIT]: '대륜에 처음 방문하셨나요?',
|
|
13
|
+
[ObjectNumber.START_CHAT]: '채팅 문의 시작하기',
|
|
14
|
+
[ObjectNumber.OTHER_RESERVATION]: '다른 예약 방법 보기',
|
|
15
|
+
[ObjectNumber.ASK_AI]: 'AI 대륜에게 질문하기',
|
|
16
|
+
[ObjectNumber.FAQ]: '자주 묻는 질문'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export enum WorkFlowButtonUiCode {
|
|
20
|
+
LEFT_FIT_BUTTON = 'WFL01400001',
|
|
21
|
+
FULL_BUTTON = 'WFL01400002',
|
|
22
|
+
TILE_BUTTON = 'WFL01400003'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const WorkFlowButtonUiCodeMap: Record<WorkFlowButtonUiCode, string> = {
|
|
26
|
+
[WorkFlowButtonUiCode.LEFT_FIT_BUTTON]: '왼쪽 오브젝트 배치',
|
|
27
|
+
[WorkFlowButtonUiCode.FULL_BUTTON]: '가운데 오브젝트 배치',
|
|
28
|
+
[WorkFlowButtonUiCode.TILE_BUTTON]: '타일 오브젝트 배치'
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// 유형
|
|
32
|
+
export enum WorkFlowObjectUICode {
|
|
33
|
+
BUTTON = 'WFL01000001',
|
|
34
|
+
TEXTBOX = 'WFL01000002',
|
|
35
|
+
UNKNOWN = 'WFL01000003'
|
|
36
|
+
}
|
|
37
|
+
export const WorkFlowObjectUICodeMap: Record<WorkFlowObjectUICode, string> = {
|
|
38
|
+
[WorkFlowObjectUICode.BUTTON]: '버튼형',
|
|
39
|
+
[WorkFlowObjectUICode.TEXTBOX]: '텍스트박스형',
|
|
40
|
+
[WorkFlowObjectUICode.UNKNOWN]: ''
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// 뒤로가기 or 처음으로
|
|
44
|
+
export enum WorkFlowBackOrInit {
|
|
45
|
+
BACK = 'WFL01300001',
|
|
46
|
+
INIT = 'WFL01300002'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const WorkFlowBackOrInitMap: Record<WorkFlowBackOrInit, string> = {
|
|
50
|
+
[WorkFlowBackOrInit.BACK]: '이전단계',
|
|
51
|
+
[WorkFlowBackOrInit.INIT]: '최초단계'
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export enum WorkFlowButtonActionType {
|
|
55
|
+
INTERNAL_LINK = 'WFL00900001', // 내부링크
|
|
56
|
+
EXTERNAL_LINK = 'WFL00900002', // 외부링크
|
|
57
|
+
INPUT = 'WFL00900003', // 입력
|
|
58
|
+
WORKFLOW_CALL = 'WFL00900004', // 워크플로우호출
|
|
59
|
+
PHONE_CALL = 'WFL00900005', // 전화연결
|
|
60
|
+
KAKAO_CONNECT = 'WFL00900006' // 카카오연동
|
|
61
|
+
}
|
|
62
|
+
export const WorkFlowButtonActionMap: Record<WorkFlowButtonActionType, string> = {
|
|
63
|
+
[WorkFlowButtonActionType.INTERNAL_LINK]: '내부링크',
|
|
64
|
+
[WorkFlowButtonActionType.EXTERNAL_LINK]: '외부링크',
|
|
65
|
+
[WorkFlowButtonActionType.INPUT]: '입력',
|
|
66
|
+
[WorkFlowButtonActionType.WORKFLOW_CALL]: '워크플로우호출',
|
|
67
|
+
[WorkFlowButtonActionType.PHONE_CALL]: '전화연결',
|
|
68
|
+
[WorkFlowButtonActionType.KAKAO_CONNECT]: '카카오연동'
|
|
69
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { IChatInquiryMainDataResponse } from '../../_api/daeryuntalk/type/response';
|
|
3
|
+
import { Message } from '../../_types/message';
|
|
4
|
+
import { MessageObject } from '../../_types/message_object';
|
|
5
|
+
interface props {
|
|
6
|
+
setIsLoading: Dispatch<SetStateAction<boolean>>;
|
|
7
|
+
inquiryMainData: IChatInquiryMainDataResponse | null;
|
|
8
|
+
setChatInquiryNumber: Dispatch<SetStateAction<string | null>>;
|
|
9
|
+
setMessages: Dispatch<SetStateAction<Message[]>>;
|
|
10
|
+
setInquiryStatus: Dispatch<SetStateAction<string>>;
|
|
11
|
+
setMessageObject: Dispatch<SetStateAction<MessageObject | null>>;
|
|
12
|
+
chatInquiryNumber: string | null;
|
|
13
|
+
setIsNextPage: Dispatch<SetStateAction<boolean | null>>;
|
|
14
|
+
setWorkFlowStack: Dispatch<SetStateAction<string[]>>;
|
|
15
|
+
sendInquiryJoined: (chatInquiryNumber: string) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const useChatHandler: ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, sendInquiryJoined }: props) => {
|
|
18
|
+
startChat: () => Promise<string>;
|
|
19
|
+
sendMessage: (htmlContent: string, jsonData: any, retry?: boolean) => Promise<void>;
|
|
20
|
+
createNewChat: (version?: string) => Promise<void>;
|
|
21
|
+
startWorkFlow: (data: {
|
|
22
|
+
chatInquiryNumber: string;
|
|
23
|
+
messageNumber: string;
|
|
24
|
+
workFlowNumber: string;
|
|
25
|
+
objectNumber: string;
|
|
26
|
+
}) => Promise<void>;
|
|
27
|
+
workFlowBack: (data: {
|
|
28
|
+
chatInquiryNumber: string;
|
|
29
|
+
messageNumber: string;
|
|
30
|
+
workFlowNavigationCode: string;
|
|
31
|
+
}) => Promise<void>;
|
|
32
|
+
chatUserUpdate: (data: {
|
|
33
|
+
chatInquiryNumber: string;
|
|
34
|
+
messageNumber: string;
|
|
35
|
+
name: string;
|
|
36
|
+
cellPhoneNumber: string;
|
|
37
|
+
}) => Promise<void>;
|
|
38
|
+
getNextMessageList: (chatInquiryNumber: string, standardDateTime: any) => Promise<void>;
|
|
39
|
+
getDownLoadUrl: ({ chatInquiryNumber, fileNumber }: {
|
|
40
|
+
chatInquiryNumber: string;
|
|
41
|
+
fileNumber: string;
|
|
42
|
+
}) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<{
|
|
43
|
+
url: string;
|
|
44
|
+
}>>;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,296 @@
|
|
|
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 } from 'react';
|
|
11
|
+
import { chatUserUpdate as apiChatUserUpdate, chatWorkFlow, chatWorkFlowBack, generateChatInquiry, getChatInquiryDetailNew, getChatInquiryMessageList, getMessageFileDownloadUrl, sendChatMessage } from '../../_api';
|
|
12
|
+
import { convertApiMessageObjectToUiMessageObject, convertApiMessageToUiMessage } from '../../_lib';
|
|
13
|
+
export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack,
|
|
14
|
+
//
|
|
15
|
+
sendInquiryJoined }) => {
|
|
16
|
+
// 채팅 시작 (문의하기 버튼 클릭 시)
|
|
17
|
+
const startChat = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
19
|
+
try {
|
|
20
|
+
setIsLoading(true);
|
|
21
|
+
console.log('[DaeryuntalkContext] 채팅 시작 요청');
|
|
22
|
+
// 기존 문의가 있는지 확인
|
|
23
|
+
const hasExistingInquiry = (inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.progress_inquiry_number) && (inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.progress_inquiry_number.trim()) !== '';
|
|
24
|
+
let currentChatInquiryNumber = '';
|
|
25
|
+
if (hasExistingInquiry) {
|
|
26
|
+
// 기존 문의가 있는 경우, 해당 문의번호 사용
|
|
27
|
+
currentChatInquiryNumber = (inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.progress_inquiry_number) || '';
|
|
28
|
+
console.log('[DaeryuntalkContext] 기존 문의 사용:', currentChatInquiryNumber);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// 새 문의 생성
|
|
32
|
+
console.log('[DaeryuntalkContext] 새 문의 생성 시작');
|
|
33
|
+
const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '');
|
|
34
|
+
if (createResponse && createResponse.data && createResponse.data.chat_inquiry_number) {
|
|
35
|
+
currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
36
|
+
console.log('[DaeryuntalkContext] 새 문의 생성 완료:', currentChatInquiryNumber);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.error('[DaeryuntalkContext] 문의 생성 실패: 문의번호 없음');
|
|
40
|
+
throw new Error('문의 생성 실패');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// 문의 상세 조회
|
|
44
|
+
console.log('[DaeryuntalkContext] 문의 상세 조회 시작:', currentChatInquiryNumber);
|
|
45
|
+
const detailResponse = yield getChatInquiryDetailNew(currentChatInquiryNumber);
|
|
46
|
+
console.log('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
|
|
47
|
+
console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 시작:', currentChatInquiryNumber);
|
|
48
|
+
const chatList = yield getChatInquiryMessageList(currentChatInquiryNumber);
|
|
49
|
+
console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
|
|
50
|
+
// 문의 정보 저장
|
|
51
|
+
setChatInquiryNumber(currentChatInquiryNumber);
|
|
52
|
+
console.log('detailResponse.data.message_list', (_a = chatList === null || chatList === void 0 ? void 0 : chatList.data) === null || _a === void 0 ? void 0 : _a.message_list);
|
|
53
|
+
// 메시지 처리
|
|
54
|
+
if (detailResponse.data && chatList.data) {
|
|
55
|
+
// 해당 무의 입장 소켓1
|
|
56
|
+
sendInquiryJoined(currentChatInquiryNumber);
|
|
57
|
+
// 메세지 리스트 후처리
|
|
58
|
+
if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.message_list) && chatList.data.message_list.length > 0) {
|
|
59
|
+
const uiMessages = chatList.data.message_list
|
|
60
|
+
.sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
|
|
61
|
+
.map(convertApiMessageToUiMessage);
|
|
62
|
+
// const uiMessages = chatList.data.message_list
|
|
63
|
+
// .sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime())
|
|
64
|
+
// .map(convertApiMessageToUiMessage);
|
|
65
|
+
setMessages(uiMessages);
|
|
66
|
+
// const uiMessages = chatList.data.message_list.map(convertApiMessageToUiMessage);
|
|
67
|
+
setMessages(uiMessages);
|
|
68
|
+
console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
69
|
+
}
|
|
70
|
+
if (((_c = chatList.data) === null || _c === void 0 ? void 0 : _c.next_page_yn) !== null) {
|
|
71
|
+
setIsNextPage(chatList.data.next_page_yn);
|
|
72
|
+
}
|
|
73
|
+
// 해당 문의 상태
|
|
74
|
+
if ((_d = detailResponse.data) === null || _d === void 0 ? void 0 : _d.chat_inquiry_state_code) {
|
|
75
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
76
|
+
}
|
|
77
|
+
// 해당 문의 오브젝트
|
|
78
|
+
if ((_e = detailResponse.data) === null || _e === void 0 ? void 0 : _e.object_expose_info) {
|
|
79
|
+
const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
|
|
80
|
+
setMessageObject(uiObject);
|
|
81
|
+
}
|
|
82
|
+
// 해당 문의 상태
|
|
83
|
+
if ((_f = detailResponse.data) === null || _f === void 0 ? void 0 : _f.chat_inquiry_state_code) {
|
|
84
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
85
|
+
}
|
|
86
|
+
// 워크플로우 스택 업데이트
|
|
87
|
+
if ((_g = detailResponse.data) === null || _g === void 0 ? void 0 : _g.work_flow_progress_stack) {
|
|
88
|
+
setWorkFlowStack((_j = (_h = detailResponse.data) === null || _h === void 0 ? void 0 : _h.work_flow_progress_stack) !== null && _j !== void 0 ? _j : []);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
setMessages([]);
|
|
93
|
+
setInquiryStatus('');
|
|
94
|
+
setMessageObject(null);
|
|
95
|
+
setIsNextPage(null);
|
|
96
|
+
console.log('[DaeryuntalkContext] 메시지 없음');
|
|
97
|
+
}
|
|
98
|
+
return currentChatInquiryNumber;
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
console.error('[DaeryuntalkContext] 채팅 시작 오류:', error);
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
setIsLoading(false);
|
|
106
|
+
}
|
|
107
|
+
}), [inquiryMainData]);
|
|
108
|
+
// 메시지 전송
|
|
109
|
+
const sendMessage = useCallback((htmlContent, jsonData, retry) => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
try {
|
|
111
|
+
setIsLoading(true);
|
|
112
|
+
console.log('chatInquiryNumber', chatInquiryNumber);
|
|
113
|
+
yield sendChatMessage(chatInquiryNumber, htmlContent, jsonData);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
console.error('[DaeryuntalkContext] 메시지 전송 중 오류 발생:', error);
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
setIsLoading(false);
|
|
120
|
+
}
|
|
121
|
+
}), [chatInquiryNumber]);
|
|
122
|
+
// 신규 채팅 문의 생성
|
|
123
|
+
const createNewChat = useCallback((version) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
125
|
+
try {
|
|
126
|
+
if (!inquiryMainData) {
|
|
127
|
+
throw new Error('채널이 존재하지 않습니다.');
|
|
128
|
+
}
|
|
129
|
+
setIsLoading(true);
|
|
130
|
+
console.log('chatInquiryNumber', chatInquiryNumber);
|
|
131
|
+
const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '');
|
|
132
|
+
console.log('[DaeryuntalkContext] 새 문의 생성 완료:', createResponse);
|
|
133
|
+
if (createResponse.data) {
|
|
134
|
+
const currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
135
|
+
// 문의 상세 조회
|
|
136
|
+
console.log('[DaeryuntalkContext] 문의 상세 조회 시작:', currentChatInquiryNumber);
|
|
137
|
+
const detailResponse = yield getChatInquiryDetailNew(currentChatInquiryNumber);
|
|
138
|
+
console.log('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
|
|
139
|
+
// 메세지 리스트
|
|
140
|
+
console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 시작:', currentChatInquiryNumber);
|
|
141
|
+
const chatList = yield getChatInquiryMessageList(currentChatInquiryNumber);
|
|
142
|
+
console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
|
|
143
|
+
// 메시지 처리
|
|
144
|
+
if (detailResponse.data && chatList.data) {
|
|
145
|
+
// 해당 무의 입장 소켓
|
|
146
|
+
sendInquiryJoined(currentChatInquiryNumber);
|
|
147
|
+
// 메세지 리스트 후처리
|
|
148
|
+
if (((_a = chatList.data) === null || _a === void 0 ? void 0 : _a.message_list) && chatList.data.message_list.length > 0) {
|
|
149
|
+
const uiMessages = chatList.data.message_list
|
|
150
|
+
.sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime())
|
|
151
|
+
.map(convertApiMessageToUiMessage);
|
|
152
|
+
setMessages(uiMessages);
|
|
153
|
+
console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
154
|
+
}
|
|
155
|
+
if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.next_page_yn) !== null) {
|
|
156
|
+
setIsNextPage(chatList.data.next_page_yn);
|
|
157
|
+
}
|
|
158
|
+
// 해당 문의 상태
|
|
159
|
+
if ((_c = detailResponse.data) === null || _c === void 0 ? void 0 : _c.chat_inquiry_state_code) {
|
|
160
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
161
|
+
}
|
|
162
|
+
// 워크플로우 스택 업데이트
|
|
163
|
+
if ((_d = detailResponse.data) === null || _d === void 0 ? void 0 : _d.work_flow_progress_stack) {
|
|
164
|
+
setWorkFlowStack((_f = (_e = detailResponse.data) === null || _e === void 0 ? void 0 : _e.work_flow_progress_stack) !== null && _f !== void 0 ? _f : []);
|
|
165
|
+
}
|
|
166
|
+
// 해당 문의 오브젝트
|
|
167
|
+
if ((_g = detailResponse.data) === null || _g === void 0 ? void 0 : _g.object_expose_info) {
|
|
168
|
+
const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
|
|
169
|
+
setMessageObject(uiObject);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
setMessages([]);
|
|
174
|
+
setInquiryStatus('');
|
|
175
|
+
setMessageObject(null);
|
|
176
|
+
setIsNextPage(null);
|
|
177
|
+
console.log('[DaeryuntalkContext] 메시지 없음');
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
console.error('[DaeryuntalkContext] 신규 채팅문의 생성:', error);
|
|
185
|
+
}
|
|
186
|
+
finally {
|
|
187
|
+
setIsLoading(false);
|
|
188
|
+
}
|
|
189
|
+
}), [chatInquiryNumber]);
|
|
190
|
+
const startWorkFlow = useCallback((data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
191
|
+
const { chatInquiryNumber, messageNumber, workFlowNumber, objectNumber } = data;
|
|
192
|
+
setIsLoading(true);
|
|
193
|
+
if (!chatInquiryNumber) {
|
|
194
|
+
throw Error('채팅 문의 번호가 없습니다.');
|
|
195
|
+
}
|
|
196
|
+
if (!messageNumber) {
|
|
197
|
+
throw Error('메시지 번호가 없습니다.');
|
|
198
|
+
}
|
|
199
|
+
if (!workFlowNumber) {
|
|
200
|
+
throw Error('워크플로우 번호가 없습니다.');
|
|
201
|
+
}
|
|
202
|
+
if (!objectNumber) {
|
|
203
|
+
throw Error('오브젝트 번호가 없습니다.');
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
yield chatWorkFlow(chatInquiryNumber, messageNumber, workFlowNumber, objectNumber);
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
console.error('[워크 플로우 생성 실패]:', error);
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
setIsLoading(false);
|
|
213
|
+
}
|
|
214
|
+
}), []);
|
|
215
|
+
const workFlowBack = useCallback((data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
216
|
+
const { chatInquiryNumber, messageNumber, workFlowNavigationCode } = data;
|
|
217
|
+
setIsLoading(true);
|
|
218
|
+
if (!chatInquiryNumber) {
|
|
219
|
+
throw Error('채팅 문의 번호가 없습니다.');
|
|
220
|
+
}
|
|
221
|
+
if (!messageNumber) {
|
|
222
|
+
throw Error('메시지 번호가 없습니다.');
|
|
223
|
+
}
|
|
224
|
+
if (!workFlowNavigationCode) {
|
|
225
|
+
throw Error('워크플로우 네비게이션 코드가 없습니다.');
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
yield chatWorkFlowBack(chatInquiryNumber, messageNumber, workFlowNavigationCode);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
console.error('[워크 플로우 생성 실패]:', error);
|
|
232
|
+
}
|
|
233
|
+
finally {
|
|
234
|
+
setIsLoading(false);
|
|
235
|
+
}
|
|
236
|
+
}), []);
|
|
237
|
+
const chatUserUpdate = useCallback((data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
238
|
+
const { chatInquiryNumber, messageNumber, name, cellPhoneNumber } = data;
|
|
239
|
+
setIsLoading(true);
|
|
240
|
+
if (!chatInquiryNumber) {
|
|
241
|
+
throw new Error('채팅 개인 정보 업데이트: 문의 번호가 없음');
|
|
242
|
+
}
|
|
243
|
+
if (!messageNumber) {
|
|
244
|
+
throw new Error('채팅 개인 정보 업데이트: 메시지 번호 없음');
|
|
245
|
+
}
|
|
246
|
+
if (!name) {
|
|
247
|
+
throw new Error('채팅 개인 정보 업데이트: 이름 없음');
|
|
248
|
+
}
|
|
249
|
+
if (!cellPhoneNumber) {
|
|
250
|
+
throw new Error('채팅 개인 정보 업데이트: 메시지 번호 없음');
|
|
251
|
+
}
|
|
252
|
+
try {
|
|
253
|
+
yield apiChatUserUpdate(chatInquiryNumber, messageNumber, name, cellPhoneNumber);
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
console.error('[워크 플로우 생성 실패]:', error);
|
|
257
|
+
}
|
|
258
|
+
finally {
|
|
259
|
+
setIsLoading(false);
|
|
260
|
+
}
|
|
261
|
+
}), []);
|
|
262
|
+
const getNextMessageList = useCallback((chatInquiryNumber, standardDateTime) => __awaiter(void 0, void 0, void 0, function* () {
|
|
263
|
+
const chatList = yield getChatInquiryMessageList(chatInquiryNumber, standardDateTime);
|
|
264
|
+
if (chatList.data) {
|
|
265
|
+
// 앞에 생성될 여기서는 앞에서부터 채워야함
|
|
266
|
+
const newMessageList = chatList.data.message_list
|
|
267
|
+
.sort((a, b) => a.timestamp - b.timestamp)
|
|
268
|
+
.map(item => {
|
|
269
|
+
return convertApiMessageToUiMessage(item);
|
|
270
|
+
});
|
|
271
|
+
setIsNextPage(chatList.data.next_page_yn);
|
|
272
|
+
setMessages(prev => {
|
|
273
|
+
if (newMessageList && newMessageList.length > 0) {
|
|
274
|
+
return [...newMessageList, ...prev];
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
return [...prev];
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}), []);
|
|
282
|
+
// 파일 다운로드 url
|
|
283
|
+
const getDownLoadUrl = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ chatInquiryNumber, fileNumber }) {
|
|
284
|
+
return yield getMessageFileDownloadUrl({ chatInquiryNumber, fileNumber });
|
|
285
|
+
}), []);
|
|
286
|
+
return {
|
|
287
|
+
startChat,
|
|
288
|
+
sendMessage,
|
|
289
|
+
createNewChat,
|
|
290
|
+
startWorkFlow,
|
|
291
|
+
workFlowBack,
|
|
292
|
+
chatUserUpdate,
|
|
293
|
+
getNextMessageList,
|
|
294
|
+
getDownLoadUrl
|
|
295
|
+
};
|
|
296
|
+
};
|