@daeryun/dr_components 0.9.19 → 0.9.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/components/Daeryuntalk/ChatInput.jsx +1 -1
- package/dist/components/Daeryuntalk/ChatInput.tsx +1 -1
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +52 -51
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +52 -51
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +22 -21
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +22 -21
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +15 -14
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +15 -14
- package/dist/components/Daeryuntalk/_lib/index.js +0 -1
- package/dist/components/Daeryuntalk/_lib/index.ts +0 -1
- package/dist/components/Daeryuntalk/_lib/utils.d.ts +1 -0
- package/dist/components/Daeryuntalk/_lib/utils.js +5 -0
- package/dist/components/Daeryuntalk/_lib/utils.ts +6 -0
- package/dist/styles/globals.css +5 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.d.ts +0 -1
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.js +0 -1
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.ts +0 -1
- package/dist/components/Daeryuntalk/_types/socket/message.d.ts +0 -0
- package/dist/components/Daeryuntalk/_types/socket/message.js +0 -1
- package/dist/components/Daeryuntalk/_types/socket/message.ts +0 -0
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
import { Dispatch, SetStateAction, use } from 'react';
|
|
24
24
|
import { ErrorEnum } from '../../_enums/error';
|
|
25
25
|
import { MessageSocketType } from '../../_enums/socket_type';
|
|
26
|
+
import { consoleFn } from '../../_lib/utils';
|
|
26
27
|
|
|
27
28
|
// API 기본 URL
|
|
28
29
|
const API_BASE_URL = process.env.NEXT_PUBLIC_CHAT_CUSTOMER_API;
|
|
@@ -208,7 +209,7 @@ export async function authenticateUser(centerCode: string, version?: string, ret
|
|
|
208
209
|
|
|
209
210
|
// 빈 응답인 경우에도 성공으로 처리 -> 이거 지워야함
|
|
210
211
|
// if (Object.keys(response).length === 0) {
|
|
211
|
-
//
|
|
212
|
+
// consoleFn('[인증 성공] 사용자 인증 완료 - 빈 응답 (쿠키만 설정됨)');
|
|
212
213
|
// return { success: true, status: 'authenticated' };
|
|
213
214
|
// }
|
|
214
215
|
|
|
@@ -216,7 +217,7 @@ export async function authenticateUser(centerCode: string, version?: string, ret
|
|
|
216
217
|
localStorage.setItem('daeryunchatinquirytoken', response.data.token);
|
|
217
218
|
}
|
|
218
219
|
|
|
219
|
-
|
|
220
|
+
consoleFn('[인증 성공] 사용자 인증 완료', response);
|
|
220
221
|
return response;
|
|
221
222
|
} catch (error) {
|
|
222
223
|
console.error('[인증 실패] 사용자 인증 오류:', error);
|
|
@@ -232,7 +233,7 @@ export async function authenticateUser(centerCode: string, version?: string, ret
|
|
|
232
233
|
export async function initializeWebSocket(
|
|
233
234
|
version?: string
|
|
234
235
|
): Promise<IDaeryunTalkResponseWrapper<WebSocketInitDataResponse>> {
|
|
235
|
-
|
|
236
|
+
consoleFn(
|
|
236
237
|
'[웹소켓 초기화 시작] 웹소켓 연결 초기화 요청',
|
|
237
238
|
version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
|
|
238
239
|
);
|
|
@@ -276,27 +277,27 @@ export function connectWebSocket(
|
|
|
276
277
|
): WebSocket {
|
|
277
278
|
// URL에 토큰을 파라미터로 추가
|
|
278
279
|
const connectionUrl = `${wsUrl}?token=${token}`;
|
|
279
|
-
|
|
280
|
+
consoleFn('[웹소켓 연결 시작] 연결 URL:', connectionUrl);
|
|
280
281
|
|
|
281
282
|
try {
|
|
282
283
|
const socket = new WebSocket(connectionUrl);
|
|
283
284
|
|
|
284
285
|
const setupSocketHandlers = (socket: WebSocket) => {
|
|
285
286
|
socket.onopen = event => {
|
|
286
|
-
|
|
287
|
+
consoleFn('[웹소켓 연결 성공]');
|
|
287
288
|
reconnectAttempts = 0;
|
|
288
289
|
if (onOpen) onOpen(event);
|
|
289
290
|
};
|
|
290
291
|
|
|
291
292
|
socket.onmessage = event => {
|
|
292
|
-
|
|
293
|
+
consoleFn('[웹소켓 메시지 수신]', event.data);
|
|
293
294
|
|
|
294
295
|
try {
|
|
295
296
|
const data = JSON.parse(event.data);
|
|
296
297
|
if (data?.type === 'user.expired' || event?.data?.type === MessageSocketType.USER_EXPIRED) {
|
|
297
298
|
userExpiredRef && (userExpiredRef.current = true);
|
|
298
299
|
}
|
|
299
|
-
|
|
300
|
+
consoleFn('📩 New Message (parsed):', data);
|
|
300
301
|
} catch (err) {
|
|
301
302
|
console.error('[웹소켓] JSON 파싱 오류:', err);
|
|
302
303
|
}
|
|
@@ -306,26 +307,26 @@ export function connectWebSocket(
|
|
|
306
307
|
|
|
307
308
|
socket.onclose = async event => {
|
|
308
309
|
console.warn('[웹소켓 종료]', event);
|
|
309
|
-
//
|
|
310
|
+
// consoleFn('is', isOpen);
|
|
310
311
|
//
|
|
311
312
|
|
|
312
|
-
|
|
313
|
+
consoleFn('userExpiredRef.current', userExpiredRef.current);
|
|
313
314
|
|
|
314
315
|
if (userExpiredRef.current) {
|
|
315
|
-
|
|
316
|
+
consoleFn('[웹소켓 종료] 만기 유저는 소켓 연결 재시도 하지 않음');
|
|
316
317
|
if (onClose) onClose(event);
|
|
317
318
|
return;
|
|
318
319
|
}
|
|
319
320
|
|
|
320
321
|
// if (!isOpen) {
|
|
321
|
-
//
|
|
322
|
+
// consoleFn('[웹소켓 종료] 채팅창이 닫혀있어 재연결하지 않음');
|
|
322
323
|
// if (onClose) onClose(event);
|
|
323
324
|
// return;
|
|
324
325
|
// }
|
|
325
326
|
|
|
326
327
|
if (reconnectAttempts < MAX_RECONNECT_ATTEMPTS) {
|
|
327
328
|
reconnectAttempts++;
|
|
328
|
-
|
|
329
|
+
consoleFn(`[재연결 시도] ${reconnectAttempts}회... ${RECONNECT_DELAY_MS}ms 후`);
|
|
329
330
|
await new Promise(res => setTimeout(res, RECONNECT_DELAY_MS));
|
|
330
331
|
|
|
331
332
|
try {
|
|
@@ -343,7 +344,7 @@ export function connectWebSocket(
|
|
|
343
344
|
// 새 소켓에 핸들러 등록
|
|
344
345
|
setupSocketHandlers(newSocket);
|
|
345
346
|
} catch (error) {
|
|
346
|
-
|
|
347
|
+
consoleFn('socket error', error);
|
|
347
348
|
setIsConnected(false);
|
|
348
349
|
}
|
|
349
350
|
} else {
|
|
@@ -382,9 +383,9 @@ export async function getChatInquiryMain(
|
|
|
382
383
|
channel_number: channelNumber
|
|
383
384
|
}
|
|
384
385
|
};
|
|
385
|
-
|
|
386
|
+
consoleFn('body', body);
|
|
386
387
|
|
|
387
|
-
|
|
388
|
+
consoleFn(
|
|
388
389
|
'[채팅 문의 메인 조회 시작] 채널 번호:',
|
|
389
390
|
body.d.channel_number,
|
|
390
391
|
version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
|
|
@@ -398,7 +399,7 @@ export async function getChatInquiryMain(
|
|
|
398
399
|
},
|
|
399
400
|
version
|
|
400
401
|
);
|
|
401
|
-
|
|
402
|
+
consoleFn('[채팅 문의 메인 조회 성공]', response);
|
|
402
403
|
return response;
|
|
403
404
|
} catch (error) {
|
|
404
405
|
console.error('[채팅 문의 메인 조회 실패]', error);
|
|
@@ -418,7 +419,7 @@ export async function generateChatInquiry(
|
|
|
418
419
|
centerCode?: string,
|
|
419
420
|
version?: string
|
|
420
421
|
): Promise<IDaeryunTalkResponseWrapper<ChatInquiryCreateDataResponse>> {
|
|
421
|
-
|
|
422
|
+
consoleFn('[새 채팅 문의 생성 시작 (개선)]', version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
|
|
422
423
|
let channelId = channelNumber;
|
|
423
424
|
if (!channelNumber) {
|
|
424
425
|
const authRes = await authenticateUser((centerCode || 'CT0000') ?? 'CT0000', version);
|
|
@@ -441,7 +442,7 @@ export async function generateChatInquiry(
|
|
|
441
442
|
},
|
|
442
443
|
version
|
|
443
444
|
);
|
|
444
|
-
|
|
445
|
+
consoleFn('[새 채팅 문의 생성 성공 (개선)] 문의 번호:', response.data.chat_inquiry_number);
|
|
445
446
|
return response;
|
|
446
447
|
} catch (error) {
|
|
447
448
|
console.error('[새 채팅 문의 생성 실패 (개선)]', error);
|
|
@@ -465,7 +466,7 @@ export async function getChatInquiryDetailNew(
|
|
|
465
466
|
}
|
|
466
467
|
};
|
|
467
468
|
|
|
468
|
-
|
|
469
|
+
consoleFn(
|
|
469
470
|
'[채팅 문의 상세 조회 시작 (개선)] 문의 번호:',
|
|
470
471
|
chat_inquiry_number,
|
|
471
472
|
version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
|
|
@@ -479,7 +480,7 @@ export async function getChatInquiryDetailNew(
|
|
|
479
480
|
},
|
|
480
481
|
version
|
|
481
482
|
);
|
|
482
|
-
|
|
483
|
+
consoleFn('[채팅 문의 상세 조회 성공 (개선)]', response);
|
|
483
484
|
return response;
|
|
484
485
|
} catch (error) {
|
|
485
486
|
console.error('[채팅 문의 상세 조회 실패 (개선)]', error);
|
|
@@ -510,7 +511,7 @@ export async function getChatInquiryMessageList(
|
|
|
510
511
|
}
|
|
511
512
|
};
|
|
512
513
|
|
|
513
|
-
|
|
514
|
+
consoleFn(
|
|
514
515
|
'[채팅 메세지 리스트] 문의 번호:',
|
|
515
516
|
chatInquiryNumber,
|
|
516
517
|
version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
|
|
@@ -524,7 +525,7 @@ export async function getChatInquiryMessageList(
|
|
|
524
525
|
},
|
|
525
526
|
version
|
|
526
527
|
);
|
|
527
|
-
|
|
528
|
+
consoleFn('[채팅 메세지 리스트]', response);
|
|
528
529
|
return response;
|
|
529
530
|
} catch (error) {
|
|
530
531
|
console.error('[채팅 메세지 리스트]', error);
|
|
@@ -559,23 +560,23 @@ export async function initializeDaeryuntalk(
|
|
|
559
560
|
if (typeof window !== 'undefined' && hashValue) {
|
|
560
561
|
localStorage.removeItem('daeryunchatinquirytoken');
|
|
561
562
|
}
|
|
562
|
-
|
|
563
|
+
consoleFn(
|
|
563
564
|
'[Daeryuntalk 초기화 시작] 전체 흐름 실행',
|
|
564
565
|
version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`
|
|
565
566
|
);
|
|
566
567
|
try {
|
|
567
|
-
|
|
568
|
+
consoleFn('[Daeryuntalk 초기화] 전체 흐름 시작');
|
|
568
569
|
let errorData: IDaeryunTalkResponseWrapper<any> | null = null;
|
|
569
570
|
|
|
570
571
|
// 1단계: 사용자 인증
|
|
571
572
|
let authResponse = await retryable(() => authenticateUser(centerCode, version), 1, 350, '사용자 인증');
|
|
572
573
|
|
|
573
|
-
|
|
574
|
+
consoleFn('authResponse11', authResponse);
|
|
574
575
|
// 9379809eec4c09ea276496b15b5d2778a2ef7af312c25d95bd2a0f884cb72bf3
|
|
575
576
|
// 만약 만료된 토큰이라면?
|
|
576
|
-
//
|
|
577
|
-
//
|
|
578
|
-
//
|
|
577
|
+
// consoleFn('authResponse', authResponse);
|
|
578
|
+
// consoleFn('ErrorEnum.CE_TOKEN_EXPIRED', ErrorEnum.CE_TOKEN_EXPIRED);
|
|
579
|
+
// consoleFn('authResponse?.result_info?.result_cd', authResponse?.result_info?.result_cd);
|
|
579
580
|
if (authResponse?.result_info?.result_cd === 'OK' || authResponse?.result_info?.result_type_cd === 'OK') {
|
|
580
581
|
} else {
|
|
581
582
|
if (
|
|
@@ -584,7 +585,7 @@ export async function initializeDaeryuntalk(
|
|
|
584
585
|
) {
|
|
585
586
|
// 재인증 시작
|
|
586
587
|
errorData = authResponse;
|
|
587
|
-
|
|
588
|
+
consoleFn('재인증 시작');
|
|
588
589
|
localStorage.removeItem('daeryunchatinquirytoken');
|
|
589
590
|
authResponse = await retryable(
|
|
590
591
|
() => authenticateUser(centerCode, version, true),
|
|
@@ -629,7 +630,7 @@ export async function initializeDaeryuntalk(
|
|
|
629
630
|
userExpiredRef,
|
|
630
631
|
onWebSocketMessage,
|
|
631
632
|
() => {
|
|
632
|
-
|
|
633
|
+
consoleFn('[웹소켓 연결 성공]');
|
|
633
634
|
onWebSocketConnected?.(ws);
|
|
634
635
|
resolve(ws);
|
|
635
636
|
},
|
|
@@ -662,7 +663,7 @@ export async function initializeDaeryuntalk(
|
|
|
662
663
|
'채팅 문의 메인 조회'
|
|
663
664
|
);
|
|
664
665
|
|
|
665
|
-
|
|
666
|
+
consoleFn('[Daeryuntalk 초기화 완료]');
|
|
666
667
|
return {
|
|
667
668
|
inquiryData: chatInquiryData,
|
|
668
669
|
socket,
|
|
@@ -701,7 +702,7 @@ export async function chatWorkFlow(
|
|
|
701
702
|
}
|
|
702
703
|
};
|
|
703
704
|
|
|
704
|
-
|
|
705
|
+
consoleFn(
|
|
705
706
|
'[채팅 워크플로우 시작]',
|
|
706
707
|
'문의 번호:',
|
|
707
708
|
chatInquiryNumber,
|
|
@@ -722,7 +723,7 @@ export async function chatWorkFlow(
|
|
|
722
723
|
},
|
|
723
724
|
version
|
|
724
725
|
);
|
|
725
|
-
|
|
726
|
+
consoleFn('[채팅 워크플로우 시작 성공]', response);
|
|
726
727
|
return response;
|
|
727
728
|
} catch (error) {
|
|
728
729
|
console.error('[채팅 워크플로우 시작 실패]', error);
|
|
@@ -753,7 +754,7 @@ export async function chatWorkFlowBack(
|
|
|
753
754
|
}
|
|
754
755
|
};
|
|
755
756
|
|
|
756
|
-
|
|
757
|
+
consoleFn(
|
|
757
758
|
'[채팅 워크플로우 되돌리기 시작]',
|
|
758
759
|
'문의 번호:',
|
|
759
760
|
chatInquiryNumber,
|
|
@@ -772,7 +773,7 @@ export async function chatWorkFlowBack(
|
|
|
772
773
|
},
|
|
773
774
|
version
|
|
774
775
|
);
|
|
775
|
-
|
|
776
|
+
consoleFn('[채팅 워크플로우 되돌리기 성공]', response);
|
|
776
777
|
return response;
|
|
777
778
|
} catch (error) {
|
|
778
779
|
console.error('[채팅 워크플로우 되돌리기 실패]', error);
|
|
@@ -812,7 +813,7 @@ export async function sendChatMessage(
|
|
|
812
813
|
}
|
|
813
814
|
};
|
|
814
815
|
|
|
815
|
-
|
|
816
|
+
consoleFn(
|
|
816
817
|
'[채팅 메시지 전송 시작] 문의 번호:',
|
|
817
818
|
chatInquiryNumber,
|
|
818
819
|
'메시지:',
|
|
@@ -828,7 +829,7 @@ export async function sendChatMessage(
|
|
|
828
829
|
},
|
|
829
830
|
version
|
|
830
831
|
);
|
|
831
|
-
|
|
832
|
+
consoleFn('[채팅 메시지 전송 성공]', response);
|
|
832
833
|
return response;
|
|
833
834
|
} catch (error) {
|
|
834
835
|
console.error('[채팅 메시지 전송 실패]', error);
|
|
@@ -861,7 +862,7 @@ export async function chatUserUpdate(
|
|
|
861
862
|
}
|
|
862
863
|
};
|
|
863
864
|
|
|
864
|
-
|
|
865
|
+
consoleFn('[채팅 개인 정보 업데이트] 시작');
|
|
865
866
|
try {
|
|
866
867
|
const response = await fetchWithCookies<any>(
|
|
867
868
|
`${API_BASE_URL}${ENDPOINTS.USER_INFO_UPDATE}`,
|
|
@@ -871,7 +872,7 @@ export async function chatUserUpdate(
|
|
|
871
872
|
},
|
|
872
873
|
version
|
|
873
874
|
);
|
|
874
|
-
|
|
875
|
+
consoleFn('[채팅 메시지 전송 성공]', response);
|
|
875
876
|
return response;
|
|
876
877
|
} catch (error) {
|
|
877
878
|
console.error('[채팅 메시지 전송 실패]', error);
|
|
@@ -902,7 +903,7 @@ export const getMessageFileDownloadUrl = async ({
|
|
|
902
903
|
file_number: fileNumber // required
|
|
903
904
|
}
|
|
904
905
|
};
|
|
905
|
-
|
|
906
|
+
consoleFn(`[${consoleName} 진행]`);
|
|
906
907
|
const response = await fetchWithCookies<{ url: string }>(
|
|
907
908
|
`${API_BASE_URL}${ENDPOINTS.CHAT_MESSAGE_FILE_URL_REQUEST}`,
|
|
908
909
|
{
|
|
@@ -912,7 +913,7 @@ export const getMessageFileDownloadUrl = async ({
|
|
|
912
913
|
version
|
|
913
914
|
);
|
|
914
915
|
|
|
915
|
-
|
|
916
|
+
consoleFn(`[${consoleName} 완료]`, response);
|
|
916
917
|
return response;
|
|
917
918
|
} catch (error) {
|
|
918
919
|
console.error(`[${consoleName} 실패] 오류:`, error);
|
|
@@ -948,7 +949,7 @@ export const requestPhone = async ({
|
|
|
948
949
|
cell_phone_number: cellPhoneNumber // required
|
|
949
950
|
}
|
|
950
951
|
};
|
|
951
|
-
|
|
952
|
+
consoleFn(`[${consoleName} 진행]`);
|
|
952
953
|
const response = await fetchWithCookies<RequestConfirmNumberResponse>(
|
|
953
954
|
`${API_BASE_URL}${ENDPOINTS.HISTORY_PHONE_REQUEST}`,
|
|
954
955
|
{
|
|
@@ -958,7 +959,7 @@ export const requestPhone = async ({
|
|
|
958
959
|
version
|
|
959
960
|
);
|
|
960
961
|
|
|
961
|
-
|
|
962
|
+
consoleFn(`[${consoleName} 완료]`, response);
|
|
962
963
|
return response;
|
|
963
964
|
} catch (error) {
|
|
964
965
|
console.error(`[${consoleName} 실패] 오류:`, error);
|
|
@@ -993,7 +994,7 @@ export const historyPhoneAuth = async ({
|
|
|
993
994
|
certification_number: certificationNumber // required
|
|
994
995
|
}
|
|
995
996
|
};
|
|
996
|
-
|
|
997
|
+
consoleFn(`[${consoleName} 진행]`);
|
|
997
998
|
const response = await fetchWithCookies<unknown>(
|
|
998
999
|
`${API_BASE_URL}${ENDPOINTS.HISTORY_PHONE_AUTHENTICATION}`,
|
|
999
1000
|
{
|
|
@@ -1003,7 +1004,7 @@ export const historyPhoneAuth = async ({
|
|
|
1003
1004
|
version
|
|
1004
1005
|
);
|
|
1005
1006
|
|
|
1006
|
-
|
|
1007
|
+
consoleFn(`[${consoleName} 완료]`, response);
|
|
1007
1008
|
return response;
|
|
1008
1009
|
} catch (error) {
|
|
1009
1010
|
console.error(`[${consoleName} 실패] 오류:`, error);
|
|
@@ -1014,7 +1015,7 @@ export const historyPhoneAuth = async ({
|
|
|
1014
1015
|
export const getHistoryList = async ({ version = DEFAULT_API_VERSION }: { version?: string }) => {
|
|
1015
1016
|
const consoleName = '히스토리 채팅 문의 목록 조회';
|
|
1016
1017
|
try {
|
|
1017
|
-
|
|
1018
|
+
consoleFn(`[${consoleName} 진행]`);
|
|
1018
1019
|
const response = await fetchWithCookies<HistoryListResponse>(
|
|
1019
1020
|
`${API_BASE_URL}${ENDPOINTS.HISTORY_LIST}`,
|
|
1020
1021
|
{
|
|
@@ -1024,7 +1025,7 @@ export const getHistoryList = async ({ version = DEFAULT_API_VERSION }: { versio
|
|
|
1024
1025
|
version
|
|
1025
1026
|
);
|
|
1026
1027
|
|
|
1027
|
-
|
|
1028
|
+
consoleFn(`[${consoleName} 완료]`, response);
|
|
1028
1029
|
return response;
|
|
1029
1030
|
} catch (error) {
|
|
1030
1031
|
console.error(`[${consoleName} 실패] 오류:`, error);
|
|
@@ -1041,7 +1042,7 @@ export const attendChatRoomByHistory = async ({
|
|
|
1041
1042
|
}) => {
|
|
1042
1043
|
const consoleName = '히스토리 채팅 문의 참여';
|
|
1043
1044
|
try {
|
|
1044
|
-
|
|
1045
|
+
consoleFn(`[${consoleName} 진행]`);
|
|
1045
1046
|
|
|
1046
1047
|
const body = {
|
|
1047
1048
|
d: {
|
|
@@ -1057,7 +1058,7 @@ export const attendChatRoomByHistory = async ({
|
|
|
1057
1058
|
version
|
|
1058
1059
|
);
|
|
1059
1060
|
|
|
1060
|
-
|
|
1061
|
+
consoleFn(`[${consoleName} 완료]`, response);
|
|
1061
1062
|
return response;
|
|
1062
1063
|
} catch (error) {
|
|
1063
1064
|
console.error(`[${consoleName} 실패] 오류:`, error);
|
|
@@ -1068,7 +1069,7 @@ export const attendChatRoomByHistory = async ({
|
|
|
1068
1069
|
export const followupAttend = async ({ token, version = DEFAULT_API_VERSION }: { token: string; version?: string }) => {
|
|
1069
1070
|
const consoleName = '히스토리 채팅 문의 참여';
|
|
1070
1071
|
try {
|
|
1071
|
-
|
|
1072
|
+
consoleFn(`[${consoleName} 진행]`);
|
|
1072
1073
|
|
|
1073
1074
|
const body = {
|
|
1074
1075
|
d: {
|
|
@@ -1084,7 +1085,7 @@ export const followupAttend = async ({ token, version = DEFAULT_API_VERSION }: {
|
|
|
1084
1085
|
version
|
|
1085
1086
|
);
|
|
1086
1087
|
|
|
1087
|
-
|
|
1088
|
+
consoleFn(`[${consoleName} 완료]`, response);
|
|
1088
1089
|
return response;
|
|
1089
1090
|
} catch (error) {
|
|
1090
1091
|
console.error(`[${consoleName} 실패] 오류:`, error);
|
|
@@ -13,6 +13,7 @@ import { convertApiMessageObjectToUiMessageObject, convertApiMessageToUiMessage
|
|
|
13
13
|
import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
|
|
14
14
|
import { useFullURL } from './useFullURL';
|
|
15
15
|
import { getErrorMessageMap } from '../../_enums/error';
|
|
16
|
+
import { consoleFn } from '../../_lib/utils';
|
|
16
17
|
export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, setInquiryMainData, centerCode }) => {
|
|
17
18
|
const toast = useDaeryunTalkToast();
|
|
18
19
|
const fullUrl = useFullURL();
|
|
@@ -28,7 +29,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
28
29
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
29
30
|
try {
|
|
30
31
|
setIsLoading(true);
|
|
31
|
-
|
|
32
|
+
consoleFn('[DaeryuntalkContext] 채팅 시작 요청');
|
|
32
33
|
// 기존 문의가 있는지 확인
|
|
33
34
|
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()) !== '';
|
|
34
35
|
let currentChatInquiryNumber = '';
|
|
@@ -37,11 +38,11 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
37
38
|
currentChatInquiryNumber = inquiryNumber
|
|
38
39
|
? inquiryNumber
|
|
39
40
|
: (inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.progress_inquiry_number) || '';
|
|
40
|
-
|
|
41
|
+
consoleFn('[DaeryuntalkContext] 기존 문의 사용:', currentChatInquiryNumber);
|
|
41
42
|
}
|
|
42
43
|
else {
|
|
43
44
|
// 새 문의 생성
|
|
44
|
-
|
|
45
|
+
consoleFn('[DaeryuntalkContext] 새 문의 생성 시작');
|
|
45
46
|
const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '', fullUrl, centerCode);
|
|
46
47
|
if (!(createResponse.result_info.result_cd === 'OK' ||
|
|
47
48
|
createResponse.result_info.result_type_cd === 'OK')) {
|
|
@@ -52,7 +53,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
52
53
|
currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
53
54
|
}
|
|
54
55
|
// 문의 상세 조회
|
|
55
|
-
|
|
56
|
+
consoleFn('[DaeryuntalkContext] 문의 상세 조회 시작:', currentChatInquiryNumber);
|
|
56
57
|
const detailResponse = yield getChatInquiryDetailNew(currentChatInquiryNumber);
|
|
57
58
|
if (!(detailResponse.result_info.result_cd === 'OK' ||
|
|
58
59
|
detailResponse.result_info.result_type_cd === 'OK')) {
|
|
@@ -60,18 +61,18 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
60
61
|
toast.error(getErrorMessageMap(detailResponse));
|
|
61
62
|
return detailResponse;
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
consoleFn('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
|
|
65
|
+
consoleFn('[DaeryuntalkContext] 문의 채팅 리스트 조회 시작:', currentChatInquiryNumber);
|
|
65
66
|
const chatList = yield getChatInquiryMessageList(currentChatInquiryNumber);
|
|
66
67
|
if (!(chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK')) {
|
|
67
68
|
resetData();
|
|
68
69
|
toast.error(getErrorMessageMap(chatList));
|
|
69
70
|
return chatList;
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
+
consoleFn('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
|
|
72
73
|
// 문의 정보 저장
|
|
73
74
|
setChatInquiryNumber(currentChatInquiryNumber);
|
|
74
|
-
|
|
75
|
+
consoleFn('detailResponse.data.message_list', (_a = chatList === null || chatList === void 0 ? void 0 : chatList.data) === null || _a === void 0 ? void 0 : _a.message_list);
|
|
75
76
|
// 메시지 처리
|
|
76
77
|
// 메세지 리스트 후처리
|
|
77
78
|
if (chatList.data.message_list.length > 0) {
|
|
@@ -79,7 +80,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
79
80
|
.sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
|
|
80
81
|
.map(convertApiMessageToUiMessage);
|
|
81
82
|
setMessages(uiMessages);
|
|
82
|
-
|
|
83
|
+
consoleFn('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
83
84
|
}
|
|
84
85
|
if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.next_page_yn) !== null) {
|
|
85
86
|
setIsNextPage(chatList.data.next_page_yn);
|
|
@@ -126,15 +127,15 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
126
127
|
toast.error(getErrorMessageMap(detailResponse));
|
|
127
128
|
return detailResponse;
|
|
128
129
|
}
|
|
129
|
-
|
|
130
|
+
consoleFn('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
|
|
130
131
|
const chatList = yield getChatInquiryMessageList(chatInquiryNumber);
|
|
131
|
-
|
|
132
|
+
consoleFn('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
|
|
132
133
|
if (!(chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK')) {
|
|
133
134
|
resetData();
|
|
134
135
|
toast.error(getErrorMessageMap(chatList));
|
|
135
136
|
return chatList;
|
|
136
137
|
}
|
|
137
|
-
|
|
138
|
+
consoleFn('detailResponse.data.message_list', (_a = chatList === null || chatList === void 0 ? void 0 : chatList.data) === null || _a === void 0 ? void 0 : _a.message_list);
|
|
138
139
|
// 메시지 처리
|
|
139
140
|
// 문의 정보 저장
|
|
140
141
|
setChatInquiryNumber(chatInquiryNumber);
|
|
@@ -155,7 +156,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
155
156
|
setMessages(uiMessages);
|
|
156
157
|
// const uiMessages = chatList.data.message_list.map(convertApiMessageToUiMessage);
|
|
157
158
|
setMessages(uiMessages);
|
|
158
|
-
|
|
159
|
+
consoleFn('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
159
160
|
}
|
|
160
161
|
if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.next_page_yn) !== null) {
|
|
161
162
|
setIsNextPage(chatList.data.next_page_yn);
|
|
@@ -192,7 +193,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
192
193
|
const sendMessage = useCallback((htmlContent, jsonData, retry) => __awaiter(void 0, void 0, void 0, function* () {
|
|
193
194
|
try {
|
|
194
195
|
setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(true);
|
|
195
|
-
|
|
196
|
+
consoleFn('chatInquiryNumber', chatInquiryNumber);
|
|
196
197
|
const response = yield sendChatMessage(chatInquiryNumber, htmlContent, jsonData);
|
|
197
198
|
if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
|
|
198
199
|
toast.error(getErrorMessageMap(response));
|
|
@@ -216,19 +217,19 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
216
217
|
return;
|
|
217
218
|
}
|
|
218
219
|
setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(true);
|
|
219
|
-
|
|
220
|
+
consoleFn('chatInquiryNumber', chatInquiryNumber);
|
|
220
221
|
const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '', fullUrl, centerCode);
|
|
221
222
|
if (!(createResponse.result_info.result_cd === 'OK' ||
|
|
222
223
|
createResponse.result_info.result_type_cd === 'OK')) {
|
|
223
224
|
toast.error(getErrorMessageMap(createResponse));
|
|
224
225
|
return createResponse;
|
|
225
226
|
}
|
|
226
|
-
|
|
227
|
+
consoleFn('[DaeryuntalkContext] 새 문의 생성 완료:', createResponse);
|
|
227
228
|
const currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
228
229
|
// 문의 상세 조회
|
|
229
|
-
|
|
230
|
+
consoleFn('[DaeryuntalkContext] 문의 상세 조회 시작:', currentChatInquiryNumber);
|
|
230
231
|
const detailResponse = yield getChatInquiryDetailNew(currentChatInquiryNumber);
|
|
231
|
-
|
|
232
|
+
consoleFn('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
|
|
232
233
|
if (!(detailResponse.result_info.result_cd === 'OK' ||
|
|
233
234
|
detailResponse.result_info.result_type_cd === 'OK')) {
|
|
234
235
|
resetData();
|
|
@@ -236,9 +237,9 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
236
237
|
return detailResponse;
|
|
237
238
|
}
|
|
238
239
|
// 메세지 리스트
|
|
239
|
-
|
|
240
|
+
consoleFn('[DaeryuntalkContext] 문의 채팅 리스트 조회 시작:', currentChatInquiryNumber);
|
|
240
241
|
const chatList = yield getChatInquiryMessageList(currentChatInquiryNumber);
|
|
241
|
-
|
|
242
|
+
consoleFn('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
|
|
242
243
|
if (!(chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK')) {
|
|
243
244
|
resetData();
|
|
244
245
|
toast.error(getErrorMessageMap(chatList));
|
|
@@ -252,7 +253,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
252
253
|
.sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime())
|
|
253
254
|
.map(convertApiMessageToUiMessage);
|
|
254
255
|
setMessages(uiMessages);
|
|
255
|
-
|
|
256
|
+
consoleFn('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
256
257
|
}
|
|
257
258
|
if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.next_page_yn) !== null) {
|
|
258
259
|
setIsNextPage(chatList.data.next_page_yn);
|