@daeryun/dr_components 0.8.19 → 0.8.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/components/Daeryuntalk/ChatConversation.d.ts +1 -0
- package/dist/components/Daeryuntalk/ChatConversation.jsx +3 -3
- package/dist/components/Daeryuntalk/ChatConversation.tsx +4 -3
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +28 -28
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +30 -28
- package/dist/components/Daeryuntalk/ChatWidget.jsx +4 -4
- package/dist/components/Daeryuntalk/ChatWidget.tsx +4 -4
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +3 -1
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +3 -1
- package/dist/components/Daeryuntalk/HistoryView.d.ts +1 -0
- package/dist/components/Daeryuntalk/HistoryView.jsx +1 -1
- package/dist/components/Daeryuntalk/HistoryView.tsx +3 -1
- package/dist/components/Daeryuntalk/NoticeMessage.jsx +1 -1
- package/dist/components/Daeryuntalk/NoticeMessage.tsx +1 -1
- package/dist/components/Daeryuntalk/ViewportHandler.jsx +11 -17
- package/dist/components/Daeryuntalk/ViewportHandler.tsx +13 -17
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +4 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +12 -17
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +131 -117
- package/dist/components/Daeryuntalk/index.jsx +10 -8
- package/dist/components/Daeryuntalk/index.tsx +16 -14
- package/dist/components/page/Login/_fetch/fetch.js +0 -1
- package/dist/components/page/Login/_fetch/fetch.ts +0 -1
- package/dist/styles/globals.css +9 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { Dispatch, MutableRefObject, SetStateAction, useCallback, useRef } from
|
|
|
2
2
|
|
|
3
3
|
import { followupAttend, initializeDaeryuntalk as apiInitializeDaeryuntalk } from '../../_api/daeryuntalk';
|
|
4
4
|
import { Message } from '../../_types/message';
|
|
5
|
-
import { IChatInquiryMainDataResponse } from '../../_api/daeryuntalk/type/response';
|
|
5
|
+
import { History, IChatInquiryMainDataResponse } from '../../_api/daeryuntalk/type/response';
|
|
6
6
|
import { convertApiMessageToUiMessage, convertSocketObjectToUiMessage } from '../../_lib';
|
|
7
7
|
import { MessageObject } from '../../_types/message_object';
|
|
8
8
|
import { IInquiryWorkFlowUpdate } from '../../_types/socket/workflow';
|
|
@@ -19,6 +19,8 @@ interface props {
|
|
|
19
19
|
setInquiryMainData: Dispatch<SetStateAction<IChatInquiryMainDataResponse | null>>;
|
|
20
20
|
socketRef: MutableRefObject<WebSocket | null>;
|
|
21
21
|
setInquiryStatus: Dispatch<SetStateAction<string>>;
|
|
22
|
+
setHistoryList: Dispatch<SetStateAction<History[]>>;
|
|
23
|
+
historyList: History[];
|
|
22
24
|
}
|
|
23
25
|
export const useSocketEventHandler = ({
|
|
24
26
|
setIsConnected,
|
|
@@ -28,7 +30,9 @@ export const useSocketEventHandler = ({
|
|
|
28
30
|
socketRef,
|
|
29
31
|
setWorkFlowStack,
|
|
30
32
|
setMessageObject,
|
|
31
|
-
setInquiryStatus
|
|
33
|
+
setInquiryStatus,
|
|
34
|
+
setHistoryList,
|
|
35
|
+
historyList
|
|
32
36
|
}: props) => {
|
|
33
37
|
const toast = useDaeryunTalkToast();
|
|
34
38
|
/**
|
|
@@ -149,132 +153,142 @@ export const useSocketEventHandler = ({
|
|
|
149
153
|
}, []);
|
|
150
154
|
|
|
151
155
|
// Daeryuntalk API 초기화 메소드
|
|
152
|
-
const initializeDaeryuntalk = useCallback(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// if (hashValue) {
|
|
159
|
-
// const hashAuth = await followupAttend({ token: hashValue });
|
|
160
|
-
// console.log('hashAuth', hashAuth);
|
|
161
|
-
// if (hashAuth?.result_info?.result_type_cd === 'OK' || hashAuth?.result_info?.result_cd === 'OK') {
|
|
162
|
-
// // 인증 완
|
|
163
|
-
// } else {
|
|
164
|
-
// toast.error('인증에 실패했습니다.');
|
|
165
|
-
// // window.location.href = '/';
|
|
166
|
-
// return;
|
|
167
|
-
// }
|
|
168
|
-
// }
|
|
156
|
+
const initializeDaeryuntalk = useCallback(
|
|
157
|
+
async (hashValue: string | null, version?: string) => {
|
|
158
|
+
console.log('[DaeryuntalkContext] 초기화 메소드 호출됨', version ? `버전: ${version}` : '기본 버전 사용');
|
|
159
|
+
try {
|
|
160
|
+
setIsLoading(true);
|
|
161
|
+
console.log('[DaeryuntalkContext] 로딩 상태 설정: true');
|
|
169
162
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
163
|
+
const { inquiryData, socket, hashAuth } = await apiInitializeDaeryuntalk(
|
|
164
|
+
hashValue || '',
|
|
165
|
+
socket => {
|
|
166
|
+
console.log('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 성공');
|
|
167
|
+
setIsConnected(true);
|
|
168
|
+
},
|
|
169
|
+
event => {
|
|
170
|
+
console.log('[DaeryuntalkContext] 웹소켓 메시지 수신됨');
|
|
171
|
+
try {
|
|
172
|
+
const data = typeof event === 'string' ? JSON.parse(event) : event;
|
|
173
|
+
console.log('socket data', data);
|
|
174
|
+
// 메시지 생성
|
|
175
|
+
if (data.type === MessageSocketType.MESSAGE_CREATED && data.payload?.message) {
|
|
176
|
+
const newMessage = convertApiMessageToUiMessage(data.payload.message);
|
|
177
|
+
console.log('메세지 넣기 시작');
|
|
178
|
+
setMessages(prev => {
|
|
179
|
+
const isDuplicate = prev.some(
|
|
180
|
+
msg => msg.messageNumber === newMessage.messageNumber
|
|
181
|
+
);
|
|
182
|
+
return isDuplicate ? prev : [...prev, newMessage];
|
|
183
|
+
});
|
|
184
|
+
}
|
|
190
185
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
186
|
+
if (data.type === MessageSocketType.MESSAGE_UPDATED) {
|
|
187
|
+
const newMessage = convertApiMessageToUiMessage(data.payload.message);
|
|
188
|
+
setMessages(prev => {
|
|
189
|
+
const index = prev.findIndex(msg => msg.messageNumber === newMessage.messageNumber);
|
|
195
190
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
191
|
+
if (index !== -1) {
|
|
192
|
+
// 기존 메시지가 있으면 해당 위치에 새 메시지로 교체
|
|
193
|
+
const updated = [...prev];
|
|
194
|
+
updated[index] = newMessage;
|
|
195
|
+
return updated;
|
|
196
|
+
}
|
|
202
197
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
198
|
+
// 없으면 새 메시지를 추가
|
|
199
|
+
return [...prev, newMessage];
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
// 메세지 회수됨 -> 이거는 관리자에서는 필요없는듯?
|
|
203
|
+
if (data.type === MessageSocketType.MESSAGE_COLLECTED) {
|
|
204
|
+
// 여기서는
|
|
205
|
+
const payload: {
|
|
206
|
+
chat_inquiry_number: string;
|
|
207
|
+
message_number: string;
|
|
208
|
+
} = data.payload;
|
|
209
|
+
setMessages(prev => prev.filter(fil => fil.messageNumber !== payload.message_number));
|
|
210
|
+
}
|
|
211
|
+
// 안읽음 count
|
|
212
|
+
if (data.type === MessageSocketType.INQUIRY_PREVIEW_UPDATED) {
|
|
213
|
+
const socketData: {
|
|
214
|
+
chat_inquiry_number: string;
|
|
215
|
+
recent_message_content: string;
|
|
216
|
+
recent_message_date_time: string;
|
|
217
|
+
unread_message_count: string;
|
|
218
|
+
} = data?.payload;
|
|
223
219
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
220
|
+
setHistoryList((prev): History[] =>
|
|
221
|
+
prev.map(item =>
|
|
222
|
+
item.chat_inquiry_number === socketData.chat_inquiry_number
|
|
223
|
+
? ({
|
|
224
|
+
chat_inquiry_number: socketData.chat_inquiry_number,
|
|
225
|
+
customer_name: item.customer_name,
|
|
226
|
+
recent_message_content: socketData.recent_message_content,
|
|
227
|
+
recent_message_date_time: socketData.recent_message_date_time,
|
|
228
|
+
unread_message_count: Number(socketData.unread_message_count)
|
|
229
|
+
} as History)
|
|
230
|
+
: item
|
|
231
|
+
)
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
// 새로운 문의가 생성됨
|
|
235
|
+
if (data.type === MessageSocketType.INQUIRY_OPENED) {
|
|
236
|
+
}
|
|
233
237
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
238
|
+
// 문의 워크플로우 변경됨
|
|
239
|
+
if (data.type === MessageSocketType.INQUIRY_WORKFLOW_UPDATED) {
|
|
240
|
+
const socketPayloadData = data?.payload as IInquiryWorkFlowUpdate;
|
|
241
|
+
// 워크플로우 스택 업데이트
|
|
242
|
+
setWorkFlowStack(socketPayloadData.work_flow_progress_stack);
|
|
243
|
+
// 오브젝트 업데이트
|
|
244
|
+
setMessageObject(convertSocketObjectToUiMessage(data?.payload));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// 문의가 종료됨
|
|
248
|
+
if (data.type === MessageSocketType.INQUIRY_CLOSED) {
|
|
249
|
+
setInquiryStatus(InquiryStatus.CLOSED);
|
|
250
|
+
}
|
|
251
|
+
// 업무 관리자 배정
|
|
252
|
+
if (data.type === MessageSocketType.INQUIRY_ASSIGNED) {
|
|
253
|
+
const payload: {
|
|
254
|
+
chat_inquiry_number: string;
|
|
255
|
+
operator_number: string;
|
|
256
|
+
} = data.payload;
|
|
257
|
+
}
|
|
258
|
+
// 할당된 상담원이 해제됨
|
|
259
|
+
if (data.type === MessageSocketType.INQUIRY_UNASSIGNED) {
|
|
260
|
+
}
|
|
261
|
+
// 고객 정보가 갱신됨
|
|
262
|
+
if (data.type === MessageSocketType.CUSTOMER_INFO_UPDATED) {
|
|
263
|
+
}
|
|
264
|
+
} catch (error) {
|
|
265
|
+
console.error('[DaeryuntalkContext] 웹소켓 메시지 처리 오류:', error);
|
|
251
266
|
}
|
|
252
|
-
}
|
|
253
|
-
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
if (hashValue) {
|
|
270
|
+
if (hashAuth?.result_info?.result_cd === 'OK' || hashAuth?.result_info?.result_type_cd === 'OK') {
|
|
271
|
+
} else {
|
|
272
|
+
toast.error('인증에 실패했습니다.');
|
|
273
|
+
window.location.hash = '/';
|
|
254
274
|
}
|
|
255
275
|
}
|
|
256
|
-
);
|
|
257
|
-
if (hashValue) {
|
|
258
|
-
if (hashAuth?.result_info?.result_cd === 'OK' || hashAuth?.result_info?.result_type_cd === 'OK') {
|
|
259
|
-
} else {
|
|
260
|
-
toast.error('인증에 실패했습니다.');
|
|
261
|
-
window.location.hash = '/';
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
276
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
277
|
+
if (inquiryData) {
|
|
278
|
+
setInquiryMainData(inquiryData.data as IChatInquiryMainDataResponse);
|
|
279
|
+
}
|
|
280
|
+
if (socket) {
|
|
281
|
+
socketRef.current = socket;
|
|
282
|
+
}
|
|
283
|
+
} catch (error) {
|
|
284
|
+
console.error('[DaeryuntalkContext] 초기화 오류:', error);
|
|
285
|
+
} finally {
|
|
286
|
+
console.log('[DaeryuntalkContext] 로딩 상태 설정: false');
|
|
287
|
+
setIsLoading(false);
|
|
270
288
|
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
console.log('[DaeryuntalkContext] 로딩 상태 설정: false');
|
|
275
|
-
setIsLoading(false);
|
|
276
|
-
}
|
|
277
|
-
}, []);
|
|
289
|
+
},
|
|
290
|
+
[historyList]
|
|
291
|
+
);
|
|
278
292
|
|
|
279
293
|
return {
|
|
280
294
|
initializeDaeryuntalk,
|
|
@@ -28,17 +28,19 @@ const Daeryuntalk = ({ tel = '1800-7905' }) => {
|
|
|
28
28
|
if (value) {
|
|
29
29
|
setHashValue(value);
|
|
30
30
|
// 해시 제거 (주소창에서 #... 부분 삭제)
|
|
31
|
-
window.history.replaceState(null, '', window.location.pathname + window.location.search);
|
|
31
|
+
// window.history.replaceState(null, '', window.location.pathname + window.location.search);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}, []);
|
|
36
|
-
return (<
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
return (<div className={`border-4`}>
|
|
37
|
+
<DaeryuntalkToastProvider>
|
|
38
|
+
<ViewportHandler />
|
|
39
|
+
<DaeryuntalkProvider propsTel={tel}>
|
|
40
|
+
<ChatButton isOpen={isOpen} isMobile={isMobile} hashValue={hashValue} onClick={toggleChat}/>
|
|
41
|
+
<ChatWidget isOpen={hashValue ? true : isOpen} isMobile={isMobile} onClose={closeChatWidget} hashValue={hashValue} setHashValue={setHashValue}/>
|
|
42
|
+
</DaeryuntalkProvider>
|
|
43
|
+
</DaeryuntalkToastProvider>
|
|
44
|
+
</div>);
|
|
43
45
|
};
|
|
44
46
|
export default Daeryuntalk;
|
|
@@ -41,26 +41,28 @@ const Daeryuntalk: React.FC<DaeryuntalkProps> = ({ tel = '1800-7905' }) => {
|
|
|
41
41
|
setHashValue(value);
|
|
42
42
|
|
|
43
43
|
// 해시 제거 (주소창에서 #... 부분 삭제)
|
|
44
|
-
window.history.replaceState(null, '', window.location.pathname + window.location.search);
|
|
44
|
+
// window.history.replaceState(null, '', window.location.pathname + window.location.search);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}, []);
|
|
49
49
|
|
|
50
50
|
return (
|
|
51
|
-
<
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
<div className={`border-4`}>
|
|
52
|
+
<DaeryuntalkToastProvider>
|
|
53
|
+
<ViewportHandler />
|
|
54
|
+
<DaeryuntalkProvider propsTel={tel}>
|
|
55
|
+
<ChatButton isOpen={isOpen} isMobile={isMobile} hashValue={hashValue} onClick={toggleChat} />
|
|
56
|
+
<ChatWidget
|
|
57
|
+
isOpen={hashValue ? true : isOpen}
|
|
58
|
+
isMobile={isMobile}
|
|
59
|
+
onClose={closeChatWidget}
|
|
60
|
+
hashValue={hashValue}
|
|
61
|
+
setHashValue={setHashValue}
|
|
62
|
+
/>
|
|
63
|
+
</DaeryuntalkProvider>
|
|
64
|
+
</DaeryuntalkToastProvider>
|
|
65
|
+
</div>
|
|
64
66
|
);
|
|
65
67
|
};
|
|
66
68
|
|
|
@@ -26,7 +26,6 @@ const Fetch = (url_1, ...args_1) => __awaiter(void 0, [url_1, ...args_1], void 0
|
|
|
26
26
|
// console.log('url', url);
|
|
27
27
|
// const fullUrl = `${process.env.NEXT_PUBLIC_LAWFIRM_API}${url}`;
|
|
28
28
|
const fullUrl = `${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}${url}`;
|
|
29
|
-
// console.log('fullUrl', fullUrl);
|
|
30
29
|
try {
|
|
31
30
|
const result = yield fetch(fullUrl, options)
|
|
32
31
|
.then(item => {
|
|
@@ -27,7 +27,6 @@ const Fetch = async (url: string, options: any = {}) => {
|
|
|
27
27
|
|
|
28
28
|
// const fullUrl = `${process.env.NEXT_PUBLIC_LAWFIRM_API}${url}`;
|
|
29
29
|
const fullUrl = `${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}${url}`;
|
|
30
|
-
// console.log('fullUrl', fullUrl);
|
|
31
30
|
|
|
32
31
|
try {
|
|
33
32
|
const result = await fetch(fullUrl, options)
|
package/dist/styles/globals.css
CHANGED
|
@@ -2224,6 +2224,10 @@ video {
|
|
|
2224
2224
|
height: 1000px;
|
|
2225
2225
|
}
|
|
2226
2226
|
|
|
2227
|
+
.h-\[100dvh\] {
|
|
2228
|
+
height: 100dvh;
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2227
2231
|
.h-\[100px\] {
|
|
2228
2232
|
height: 100px;
|
|
2229
2233
|
}
|
|
@@ -2649,10 +2653,6 @@ video {
|
|
|
2649
2653
|
height: 1px;
|
|
2650
2654
|
}
|
|
2651
2655
|
|
|
2652
|
-
.h-screen {
|
|
2653
|
-
height: 100vh;
|
|
2654
|
-
}
|
|
2655
|
-
|
|
2656
2656
|
.\!max-h-fit {
|
|
2657
2657
|
max-height: -moz-fit-content !important;
|
|
2658
2658
|
max-height: fit-content !important;
|
|
@@ -13400,6 +13400,11 @@ body {
|
|
|
13400
13400
|
grid-column: span 1 / span 1;
|
|
13401
13401
|
}
|
|
13402
13402
|
|
|
13403
|
+
.max-sm\:mx-\[10px\] {
|
|
13404
|
+
margin-left: 10px;
|
|
13405
|
+
margin-right: 10px;
|
|
13406
|
+
}
|
|
13407
|
+
|
|
13403
13408
|
.max-sm\:mx-\[2px\] {
|
|
13404
13409
|
margin-left: 2px;
|
|
13405
13410
|
margin-right: 2px;
|