@daeryun/dr_components 0.9.1 → 0.9.3
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/components/Daeryuntalk/ChatButton.jsx +3 -3
- package/dist/components/Daeryuntalk/ChatButton.tsx +3 -3
- package/dist/components/Daeryuntalk/ChatConversation.jsx +1 -56
- package/dist/components/Daeryuntalk/ChatConversation.tsx +2 -56
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +2 -1
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +11 -2
- package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +5 -2
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +12 -7
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +24 -9
- package/dist/components/Daeryuntalk/Toast/Toast.jsx +4 -2
- package/dist/components/Daeryuntalk/Toast/Toast.tsx +4 -2
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +2 -3
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +6 -6
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +5 -4
- package/dist/components/Daeryuntalk/_enums/socket_type.d.ts +8 -0
- package/dist/components/Daeryuntalk/_enums/socket_type.js +9 -0
- package/dist/components/Daeryuntalk/_enums/socket_type.ts +9 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +2 -1
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +3 -3
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +13 -3
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +3 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +23 -20
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +25 -20
- package/dist/components/Daeryuntalk/_hooks/view/useChatSocketState.js +1 -1
- package/dist/components/Daeryuntalk/_hooks/view/useChatSocketState.ts +1 -1
- package/dist/components/Daeryuntalk/index.d.ts +2 -1
- package/dist/components/Daeryuntalk/index.jsx +2 -2
- package/dist/components/Daeryuntalk/index.tsx +4 -3
- package/dist/components/Seo/SeoStrength.jsx +3 -3
- package/dist/components/Seo/SeoStrength.tsx +3 -3
- package/dist/styles/globals.css +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -10,12 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import React, { useCallback, useEffect } from 'react';
|
|
11
11
|
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
12
12
|
const ChatButton = ({ isOpen, onClick, apiVersion, isMobile = false, hashValue = null }) => {
|
|
13
|
-
const { initializeDaeryuntalk } = useDaeryuntalk();
|
|
13
|
+
const { initializeDaeryuntalk, centerCode } = useDaeryuntalk();
|
|
14
14
|
const handleClick = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
onClick();
|
|
16
16
|
if (!isOpen) {
|
|
17
17
|
try {
|
|
18
|
-
yield initializeDaeryuntalk('', isOpen, apiVersion);
|
|
18
|
+
yield initializeDaeryuntalk('', isOpen, centerCode, apiVersion);
|
|
19
19
|
}
|
|
20
20
|
catch (err) {
|
|
21
21
|
console.error('Daeryuntalk 초기화 실패:', err);
|
|
@@ -27,7 +27,7 @@ const ChatButton = ({ isOpen, onClick, apiVersion, isMobile = false, hashValue =
|
|
|
27
27
|
if (hashValue) {
|
|
28
28
|
const init = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
29
|
try {
|
|
30
|
-
yield initializeDaeryuntalk(hashValue, isOpen, apiVersion);
|
|
30
|
+
yield initializeDaeryuntalk(hashValue, isOpen, centerCode, apiVersion);
|
|
31
31
|
}
|
|
32
32
|
catch (err) {
|
|
33
33
|
console.error('해시 기반 Daeryuntalk 초기화 실패:', err);
|
|
@@ -10,13 +10,13 @@ interface ChatButtonProps {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const ChatButton: React.FC<ChatButtonProps> = ({ isOpen, onClick, apiVersion, isMobile = false, hashValue = null }) => {
|
|
13
|
-
const { initializeDaeryuntalk } = useDaeryuntalk();
|
|
13
|
+
const { initializeDaeryuntalk, centerCode } = useDaeryuntalk();
|
|
14
14
|
|
|
15
15
|
const handleClick = useCallback(async () => {
|
|
16
16
|
onClick();
|
|
17
17
|
if (!isOpen) {
|
|
18
18
|
try {
|
|
19
|
-
await initializeDaeryuntalk('', isOpen, apiVersion);
|
|
19
|
+
await initializeDaeryuntalk('', isOpen, centerCode, apiVersion);
|
|
20
20
|
} catch (err) {
|
|
21
21
|
console.error('Daeryuntalk 초기화 실패:', err);
|
|
22
22
|
}
|
|
@@ -28,7 +28,7 @@ const ChatButton: React.FC<ChatButtonProps> = ({ isOpen, onClick, apiVersion, is
|
|
|
28
28
|
if (hashValue) {
|
|
29
29
|
const init = async () => {
|
|
30
30
|
try {
|
|
31
|
-
await initializeDaeryuntalk(hashValue, isOpen, apiVersion);
|
|
31
|
+
await initializeDaeryuntalk(hashValue, isOpen, centerCode, apiVersion);
|
|
32
32
|
} catch (err) {
|
|
33
33
|
console.error('해시 기반 Daeryuntalk 초기화 실패:', err);
|
|
34
34
|
}
|
|
@@ -68,38 +68,6 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
|
|
|
68
68
|
}, 200);
|
|
69
69
|
return () => clearTimeout(timeout); // cleanup
|
|
70
70
|
}, [messages, messageObject]);
|
|
71
|
-
const failedData = {
|
|
72
|
-
messageNumber: 'MSG76634299447981111',
|
|
73
|
-
plainText: '안녕',
|
|
74
|
-
senderType: 'MSP00100003',
|
|
75
|
-
messageType: 'MSP00200002',
|
|
76
|
-
messageStatus: 'FAILED',
|
|
77
|
-
userKey: '054423.878_933-2ee9fbb1-ce83-4b1d-acea-5c092022b6ff',
|
|
78
|
-
inquiryNumber: 'C9819004143723624194',
|
|
79
|
-
templateType: 'MSP00300101',
|
|
80
|
-
createdAt: new Date(),
|
|
81
|
-
updatedAt: new Date(),
|
|
82
|
-
language: 'ko',
|
|
83
|
-
timestamp: 1752736508878363,
|
|
84
|
-
richText: {
|
|
85
|
-
version: 1,
|
|
86
|
-
htmlContent: '',
|
|
87
|
-
structuredData: {
|
|
88
|
-
content: [
|
|
89
|
-
{
|
|
90
|
-
content: [
|
|
91
|
-
{
|
|
92
|
-
text: '실패 재전송 검수용',
|
|
93
|
-
type: 'text'
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
type: 'paragraph'
|
|
97
|
-
}
|
|
98
|
-
],
|
|
99
|
-
type: 'doc'
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
71
|
useEffect(() => {
|
|
104
72
|
if (!isInitialMount.current)
|
|
105
73
|
return;
|
|
@@ -153,7 +121,7 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
|
|
|
153
121
|
};
|
|
154
122
|
const renderedMessages = useMemo(() => {
|
|
155
123
|
const elements = [];
|
|
156
|
-
const sortedMessages =
|
|
124
|
+
const sortedMessages = messages && messages.length > 0 ? messages.sort((a, b) => a.timestamp - b.timestamp) : [];
|
|
157
125
|
sortedMessages.forEach((message, index) => {
|
|
158
126
|
const findObject = message.workFlow &&
|
|
159
127
|
(messageObject === null || messageObject === void 0 ? void 0 : messageObject.exposeObjectListYn) &&
|
|
@@ -233,29 +201,6 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
|
|
|
233
201
|
</div>
|
|
234
202
|
</div>
|
|
235
203
|
</div>
|
|
236
|
-
|
|
237
|
-
{/*/!* 모바일 *!/*/}
|
|
238
|
-
{/*<div ref={mobileBottomRef} className={`block w-full xs:hidden`}>*/}
|
|
239
|
-
{/* /!* 높이가 부모에 스크롤이 줄어도 해당 부분은 바텀에 고정 필요 *!/*/}
|
|
240
|
-
{/* {inquiryStatus === InquiryStatus.CLOSED ? (*/}
|
|
241
|
-
{/* <div className="w-full border-t border-drTalkGrayscale4 px-[20px] py-[16px]">*/}
|
|
242
|
-
{/* <div className="">*/}
|
|
243
|
-
{/* <Button3*/}
|
|
244
|
-
{/* onClick={() => {*/}
|
|
245
|
-
{/* onChatNew && onChatNew();*/}
|
|
246
|
-
{/* }}*/}
|
|
247
|
-
{/* className={`w-full`}*/}
|
|
248
|
-
{/* >*/}
|
|
249
|
-
{/* 새 문의하기*/}
|
|
250
|
-
{/* </Button3>*/}
|
|
251
|
-
{/* </div>*/}
|
|
252
|
-
{/* </div>*/}
|
|
253
|
-
{/* ) : (*/}
|
|
254
|
-
{/* <div className=" w-full border-t border-drTalkGrayscale4 px-[20px] py-[8px]">*/}
|
|
255
|
-
{/* <ChatInput />*/}
|
|
256
|
-
{/* </div>*/}
|
|
257
|
-
{/* )}*/}
|
|
258
|
-
{/*</div>*/}
|
|
259
204
|
</>);
|
|
260
205
|
};
|
|
261
206
|
export default ChatConversation;
|
|
@@ -108,38 +108,6 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
|
|
|
108
108
|
return () => clearTimeout(timeout); // cleanup
|
|
109
109
|
}, [messages, messageObject]);
|
|
110
110
|
|
|
111
|
-
const failedData: Message = {
|
|
112
|
-
messageNumber: 'MSG76634299447981111',
|
|
113
|
-
plainText: '안녕',
|
|
114
|
-
senderType: 'MSP00100003',
|
|
115
|
-
messageType: 'MSP00200002',
|
|
116
|
-
messageStatus: 'FAILED',
|
|
117
|
-
userKey: '054423.878_933-2ee9fbb1-ce83-4b1d-acea-5c092022b6ff',
|
|
118
|
-
inquiryNumber: 'C9819004143723624194',
|
|
119
|
-
templateType: 'MSP00300101',
|
|
120
|
-
createdAt: new Date(),
|
|
121
|
-
updatedAt: new Date(),
|
|
122
|
-
language: 'ko',
|
|
123
|
-
timestamp: 1752736508878363,
|
|
124
|
-
richText: {
|
|
125
|
-
version: 1,
|
|
126
|
-
htmlContent: '',
|
|
127
|
-
structuredData: {
|
|
128
|
-
content: [
|
|
129
|
-
{
|
|
130
|
-
content: [
|
|
131
|
-
{
|
|
132
|
-
text: '실패 재전송 검수용',
|
|
133
|
-
type: 'text'
|
|
134
|
-
}
|
|
135
|
-
],
|
|
136
|
-
type: 'paragraph'
|
|
137
|
-
}
|
|
138
|
-
],
|
|
139
|
-
type: 'doc'
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
111
|
useEffect(() => {
|
|
144
112
|
if (!isInitialMount.current) return;
|
|
145
113
|
|
|
@@ -201,7 +169,8 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
|
|
|
201
169
|
const renderedMessages = useMemo(() => {
|
|
202
170
|
const elements: React.ReactNode[] = [];
|
|
203
171
|
|
|
204
|
-
const sortedMessages =
|
|
172
|
+
const sortedMessages =
|
|
173
|
+
messages && messages.length > 0 ? messages.sort((a, b) => a.timestamp - b.timestamp) : [];
|
|
205
174
|
|
|
206
175
|
sortedMessages.forEach((message, index) => {
|
|
207
176
|
const findObject =
|
|
@@ -332,29 +301,6 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
|
|
|
332
301
|
</div>
|
|
333
302
|
</div>
|
|
334
303
|
</div>
|
|
335
|
-
|
|
336
|
-
{/*/!* 모바일 *!/*/}
|
|
337
|
-
{/*<div ref={mobileBottomRef} className={`block w-full xs:hidden`}>*/}
|
|
338
|
-
{/* /!* 높이가 부모에 스크롤이 줄어도 해당 부분은 바텀에 고정 필요 *!/*/}
|
|
339
|
-
{/* {inquiryStatus === InquiryStatus.CLOSED ? (*/}
|
|
340
|
-
{/* <div className="w-full border-t border-drTalkGrayscale4 px-[20px] py-[16px]">*/}
|
|
341
|
-
{/* <div className="">*/}
|
|
342
|
-
{/* <Button3*/}
|
|
343
|
-
{/* onClick={() => {*/}
|
|
344
|
-
{/* onChatNew && onChatNew();*/}
|
|
345
|
-
{/* }}*/}
|
|
346
|
-
{/* className={`w-full`}*/}
|
|
347
|
-
{/* >*/}
|
|
348
|
-
{/* 새 문의하기*/}
|
|
349
|
-
{/* </Button3>*/}
|
|
350
|
-
{/* </div>*/}
|
|
351
|
-
{/* </div>*/}
|
|
352
|
-
{/* ) : (*/}
|
|
353
|
-
{/* <div className=" w-full border-t border-drTalkGrayscale4 px-[20px] py-[8px]">*/}
|
|
354
|
-
{/* <ChatInput />*/}
|
|
355
|
-
{/* </div>*/}
|
|
356
|
-
{/* )}*/}
|
|
357
|
-
{/*</div>*/}
|
|
358
304
|
</>
|
|
359
305
|
);
|
|
360
306
|
};
|
|
@@ -12,7 +12,7 @@ import FixedErrorBox from './FixedErrorBox';
|
|
|
12
12
|
const ChatHomeView = ({ hashValue, onClose, isMobile, isHash }) => {
|
|
13
13
|
const [viewState, setViewState] = useState(isHash ? 'conversation' : 'home');
|
|
14
14
|
const [isLoading, setIsLoading] = useState(false);
|
|
15
|
-
const { isConnected, isAuthenticated, historyList, inquiryMainData, chatInquiryNumber, startChat, retryInitData } = useDaeryuntalk();
|
|
15
|
+
const { isConnected, isAuthenticated, historyList, inquiryMainData, chatInquiryNumber, startChat, retryInitData, setIsTyping } = useDaeryuntalk();
|
|
16
16
|
// 소켓 이벤트
|
|
17
17
|
const { sendInquiryJoined, sendHeartbeat, sendInquiryWatching, sendInquiryLeft, sendHistoryEntered } = useDaeryuntalk();
|
|
18
18
|
// 홈
|
|
@@ -52,6 +52,7 @@ const ChatHomeView = ({ hashValue, onClose, isMobile, isHash }) => {
|
|
|
52
52
|
goGetHistoryList({});
|
|
53
53
|
}
|
|
54
54
|
if (isAuthenticated && viewState === 'conversation') {
|
|
55
|
+
setIsTyping(false);
|
|
55
56
|
goGetHistoryList({});
|
|
56
57
|
}
|
|
57
58
|
}, [viewState, isAuthenticated]);
|
|
@@ -33,8 +33,16 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, onClose, isMobil
|
|
|
33
33
|
const [viewState, setViewState] = useState<ViewState>(isHash ? 'conversation' : 'home');
|
|
34
34
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
35
35
|
|
|
36
|
-
const {
|
|
37
|
-
|
|
36
|
+
const {
|
|
37
|
+
isConnected,
|
|
38
|
+
isAuthenticated,
|
|
39
|
+
historyList,
|
|
40
|
+
inquiryMainData,
|
|
41
|
+
chatInquiryNumber,
|
|
42
|
+
startChat,
|
|
43
|
+
retryInitData,
|
|
44
|
+
setIsTyping
|
|
45
|
+
} = useDaeryuntalk();
|
|
38
46
|
|
|
39
47
|
// 소켓 이벤트
|
|
40
48
|
const { sendInquiryJoined, sendHeartbeat, sendInquiryWatching, sendInquiryLeft, sendHistoryEntered } =
|
|
@@ -104,6 +112,7 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, onClose, isMobil
|
|
|
104
112
|
goGetHistoryList({});
|
|
105
113
|
}
|
|
106
114
|
if (isAuthenticated && viewState === 'conversation') {
|
|
115
|
+
setIsTyping(false);
|
|
107
116
|
goGetHistoryList({});
|
|
108
117
|
}
|
|
109
118
|
}, [viewState, isAuthenticated]);
|
|
@@ -10,7 +10,7 @@ type DaeryuntalkContextType = {
|
|
|
10
10
|
isConnected: boolean | null;
|
|
11
11
|
isLoading: boolean;
|
|
12
12
|
sendMessage: (htmlContent: string, jsonData: any) => void;
|
|
13
|
-
initializeDaeryuntalk: (hashValue: string, isOpen: boolean, version?: string) => void;
|
|
13
|
+
initializeDaeryuntalk: (hashValue: string, isOpen: boolean, centerCode: string, version?: string) => void;
|
|
14
14
|
startChat: (inquiryNumber?: string) => Promise<any>;
|
|
15
15
|
createNewChat: () => void;
|
|
16
16
|
startWorkFlow: (data: {
|
|
@@ -75,13 +75,16 @@ type DaeryuntalkContextType = {
|
|
|
75
75
|
setWorkFlowStack: (arr: string[]) => void;
|
|
76
76
|
retryInitData: () => void;
|
|
77
77
|
isTyping: boolean;
|
|
78
|
+
centerCode: string;
|
|
79
|
+
setIsTyping: (isTyping: boolean) => void;
|
|
78
80
|
};
|
|
79
81
|
declare const DaeryuntalkContext: React.Context<DaeryuntalkContextType>;
|
|
80
82
|
type DaeryuntalkProviderProps = {
|
|
81
83
|
children: ReactNode;
|
|
82
|
-
propsTel: string;
|
|
83
84
|
isMobile: boolean;
|
|
84
85
|
onClose: () => void;
|
|
86
|
+
propsTel: string;
|
|
87
|
+
centerCode: string;
|
|
85
88
|
};
|
|
86
89
|
export declare const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps>;
|
|
87
90
|
export declare const useDaeryuntalk: () => DaeryuntalkContextType;
|
|
@@ -57,11 +57,12 @@ const DaeryuntalkContext = createContext({
|
|
|
57
57
|
setMessageObject: () => { },
|
|
58
58
|
setWorkFlowStack: () => { },
|
|
59
59
|
retryInitData: () => { },
|
|
60
|
-
isTyping: false
|
|
60
|
+
isTyping: false,
|
|
61
|
+
centerCode: '',
|
|
62
|
+
setIsTyping: () => { }
|
|
61
63
|
});
|
|
62
|
-
export const DaeryuntalkProvider = ({ children, propsTel, isMobile, onClose }) => {
|
|
64
|
+
export const DaeryuntalkProvider = ({ children, propsTel, isMobile, onClose, centerCode }) => {
|
|
63
65
|
const [inquiryStatus, setInquiryStatus] = useState('');
|
|
64
|
-
const [tel, setTel] = useState(propsTel);
|
|
65
66
|
// 인증 여부
|
|
66
67
|
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
67
68
|
// 채팅 진행중에 필요한 state들
|
|
@@ -95,7 +96,8 @@ export const DaeryuntalkProvider = ({ children, propsTel, isMobile, onClose }) =
|
|
|
95
96
|
isMobile,
|
|
96
97
|
setIsAuthenticated,
|
|
97
98
|
setIsTyping,
|
|
98
|
-
onClose
|
|
99
|
+
onClose,
|
|
100
|
+
centerCode
|
|
99
101
|
});
|
|
100
102
|
// MSG15591497825895676
|
|
101
103
|
// 채팅 관련
|
|
@@ -109,7 +111,8 @@ export const DaeryuntalkProvider = ({ children, propsTel, isMobile, onClose }) =
|
|
|
109
111
|
chatInquiryNumber,
|
|
110
112
|
setIsNextPage,
|
|
111
113
|
setWorkFlowStack,
|
|
112
|
-
setInquiryMainData
|
|
114
|
+
setInquiryMainData,
|
|
115
|
+
centerCode
|
|
113
116
|
});
|
|
114
117
|
// 이미지 뷰어용
|
|
115
118
|
const { isImageViewerOpen, selectedImageFile, imageViewerMessage, openImageViewer, closeImageViewer } = useViewerHook();
|
|
@@ -144,7 +147,7 @@ export const DaeryuntalkProvider = ({ children, propsTel, isMobile, onClose }) =
|
|
|
144
147
|
imageViewerMessage,
|
|
145
148
|
openImageViewer,
|
|
146
149
|
closeImageViewer,
|
|
147
|
-
tel:
|
|
150
|
+
tel: propsTel,
|
|
148
151
|
goRequestPhone,
|
|
149
152
|
goHistoryPhoneAuth,
|
|
150
153
|
goGetHistoryList,
|
|
@@ -159,7 +162,9 @@ export const DaeryuntalkProvider = ({ children, propsTel, isMobile, onClose }) =
|
|
|
159
162
|
setMessageObject,
|
|
160
163
|
setWorkFlowStack,
|
|
161
164
|
retryInitData,
|
|
162
|
-
isTyping
|
|
165
|
+
isTyping,
|
|
166
|
+
centerCode,
|
|
167
|
+
setIsTyping
|
|
163
168
|
}}>
|
|
164
169
|
{children}
|
|
165
170
|
</DaeryuntalkContext.Provider>);
|
|
@@ -16,7 +16,7 @@ type DaeryuntalkContextType = {
|
|
|
16
16
|
isConnected: boolean | null;
|
|
17
17
|
isLoading: boolean;
|
|
18
18
|
sendMessage: (htmlContent: string, jsonData: any) => void;
|
|
19
|
-
initializeDaeryuntalk: (hashValue: string, isOpen: boolean, version?: string) => void;
|
|
19
|
+
initializeDaeryuntalk: (hashValue: string, isOpen: boolean, centerCode: string, version?: string) => void;
|
|
20
20
|
startChat: (inquiryNumber?: string) => Promise<any>;
|
|
21
21
|
createNewChat: () => void;
|
|
22
22
|
startWorkFlow: (data: {
|
|
@@ -80,6 +80,8 @@ type DaeryuntalkContextType = {
|
|
|
80
80
|
setWorkFlowStack: (arr: string[]) => void;
|
|
81
81
|
retryInitData: () => void;
|
|
82
82
|
isTyping: boolean;
|
|
83
|
+
centerCode: string;
|
|
84
|
+
setIsTyping: (isTyping: boolean) => void;
|
|
83
85
|
};
|
|
84
86
|
|
|
85
87
|
// 기본값으로 컨텍스트 생성
|
|
@@ -127,20 +129,29 @@ const DaeryuntalkContext = createContext<DaeryuntalkContextType>({
|
|
|
127
129
|
setMessageObject: () => {},
|
|
128
130
|
setWorkFlowStack: () => {},
|
|
129
131
|
retryInitData: () => {},
|
|
130
|
-
isTyping: false
|
|
132
|
+
isTyping: false,
|
|
133
|
+
centerCode: '',
|
|
134
|
+
setIsTyping: () => {}
|
|
131
135
|
});
|
|
132
136
|
|
|
133
137
|
// 프로바이더 컴포넌트 생성
|
|
134
138
|
type DaeryuntalkProviderProps = {
|
|
135
139
|
children: ReactNode;
|
|
136
|
-
propsTel: string;
|
|
137
140
|
isMobile: boolean;
|
|
138
141
|
onClose: () => void;
|
|
142
|
+
propsTel: string;
|
|
143
|
+
centerCode: string;
|
|
139
144
|
};
|
|
140
145
|
|
|
141
|
-
export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({
|
|
146
|
+
export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({
|
|
147
|
+
children,
|
|
148
|
+
propsTel,
|
|
149
|
+
isMobile,
|
|
150
|
+
onClose,
|
|
151
|
+
centerCode
|
|
152
|
+
}) => {
|
|
142
153
|
const [inquiryStatus, setInquiryStatus] = useState<string>('');
|
|
143
|
-
|
|
154
|
+
|
|
144
155
|
// 인증 여부
|
|
145
156
|
const [isAuthenticated, setIsAuthenticated] = useState<boolean>(false);
|
|
146
157
|
|
|
@@ -190,7 +201,8 @@ export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ childr
|
|
|
190
201
|
isMobile,
|
|
191
202
|
setIsAuthenticated,
|
|
192
203
|
setIsTyping,
|
|
193
|
-
onClose
|
|
204
|
+
onClose,
|
|
205
|
+
centerCode
|
|
194
206
|
});
|
|
195
207
|
|
|
196
208
|
// MSG15591497825895676
|
|
@@ -216,7 +228,8 @@ export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ childr
|
|
|
216
228
|
chatInquiryNumber,
|
|
217
229
|
setIsNextPage,
|
|
218
230
|
setWorkFlowStack,
|
|
219
|
-
setInquiryMainData
|
|
231
|
+
setInquiryMainData,
|
|
232
|
+
centerCode
|
|
220
233
|
});
|
|
221
234
|
|
|
222
235
|
// 이미지 뷰어용
|
|
@@ -257,7 +270,7 @@ export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ childr
|
|
|
257
270
|
imageViewerMessage,
|
|
258
271
|
openImageViewer,
|
|
259
272
|
closeImageViewer,
|
|
260
|
-
tel:
|
|
273
|
+
tel: propsTel,
|
|
261
274
|
goRequestPhone,
|
|
262
275
|
goHistoryPhoneAuth,
|
|
263
276
|
goGetHistoryList,
|
|
@@ -272,7 +285,9 @@ export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ childr
|
|
|
272
285
|
setMessageObject,
|
|
273
286
|
setWorkFlowStack,
|
|
274
287
|
retryInitData,
|
|
275
|
-
isTyping
|
|
288
|
+
isTyping,
|
|
289
|
+
centerCode,
|
|
290
|
+
setIsTyping
|
|
276
291
|
}}
|
|
277
292
|
>
|
|
278
293
|
{children}
|
|
@@ -41,10 +41,12 @@ const DaeryunTalkToast = ({ type, title, description, duration = 3000, onClose }
|
|
|
41
41
|
onClose();
|
|
42
42
|
};
|
|
43
43
|
return (<>
|
|
44
|
-
<div className=" flex h-[48px] w-full items-center justify-center space-x-[6px] rounded-[25px] bg-[#505050] text-white">
|
|
44
|
+
<div className=" flex min-h-[48px] w-full items-center justify-center space-x-[6px] rounded-[25px] bg-[#505050] text-white">
|
|
45
45
|
<div className="mt-0.5 flex-shrink-0">{ICONS[type]}</div>
|
|
46
46
|
<div className="flex">
|
|
47
|
-
<h3 className="text-[14px] font-[400] leading-[130%] tracking-[-4%]">
|
|
47
|
+
<h3 className="whitespace-pre-line text-[14px] font-[400] leading-[130%] tracking-[-4%]">
|
|
48
|
+
{title}
|
|
49
|
+
</h3>
|
|
48
50
|
{/*{description && <p className="mt-0.5 text-sm text-white text-opacity-90">{description}</p>}*/}
|
|
49
51
|
</div>
|
|
50
52
|
</div>
|
|
@@ -72,10 +72,12 @@ const DaeryunTalkToast = ({ type, title, description, duration = 3000, onClose }
|
|
|
72
72
|
|
|
73
73
|
return (
|
|
74
74
|
<>
|
|
75
|
-
<div className=" flex h-[48px] w-full items-center justify-center space-x-[6px] rounded-[25px] bg-[#505050] text-white">
|
|
75
|
+
<div className=" flex min-h-[48px] w-full items-center justify-center space-x-[6px] rounded-[25px] bg-[#505050] text-white">
|
|
76
76
|
<div className="mt-0.5 flex-shrink-0">{ICONS[type]}</div>
|
|
77
77
|
<div className="flex">
|
|
78
|
-
<h3 className="text-[14px] font-[400] leading-[130%] tracking-[-4%]">
|
|
78
|
+
<h3 className="whitespace-pre-line text-[14px] font-[400] leading-[130%] tracking-[-4%]">
|
|
79
|
+
{title}
|
|
80
|
+
</h3>
|
|
79
81
|
{/*{description && <p className="mt-0.5 text-sm text-white text-opacity-90">{description}</p>}*/}
|
|
80
82
|
</div>
|
|
81
83
|
</div>
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
import { IDaeryunTalkResponseWrapper, WebSocketInitDataResponse, IChatInquiryMainDataResponse, ChatInquiryCreateDataResponse, ChatInquiryDetailDataResponse, SendMessageResponse, ChatInquiryMessageListDataResponse, HistoryListResponse, RequestConfirmNumberResponse } from './type/response';
|
|
11
11
|
import { Dispatch, SetStateAction } from 'react';
|
|
12
12
|
export declare const DEFAULT_API_VERSION = "1.0.0";
|
|
13
|
-
export declare const TEST_CENTER_CODE: string;
|
|
14
13
|
export declare const MESSAGE_TYPES: {
|
|
15
14
|
SYSTEM: string;
|
|
16
15
|
BOT: string;
|
|
@@ -44,7 +43,7 @@ export declare function getChatInquiryMain(channelNumber: string, version?: stri
|
|
|
44
43
|
* @param currentUrl
|
|
45
44
|
* @param version
|
|
46
45
|
*/
|
|
47
|
-
export declare function generateChatInquiry(channelNumber: string, currentUrl: string, version?: string): Promise<IDaeryunTalkResponseWrapper<ChatInquiryCreateDataResponse>>;
|
|
46
|
+
export declare function generateChatInquiry(channelNumber: string, currentUrl: string, centerCode?: string, version?: string): Promise<IDaeryunTalkResponseWrapper<ChatInquiryCreateDataResponse>>;
|
|
48
47
|
/**
|
|
49
48
|
* 채팅 문의 상세 조회 (개선된 API)
|
|
50
49
|
* @param chatInquiryNumber 채팅 문의 번호
|
|
@@ -69,7 +68,7 @@ export declare function getChatInquiryMessageList(chatInquiryNumber: string, sta
|
|
|
69
68
|
* @param version API 버전 (기본값: 1.0.0)
|
|
70
69
|
* @returns 웹소켓 인스턴스 및 문의 데이터
|
|
71
70
|
*/
|
|
72
|
-
export declare function initializeDaeryuntalk(hashValue: string, isOpen: boolean, setIsConnected: Dispatch<SetStateAction<boolean | null>>, isMobile: boolean, onWebSocketConnected?: (socket: WebSocket) => void, onWebSocketMessage?: (event: MessageEvent) => void, version?: string): Promise<{
|
|
71
|
+
export declare function initializeDaeryuntalk(hashValue: string, isOpen: boolean, setIsConnected: Dispatch<SetStateAction<boolean | null>>, isMobile: boolean, centerCode: string, onWebSocketConnected?: (socket: WebSocket) => void, onWebSocketMessage?: (event: MessageEvent) => void, version?: string): Promise<{
|
|
73
72
|
inquiryData: IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse> | null;
|
|
74
73
|
socket: WebSocket | null;
|
|
75
74
|
hashAuth: any;
|
|
@@ -39,7 +39,6 @@ const ENDPOINTS = {
|
|
|
39
39
|
FOLLOWUP_ATTENTD: '/chatctm/chi/chatinquiryalarmparticipation' // 채팅 문의 알림 참여
|
|
40
40
|
};
|
|
41
41
|
// 메인
|
|
42
|
-
export const TEST_CENTER_CODE = 'CT0000';
|
|
43
42
|
// 채팅 메시지 유형 상수
|
|
44
43
|
export const MESSAGE_TYPES = {
|
|
45
44
|
SYSTEM: 'MSP00100001',
|
|
@@ -312,12 +311,13 @@ export function getChatInquiryMain(channelNumber, version) {
|
|
|
312
311
|
* @param currentUrl
|
|
313
312
|
* @param version
|
|
314
313
|
*/
|
|
315
|
-
export function generateChatInquiry(channelNumber, currentUrl, version) {
|
|
314
|
+
export function generateChatInquiry(channelNumber, currentUrl, centerCode, version) {
|
|
316
315
|
return __awaiter(this, void 0, void 0, function* () {
|
|
316
|
+
var _a;
|
|
317
317
|
console.log('[새 채팅 문의 생성 시작 (개선)]', version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
|
|
318
318
|
let channelId = channelNumber;
|
|
319
319
|
if (!channelNumber) {
|
|
320
|
-
const authRes = yield authenticateUser(
|
|
320
|
+
const authRes = yield authenticateUser((_a = (centerCode || 'CT0000')) !== null && _a !== void 0 ? _a : 'CT0000', version);
|
|
321
321
|
channelId = authRes.data.channel_number;
|
|
322
322
|
}
|
|
323
323
|
const body = {
|
|
@@ -406,7 +406,7 @@ export function getChatInquiryMessageList(chatInquiryNumber, standardDateTime, s
|
|
|
406
406
|
* @param version API 버전 (기본값: 1.0.0)
|
|
407
407
|
* @returns 웹소켓 인스턴스 및 문의 데이터
|
|
408
408
|
*/
|
|
409
|
-
export function initializeDaeryuntalk(hashValue, isOpen, setIsConnected, isMobile, onWebSocketConnected, onWebSocketMessage, version) {
|
|
409
|
+
export function initializeDaeryuntalk(hashValue, isOpen, setIsConnected, isMobile, centerCode, onWebSocketConnected, onWebSocketMessage, version) {
|
|
410
410
|
return __awaiter(this, void 0, void 0, function* () {
|
|
411
411
|
var _a, _b, _c, _d, _e, _f;
|
|
412
412
|
if (typeof window !== 'undefined' && hashValue) {
|
|
@@ -417,7 +417,7 @@ export function initializeDaeryuntalk(hashValue, isOpen, setIsConnected, isMobil
|
|
|
417
417
|
console.log('[Daeryuntalk 초기화] 전체 흐름 시작');
|
|
418
418
|
let errorData = null;
|
|
419
419
|
// 1단계: 사용자 인증
|
|
420
|
-
let authResponse = yield retryable(() => authenticateUser(
|
|
420
|
+
let authResponse = yield retryable(() => authenticateUser(centerCode, version), 1, 350, '사용자 인증');
|
|
421
421
|
console.log('authResponse11', authResponse);
|
|
422
422
|
// 9379809eec4c09ea276496b15b5d2778a2ef7af312c25d95bd2a0f884cb72bf3
|
|
423
423
|
// 만약 만료된 토큰이라면?
|
|
@@ -433,7 +433,7 @@ export function initializeDaeryuntalk(hashValue, isOpen, setIsConnected, isMobil
|
|
|
433
433
|
errorData = authResponse;
|
|
434
434
|
console.log('재인증 시작');
|
|
435
435
|
localStorage.removeItem('daeryunchatinquirytoken');
|
|
436
|
-
authResponse = yield retryable(() => authenticateUser(
|
|
436
|
+
authResponse = yield retryable(() => authenticateUser(centerCode, version, true), 3, 350, '사용자 인증');
|
|
437
437
|
}
|
|
438
438
|
else {
|
|
439
439
|
errorData = authResponse;
|
|
@@ -57,7 +57,6 @@ const ENDPOINTS = {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
// 메인
|
|
60
|
-
export const TEST_CENTER_CODE: string = 'CT0000';
|
|
61
60
|
|
|
62
61
|
// 채팅 메시지 유형 상수
|
|
63
62
|
export const MESSAGE_TYPES = {
|
|
@@ -386,12 +385,13 @@ export async function getChatInquiryMain(
|
|
|
386
385
|
export async function generateChatInquiry(
|
|
387
386
|
channelNumber: string,
|
|
388
387
|
currentUrl: string,
|
|
388
|
+
centerCode?: string,
|
|
389
389
|
version?: string
|
|
390
390
|
): Promise<IDaeryunTalkResponseWrapper<ChatInquiryCreateDataResponse>> {
|
|
391
391
|
console.log('[새 채팅 문의 생성 시작 (개선)]', version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
|
|
392
392
|
let channelId = channelNumber;
|
|
393
393
|
if (!channelNumber) {
|
|
394
|
-
const authRes = await authenticateUser(
|
|
394
|
+
const authRes = await authenticateUser((centerCode || 'CT0000') ?? 'CT0000', version);
|
|
395
395
|
channelId = authRes.data.channel_number;
|
|
396
396
|
}
|
|
397
397
|
|
|
@@ -515,6 +515,7 @@ export async function initializeDaeryuntalk(
|
|
|
515
515
|
isOpen: boolean,
|
|
516
516
|
setIsConnected: Dispatch<SetStateAction<boolean | null>>,
|
|
517
517
|
isMobile: boolean,
|
|
518
|
+
centerCode: string,
|
|
518
519
|
onWebSocketConnected?: (socket: WebSocket) => void,
|
|
519
520
|
onWebSocketMessage?: (event: MessageEvent) => void,
|
|
520
521
|
version?: string
|
|
@@ -536,7 +537,7 @@ export async function initializeDaeryuntalk(
|
|
|
536
537
|
let errorData: IDaeryunTalkResponseWrapper<any> | null = null;
|
|
537
538
|
|
|
538
539
|
// 1단계: 사용자 인증
|
|
539
|
-
let authResponse = await retryable(() => authenticateUser(
|
|
540
|
+
let authResponse = await retryable(() => authenticateUser(centerCode, version), 1, 350, '사용자 인증');
|
|
540
541
|
|
|
541
542
|
console.log('authResponse11', authResponse);
|
|
542
543
|
// 9379809eec4c09ea276496b15b5d2778a2ef7af312c25d95bd2a0f884cb72bf3
|
|
@@ -555,7 +556,7 @@ export async function initializeDaeryuntalk(
|
|
|
555
556
|
console.log('재인증 시작');
|
|
556
557
|
localStorage.removeItem('daeryunchatinquirytoken');
|
|
557
558
|
authResponse = await retryable(
|
|
558
|
-
() => authenticateUser(
|
|
559
|
+
() => authenticateUser(centerCode, version, true),
|
|
559
560
|
3,
|
|
560
561
|
350,
|
|
561
562
|
'사용자 인증'
|
|
@@ -22,3 +22,11 @@ export declare enum MessageSocketType {
|
|
|
22
22
|
/** 타이핑중임 */
|
|
23
23
|
TYPING_STARTED = "typing.started"
|
|
24
24
|
}
|
|
25
|
+
export declare enum MessageSendSocketType {
|
|
26
|
+
HEARTBEAT = "heartbeat",
|
|
27
|
+
INQUIRY_WATCHING = "inquiry.watching",
|
|
28
|
+
INQUIRY_JOINED = "inquiry.joined",
|
|
29
|
+
INQUIRY_LEFT = "inquiry.left",
|
|
30
|
+
HISTORY_ENTERED = "history.entered",
|
|
31
|
+
HISTORY_EXITED = "history.exited"
|
|
32
|
+
}
|
|
@@ -33,3 +33,12 @@ export var MessageSocketType;
|
|
|
33
33
|
/** 타이핑중임 */
|
|
34
34
|
MessageSocketType["TYPING_STARTED"] = "typing.started";
|
|
35
35
|
})(MessageSocketType || (MessageSocketType = {}));
|
|
36
|
+
export var MessageSendSocketType;
|
|
37
|
+
(function (MessageSendSocketType) {
|
|
38
|
+
MessageSendSocketType["HEARTBEAT"] = "heartbeat";
|
|
39
|
+
MessageSendSocketType["INQUIRY_WATCHING"] = "inquiry.watching";
|
|
40
|
+
MessageSendSocketType["INQUIRY_JOINED"] = "inquiry.joined";
|
|
41
|
+
MessageSendSocketType["INQUIRY_LEFT"] = "inquiry.left";
|
|
42
|
+
MessageSendSocketType["HISTORY_ENTERED"] = "history.entered";
|
|
43
|
+
MessageSendSocketType["HISTORY_EXITED"] = "history.exited";
|
|
44
|
+
})(MessageSendSocketType || (MessageSendSocketType = {}));
|
|
@@ -42,3 +42,12 @@ export enum MessageSocketType {
|
|
|
42
42
|
/** 타이핑중임 */
|
|
43
43
|
TYPING_STARTED = 'typing.started'
|
|
44
44
|
}
|
|
45
|
+
|
|
46
|
+
export enum MessageSendSocketType {
|
|
47
|
+
HEARTBEAT = 'heartbeat',
|
|
48
|
+
INQUIRY_WATCHING = 'inquiry.watching',
|
|
49
|
+
INQUIRY_JOINED = 'inquiry.joined',
|
|
50
|
+
INQUIRY_LEFT = 'inquiry.left',
|
|
51
|
+
HISTORY_ENTERED = 'history.entered',
|
|
52
|
+
HISTORY_EXITED = 'history.exited'
|
|
53
|
+
}
|
|
@@ -13,8 +13,9 @@ interface props {
|
|
|
13
13
|
setIsNextPage: Dispatch<SetStateAction<boolean | null>>;
|
|
14
14
|
setWorkFlowStack: Dispatch<SetStateAction<string[]>>;
|
|
15
15
|
setInquiryMainData: Dispatch<SetStateAction<IChatInquiryMainDataResponse | null>>;
|
|
16
|
+
centerCode: string;
|
|
16
17
|
}
|
|
17
|
-
export declare const useChatHandler: ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, setInquiryMainData }: props) => {
|
|
18
|
+
export declare const useChatHandler: ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, setInquiryMainData, centerCode }: props) => {
|
|
18
19
|
attendRoomByHistory: (chatInquiryNumber: string) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<import("../../_api/daeryuntalk/type/response").HistoryListResponse> | undefined>;
|
|
19
20
|
startChat: (inquiryNumber?: string) => Promise<string | import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<import("../../_api/daeryuntalk/type/response").ChatInquiryCreateDataResponse> | import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<import("../../_api/daeryuntalk/type/response").ChatInquiryDetailDataResponse> | import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<import("../../_api/daeryuntalk/type/response").ChatInquiryMessageListDataResponse> | {
|
|
20
21
|
error: unknown;
|