@daeryun/dr_components 0.7.79 → 0.7.80
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/categoryMenuName.js +0 -3
- package/dist/lib/categoryMenuName.ts +0 -2
- 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
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import React, { createContext,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
generateChatInquiry,
|
|
9
|
-
getChatInquiryDetailNew,
|
|
10
|
-
MESSAGE_TYPES,
|
|
11
|
-
sendChatMessage
|
|
12
|
-
} from '../../lib/api/daeryuntalk';
|
|
13
|
-
|
|
14
|
-
const mapMessageSender = (messageType: string): MessageSender => {
|
|
15
|
-
switch (messageType) {
|
|
16
|
-
case MESSAGE_TYPES.SYSTEM:
|
|
17
|
-
return 'system';
|
|
18
|
-
case MESSAGE_TYPES.CUSTOMER:
|
|
19
|
-
return 'user';
|
|
20
|
-
case MESSAGE_TYPES.BOT:
|
|
21
|
-
return 'bot';
|
|
22
|
-
case MESSAGE_TYPES.OPERATOR:
|
|
23
|
-
case MESSAGE_TYPES.MACRO:
|
|
24
|
-
return 'operator';
|
|
25
|
-
default:
|
|
26
|
-
return 'system';
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const convertApiMessageToUiMessage = (apiMessage: ApiChatMessage): Message => {
|
|
31
|
-
return {
|
|
32
|
-
// 핵심 필드
|
|
33
|
-
msgNo: apiMessage.msg_no,
|
|
34
|
-
plainText: apiMessage.plain_text,
|
|
35
|
-
sender: mapMessageSender(apiMessage.msg_type) as MessageSender,
|
|
36
|
-
|
|
37
|
-
// API에서 오는 모든 필드들
|
|
38
|
-
msgType: apiMessage.msg_type,
|
|
39
|
-
msgStatus: apiMessage.msg_status,
|
|
40
|
-
userKey: apiMessage.user_key,
|
|
41
|
-
inquiryNo: apiMessage.inquiry_no,
|
|
42
|
-
createdAt: new Date(apiMessage.created_at),
|
|
43
|
-
updatedAt: apiMessage.updated_at ? new Date(apiMessage.updated_at) : undefined,
|
|
44
|
-
language: apiMessage.language,
|
|
45
|
-
|
|
46
|
-
// 블록 관련
|
|
47
|
-
blocks: apiMessage.blocks.map(block => ({
|
|
48
|
-
type: block.type,
|
|
49
|
-
value: block.value
|
|
50
|
-
}))
|
|
51
|
-
};
|
|
52
|
-
};
|
|
1
|
+
import React, { createContext, ReactNode, useCallback, useContext, useRef, useState } from 'react';
|
|
2
|
+
import { FileInfo, Message } from './_types/message';
|
|
3
|
+
import { ChatInquiryDetailDataResponse, IChatInquiryMainDataResponse } from './_api/daeryuntalk/type/response';
|
|
4
|
+
import { MessageObject } from './_types/message_object';
|
|
5
|
+
import { useSocketEventHandler } from './_hooks/talkprovider/useSocketEventHandler';
|
|
6
|
+
import { useChatHandler } from './_hooks/talkprovider/useChatHandler';
|
|
7
|
+
import { useViewerHook } from './_hooks/talkprovider/useViewerHook';
|
|
53
8
|
|
|
54
9
|
type DaeryuntalkContextType = {
|
|
55
10
|
messages: Message[];
|
|
11
|
+
inquiryStatus: string;
|
|
12
|
+
messageObject: MessageObject | null;
|
|
13
|
+
isNextPage: boolean | null;
|
|
14
|
+
|
|
56
15
|
isConnected: boolean;
|
|
57
16
|
isLoading: boolean;
|
|
58
|
-
sendMessage: (
|
|
17
|
+
sendMessage: (htmlContent: string, jsonData: any) => void;
|
|
59
18
|
viewHistory: () => void;
|
|
60
19
|
initializeDaeryuntalk: (version?: string) => void;
|
|
61
20
|
startChat: () => Promise<string | void>;
|
|
21
|
+
createNewChat: () => void;
|
|
22
|
+
startWorkFlow: (data: {
|
|
23
|
+
chatInquiryNumber: string;
|
|
24
|
+
messageNumber: string;
|
|
25
|
+
workFlowNumber: string;
|
|
26
|
+
objectNumber: string;
|
|
27
|
+
}) => void;
|
|
28
|
+
workFlowBack: (data: { chatInquiryNumber: string; messageNumber: string; workFlowNavigationCode: string }) => void;
|
|
29
|
+
chatInquiryNumber: string | null;
|
|
30
|
+
workFlowStack: string[];
|
|
31
|
+
sendHeartbeat: (chatInquiryNumber: string) => void;
|
|
32
|
+
sendInquiryLeft: (chatInquiryNumber: string) => void;
|
|
33
|
+
chatUserUpdate: (data: {
|
|
34
|
+
chatInquiryNumber: string;
|
|
35
|
+
messageNumber: string;
|
|
36
|
+
name: string;
|
|
37
|
+
cellPhoneNumber: string;
|
|
38
|
+
}) => void;
|
|
39
|
+
getNextMessageList: (chatInquiryNumber: string, standardDateTime: any) => void;
|
|
40
|
+
//
|
|
62
41
|
isOpen?: boolean;
|
|
63
|
-
chatData?:
|
|
64
|
-
inquiryMainData?:
|
|
42
|
+
chatData?: ChatInquiryDetailDataResponse | null;
|
|
43
|
+
inquiryMainData?: IChatInquiryMainDataResponse | null;
|
|
65
44
|
isAuthenticated?: boolean;
|
|
66
45
|
isSocketInitialized?: boolean;
|
|
67
46
|
isSocketConnected?: boolean;
|
|
68
47
|
error?: Error | null;
|
|
69
48
|
closeDaeryuntalk?: () => void;
|
|
49
|
+
|
|
50
|
+
// 이미지 뷰어용
|
|
51
|
+
isImageViewerOpen?: boolean;
|
|
52
|
+
selectedImageFile?: FileInfo | null;
|
|
53
|
+
imageViewerMessage?: Message | null;
|
|
54
|
+
openImageViewer?: (file: FileInfo, message: Message) => void;
|
|
55
|
+
closeImageViewer?: () => void;
|
|
70
56
|
};
|
|
71
57
|
|
|
72
58
|
// 기본값으로 컨텍스트 생성
|
|
73
59
|
const DaeryuntalkContext = createContext<DaeryuntalkContextType>({
|
|
74
60
|
messages: [],
|
|
61
|
+
inquiryStatus: '',
|
|
62
|
+
messageObject: null,
|
|
63
|
+
isNextPage: null,
|
|
64
|
+
//
|
|
75
65
|
isConnected: false,
|
|
76
66
|
isLoading: false,
|
|
77
67
|
sendMessage: () => {},
|
|
78
68
|
viewHistory: () => {},
|
|
79
69
|
initializeDaeryuntalk: () => {},
|
|
80
70
|
startChat: async () => {},
|
|
71
|
+
createNewChat: async () => {},
|
|
72
|
+
startWorkFlow: async () => {},
|
|
73
|
+
workFlowBack: async () => {},
|
|
74
|
+
chatInquiryNumber: '',
|
|
75
|
+
workFlowStack: [],
|
|
76
|
+
sendHeartbeat: () => {},
|
|
77
|
+
sendInquiryLeft: () => {},
|
|
78
|
+
chatUserUpdate: () => {},
|
|
79
|
+
getNextMessageList: () => {},
|
|
80
|
+
//
|
|
81
81
|
isOpen: false,
|
|
82
82
|
chatData: null,
|
|
83
83
|
inquiryMainData: null,
|
|
@@ -86,6 +86,8 @@ const DaeryuntalkContext = createContext<DaeryuntalkContextType>({
|
|
|
86
86
|
isSocketConnected: false,
|
|
87
87
|
error: null,
|
|
88
88
|
closeDaeryuntalk: () => {}
|
|
89
|
+
|
|
90
|
+
// 이미지 뷰어용
|
|
89
91
|
});
|
|
90
92
|
|
|
91
93
|
// 프로바이더 컴포넌트 생성
|
|
@@ -94,144 +96,65 @@ type DaeryuntalkProviderProps = {
|
|
|
94
96
|
};
|
|
95
97
|
|
|
96
98
|
export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ children }) => {
|
|
99
|
+
const [inquiryStatus, setInquiryStatus] = useState<string>('');
|
|
100
|
+
|
|
101
|
+
// 채팅 진행중에 필요한 state들
|
|
97
102
|
const [messages, setMessages] = useState<Message[]>([]);
|
|
98
|
-
const [
|
|
99
|
-
const [
|
|
100
|
-
const [
|
|
101
|
-
const [chatData, setChatData] = useState<ChatInquiryDetailData | null>(null);
|
|
103
|
+
const [messageObject, setMessageObject] = useState<MessageObject | null>(null);
|
|
104
|
+
const [workFlowStack, setWorkFlowStack] = useState<string[]>([]);
|
|
105
|
+
const [isNextPage, setIsNextPage] = useState<boolean | null>(null);
|
|
102
106
|
const [chatInquiryNumber, setChatInquiryNumber] = useState<string | null>(null);
|
|
103
107
|
|
|
104
|
-
//
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
console.error('[DaeryuntalkContext] 초기화 오류:', error);
|
|
152
|
-
} finally {
|
|
153
|
-
console.log('[DaeryuntalkContext] 로딩 상태 설정: false');
|
|
154
|
-
setIsLoading(false);
|
|
155
|
-
}
|
|
156
|
-
}, []);
|
|
157
|
-
|
|
158
|
-
// 채팅 시작 (문의하기 버튼 클릭 시)
|
|
159
|
-
const startChat = useCallback(async () => {
|
|
160
|
-
try {
|
|
161
|
-
setIsLoading(true);
|
|
162
|
-
console.log('[DaeryuntalkContext] 채팅 시작 요청');
|
|
163
|
-
|
|
164
|
-
// 기존 문의가 있는지 확인
|
|
165
|
-
const hasExistingInquiry =
|
|
166
|
-
inquiryMainData?.data?.progress_inquiry_number &&
|
|
167
|
-
inquiryMainData.data.progress_inquiry_number.trim() !== '';
|
|
168
|
-
|
|
169
|
-
let currentChatInquiryNumber = '';
|
|
170
|
-
|
|
171
|
-
if (hasExistingInquiry) {
|
|
172
|
-
// 기존 문의가 있는 경우, 해당 문의번호 사용
|
|
173
|
-
currentChatInquiryNumber = inquiryMainData!.data.progress_inquiry_number;
|
|
174
|
-
console.log('[DaeryuntalkContext] 기존 문의 사용:', currentChatInquiryNumber);
|
|
175
|
-
} else {
|
|
176
|
-
// 새 문의 생성
|
|
177
|
-
console.log('[DaeryuntalkContext] 새 문의 생성 시작');
|
|
178
|
-
const createResponse = await generateChatInquiry();
|
|
179
|
-
|
|
180
|
-
if (createResponse && createResponse.data && createResponse.data.chat_inquiry_number) {
|
|
181
|
-
currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
182
|
-
console.log('[DaeryuntalkContext] 새 문의 생성 완료:', currentChatInquiryNumber);
|
|
183
|
-
} else {
|
|
184
|
-
console.error('[DaeryuntalkContext] 문의 생성 실패: 문의번호 없음');
|
|
185
|
-
throw new Error('문의 생성 실패');
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// 문의 상세 조회
|
|
190
|
-
console.log('[DaeryuntalkContext] 문의 상세 조회 시작:', currentChatInquiryNumber);
|
|
191
|
-
const detailResponse = await getChatInquiryDetailNew(currentChatInquiryNumber);
|
|
192
|
-
console.log('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
|
|
193
|
-
|
|
194
|
-
// 문의 정보 저장
|
|
195
|
-
setChatInquiryNumber(currentChatInquiryNumber);
|
|
196
|
-
setChatData(detailResponse.data || null);
|
|
197
|
-
|
|
198
|
-
// 메시지 처리
|
|
199
|
-
if (detailResponse.data?.messages && detailResponse.data.messages.length > 0) {
|
|
200
|
-
const uiMessages = detailResponse.data.messages.map(convertApiMessageToUiMessage);
|
|
201
|
-
setMessages(uiMessages);
|
|
202
|
-
console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
203
|
-
} else {
|
|
204
|
-
setMessages([]);
|
|
205
|
-
console.log('[DaeryuntalkContext] 메시지 없음');
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return currentChatInquiryNumber;
|
|
209
|
-
} catch (error) {
|
|
210
|
-
console.error('[DaeryuntalkContext] 채팅 시작 오류:', error);
|
|
211
|
-
throw error;
|
|
212
|
-
} finally {
|
|
213
|
-
setIsLoading(false);
|
|
214
|
-
}
|
|
215
|
-
}, [inquiryMainData]);
|
|
216
|
-
|
|
217
|
-
// 메시지 전송
|
|
218
|
-
const sendMessage = useCallback(
|
|
219
|
-
async (text: string, retry?: boolean) => {
|
|
220
|
-
try {
|
|
221
|
-
/** todo 지금은 여기로직이 비어있지만
|
|
222
|
-
* 추후에는 메시지 전송 로직을 한 이후에 로컬로 메시지를 임시로 저장하고 그걸 보내야함
|
|
223
|
-
* 그럴라면 인터페이스 규격이 서로달라 내가 임시로 작성할지 아니면 응답 데이터를 변조해서 쓸지 고민
|
|
224
|
-
*/
|
|
225
|
-
await sendChatMessage(chatInquiryNumber as string, text);
|
|
226
|
-
} catch (error) {
|
|
227
|
-
console.error('[DaeryuntalkContext] 메시지 전송 중 오류 발생:', error);
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
[chatInquiryNumber]
|
|
231
|
-
);
|
|
108
|
+
// 전역 소켓 연결 상태
|
|
109
|
+
const [isConnected, setIsConnected] = useState<boolean>(false);
|
|
110
|
+
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
111
|
+
const [inquiryMainData, setInquiryMainData] = useState<IChatInquiryMainDataResponse | null>(null);
|
|
112
|
+
|
|
113
|
+
const socketRef = useRef<WebSocket | null>(null);
|
|
114
|
+
|
|
115
|
+
// 소켓 관련 API + 채팅 시작
|
|
116
|
+
const { initializeDaeryuntalk, sendHeartbeat, sendInquiryJoined, sendInquiryLeft, sendHistoryEntered } =
|
|
117
|
+
useSocketEventHandler({
|
|
118
|
+
setIsConnected,
|
|
119
|
+
setIsLoading,
|
|
120
|
+
setMessages,
|
|
121
|
+
setInquiryMainData,
|
|
122
|
+
setWorkFlowStack,
|
|
123
|
+
setMessageObject,
|
|
124
|
+
socketRef: socketRef
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// MSG15591497825895676
|
|
128
|
+
|
|
129
|
+
// 채팅 관련
|
|
130
|
+
const {
|
|
131
|
+
startChat,
|
|
132
|
+
sendMessage,
|
|
133
|
+
createNewChat,
|
|
134
|
+
startWorkFlow,
|
|
135
|
+
workFlowBack,
|
|
136
|
+
chatUserUpdate,
|
|
137
|
+
getNextMessageList,
|
|
138
|
+
getDownLoadUrl
|
|
139
|
+
} = useChatHandler({
|
|
140
|
+
setIsLoading,
|
|
141
|
+
inquiryMainData,
|
|
142
|
+
setChatInquiryNumber,
|
|
143
|
+
setMessages,
|
|
144
|
+
setInquiryStatus,
|
|
145
|
+
setMessageObject,
|
|
146
|
+
chatInquiryNumber,
|
|
147
|
+
setIsNextPage,
|
|
148
|
+
setWorkFlowStack,
|
|
149
|
+
sendInquiryJoined
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// 이미지 뷰어용
|
|
153
|
+
const { isImageViewerOpen, selectedImageFile, imageViewerMessage, openImageViewer, closeImageViewer } =
|
|
154
|
+
useViewerHook();
|
|
232
155
|
|
|
233
156
|
// todo 메시지 이력 조회 함수
|
|
234
|
-
const viewHistory = () => {};
|
|
157
|
+
const viewHistory = useCallback(async () => {}, []);
|
|
235
158
|
|
|
236
159
|
return (
|
|
237
160
|
<DaeryuntalkContext.Provider
|
|
@@ -244,7 +167,23 @@ export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ childr
|
|
|
244
167
|
initializeDaeryuntalk,
|
|
245
168
|
startChat,
|
|
246
169
|
inquiryMainData,
|
|
247
|
-
|
|
170
|
+
inquiryStatus,
|
|
171
|
+
messageObject,
|
|
172
|
+
isNextPage,
|
|
173
|
+
createNewChat,
|
|
174
|
+
startWorkFlow,
|
|
175
|
+
chatInquiryNumber,
|
|
176
|
+
workFlowBack,
|
|
177
|
+
workFlowStack,
|
|
178
|
+
sendHeartbeat,
|
|
179
|
+
sendInquiryLeft,
|
|
180
|
+
chatUserUpdate,
|
|
181
|
+
getNextMessageList,
|
|
182
|
+
isImageViewerOpen,
|
|
183
|
+
selectedImageFile,
|
|
184
|
+
imageViewerMessage,
|
|
185
|
+
openImageViewer,
|
|
186
|
+
closeImageViewer
|
|
248
187
|
}}
|
|
249
188
|
>
|
|
250
189
|
{children}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { JSONContent } from '@tiptap/core';
|
|
2
|
+
export interface TiptapEditorRef {
|
|
3
|
+
clearContent: () => void;
|
|
4
|
+
getHTML: () => string;
|
|
5
|
+
getJSON: () => JSONContent;
|
|
6
|
+
isEmpty: () => boolean;
|
|
7
|
+
focus: () => void;
|
|
8
|
+
insertContent: (content: string) => void;
|
|
9
|
+
}
|
|
10
|
+
interface TiptapProps {
|
|
11
|
+
onChange?: (html: string, json: JSONContent) => void;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
onEnterKeyPress?: () => void;
|
|
14
|
+
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
15
|
+
}
|
|
16
|
+
declare const Tiptap: import("react").ForwardRefExoticComponent<TiptapProps & import("react").RefAttributes<TiptapEditorRef>>;
|
|
17
|
+
export default Tiptap;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useEditor, EditorContent } from '@tiptap/react';
|
|
2
|
+
import StarterKit from '@tiptap/starter-kit';
|
|
3
|
+
import Placeholder from '@tiptap/extension-placeholder';
|
|
4
|
+
import { useImperativeHandle, forwardRef } from 'react';
|
|
5
|
+
const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력하세요...', onEnterKeyPress, onKeyDown }, ref) => {
|
|
6
|
+
const editor = useEditor({
|
|
7
|
+
extensions: [
|
|
8
|
+
StarterKit.configure({
|
|
9
|
+
heading: false,
|
|
10
|
+
blockquote: false,
|
|
11
|
+
codeBlock: false,
|
|
12
|
+
horizontalRule: false
|
|
13
|
+
}),
|
|
14
|
+
Placeholder.configure({ placeholder })
|
|
15
|
+
],
|
|
16
|
+
content: '',
|
|
17
|
+
enableInputRules: false,
|
|
18
|
+
enablePasteRules: false,
|
|
19
|
+
onUpdate: ({ editor }) => {
|
|
20
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(editor.getHTML(), editor.getJSON());
|
|
21
|
+
},
|
|
22
|
+
editorProps: {
|
|
23
|
+
attributes: {
|
|
24
|
+
class: 'focus:outline-none min-h-[44px] max-h-[72px] overflow-y-auto resize-none px-[10px] py-[4px]'
|
|
25
|
+
},
|
|
26
|
+
handleKeyDown: (view, event) => {
|
|
27
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
const content = editor === null || editor === void 0 ? void 0 : editor.getText();
|
|
30
|
+
if (content && content.trim() && onEnterKeyPress) {
|
|
31
|
+
onEnterKeyPress();
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
useImperativeHandle(ref, () => ({
|
|
41
|
+
clearContent: () => {
|
|
42
|
+
editor === null || editor === void 0 ? void 0 : editor.commands.clearContent(true);
|
|
43
|
+
},
|
|
44
|
+
getHTML: () => (editor === null || editor === void 0 ? void 0 : editor.getHTML()) || '',
|
|
45
|
+
getJSON: () => (editor === null || editor === void 0 ? void 0 : editor.getJSON()) || { type: 'doc', content: [] },
|
|
46
|
+
isEmpty: () => (editor === null || editor === void 0 ? void 0 : editor.isEmpty) || true,
|
|
47
|
+
focus: () => editor === null || editor === void 0 ? void 0 : editor.commands.focus(),
|
|
48
|
+
insertContent: (content) => {
|
|
49
|
+
editor === null || editor === void 0 ? void 0 : editor.commands.insertContent(content);
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
if (!editor)
|
|
53
|
+
return null;
|
|
54
|
+
return <EditorContent editor={editor} tabIndex={0} className="rounded-md border text-black dark:text-white"/>;
|
|
55
|
+
});
|
|
56
|
+
Tiptap.displayName = 'Tiptap';
|
|
57
|
+
export default Tiptap;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useEditor, EditorContent } from '@tiptap/react';
|
|
2
|
+
import StarterKit from '@tiptap/starter-kit';
|
|
3
|
+
import Placeholder from '@tiptap/extension-placeholder';
|
|
4
|
+
import { useImperativeHandle, forwardRef } from 'react';
|
|
5
|
+
import { JSONContent } from '@tiptap/core'; // 추가 필요
|
|
6
|
+
|
|
7
|
+
export interface TiptapEditorRef {
|
|
8
|
+
clearContent: () => void;
|
|
9
|
+
getHTML: () => string;
|
|
10
|
+
getJSON: () => JSONContent;
|
|
11
|
+
isEmpty: () => boolean;
|
|
12
|
+
focus: () => void;
|
|
13
|
+
insertContent: (content: string) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface TiptapProps {
|
|
17
|
+
onChange?: (html: string, json: JSONContent) => void;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
onEnterKeyPress?: () => void;
|
|
20
|
+
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const Tiptap = forwardRef<TiptapEditorRef, TiptapProps>(
|
|
24
|
+
({ onChange, placeholder = '메시지를 입력하세요...', onEnterKeyPress, onKeyDown }, ref) => {
|
|
25
|
+
const editor = useEditor({
|
|
26
|
+
extensions: [
|
|
27
|
+
StarterKit.configure({
|
|
28
|
+
heading: false,
|
|
29
|
+
blockquote: false,
|
|
30
|
+
codeBlock: false,
|
|
31
|
+
horizontalRule: false
|
|
32
|
+
}),
|
|
33
|
+
Placeholder.configure({ placeholder })
|
|
34
|
+
],
|
|
35
|
+
content: '',
|
|
36
|
+
enableInputRules: false,
|
|
37
|
+
enablePasteRules: false,
|
|
38
|
+
onUpdate: ({ editor }) => {
|
|
39
|
+
onChange?.(editor.getHTML(), editor.getJSON());
|
|
40
|
+
},
|
|
41
|
+
editorProps: {
|
|
42
|
+
attributes: {
|
|
43
|
+
class: 'focus:outline-none min-h-[44px] max-h-[72px] overflow-y-auto resize-none px-[10px] py-[4px]'
|
|
44
|
+
},
|
|
45
|
+
handleKeyDown: (view, event) => {
|
|
46
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
const content = editor?.getText();
|
|
49
|
+
if (content && content.trim() && onEnterKeyPress) {
|
|
50
|
+
onEnterKeyPress();
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
onKeyDown?.(event as unknown as React.KeyboardEvent);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
useImperativeHandle(ref, () => ({
|
|
62
|
+
clearContent: () => {
|
|
63
|
+
editor?.commands.clearContent(true);
|
|
64
|
+
},
|
|
65
|
+
getHTML: () => editor?.getHTML() || '',
|
|
66
|
+
getJSON: () => editor?.getJSON() || { type: 'doc', content: [] },
|
|
67
|
+
isEmpty: () => editor?.isEmpty || true,
|
|
68
|
+
focus: () => editor?.commands.focus(),
|
|
69
|
+
insertContent: (content: string) => {
|
|
70
|
+
editor?.commands.insertContent(content);
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
if (!editor) return null;
|
|
75
|
+
|
|
76
|
+
return <EditorContent editor={editor} tabIndex={0} className="rounded-md border text-black dark:text-white" />;
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
Tiptap.displayName = 'Tiptap';
|
|
81
|
+
|
|
82
|
+
export default Tiptap;
|