@daeryun/dr_components 0.8.4 → 0.8.5

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.
@@ -76,9 +76,10 @@ export declare function getChatInquiryMessageList(chatInquiryNumber: string, sta
76
76
  * @param version API 버전 (기본값: 1.0.0)
77
77
  * @returns 웹소켓 인스턴스 및 문의 데이터
78
78
  */
79
- export declare function initializeDaeryuntalk(onWebSocketConnected?: (socket: WebSocket) => void, onWebSocketMessage?: (event: MessageEvent) => void, version?: string): Promise<{
79
+ export declare function initializeDaeryuntalk(hashValue: string, onWebSocketConnected?: (socket: WebSocket) => void, onWebSocketMessage?: (event: MessageEvent) => void, version?: string): Promise<{
80
80
  inquiryData?: IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse>;
81
81
  socket: WebSocket;
82
+ hashAuth: any;
82
83
  }>;
83
84
  /**
84
85
  * 채팅 워크플로우 진행 처리
@@ -381,7 +381,7 @@ export function getChatInquiryMessageList(chatInquiryNumber, standardDateTime, s
381
381
  * @param version API 버전 (기본값: 1.0.0)
382
382
  * @returns 웹소켓 인스턴스 및 문의 데이터
383
383
  */
384
- export function initializeDaeryuntalk(onWebSocketConnected, onWebSocketMessage, version) {
384
+ export function initializeDaeryuntalk(hashValue, onWebSocketConnected, onWebSocketMessage, version) {
385
385
  return __awaiter(this, void 0, void 0, function* () {
386
386
  console.log('[Daeryuntalk 초기화 시작] 전체 흐름 실행', version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
387
387
  try {
@@ -410,6 +410,12 @@ export function initializeDaeryuntalk(onWebSocketConnected, onWebSocketMessage,
410
410
  : undefined);
411
411
  // console.log('socket', socket);
412
412
  console.log('[Daeryuntalk 초기화] 3단계: 웹소켓 연결 객체 생성됨');
413
+ console.log('[DaeryuntalkContext] 로딩 상태 설정: true');
414
+ // 만약 해쉬값이 있으면 이것부터 해여함
415
+ let hashAuth;
416
+ if (hashValue) {
417
+ hashAuth = yield followupAttend({ token: hashValue });
418
+ }
413
419
  console.log('authResponse', authResponse);
414
420
  // 4단계: 채팅 문의 메인 조회
415
421
  console.log('[Daeryuntalk 초기화] 4단계: 채팅 문의 메인 조회 시작');
@@ -417,7 +423,8 @@ export function initializeDaeryuntalk(onWebSocketConnected, onWebSocketMessage,
417
423
  console.log('[Daeryuntalk 초기화] 4단계: 채팅 문의 메인 조회 완료', chatInquiryData);
418
424
  return {
419
425
  inquiryData: chatInquiryData,
420
- socket: socket
426
+ socket: socket,
427
+ hashAuth: hashAuth
421
428
  };
422
429
  console.log('[Daeryuntalk 초기화 완료] 모든 단계 성공');
423
430
  }
@@ -483,12 +483,14 @@ export async function getChatInquiryMessageList(
483
483
  * @returns 웹소켓 인스턴스 및 문의 데이터
484
484
  */
485
485
  export async function initializeDaeryuntalk(
486
+ hashValue: string,
486
487
  onWebSocketConnected?: (socket: WebSocket) => void,
487
488
  onWebSocketMessage?: (event: MessageEvent) => void,
488
489
  version?: string
489
490
  ): Promise<{
490
491
  inquiryData?: IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse>;
491
492
  socket: WebSocket;
493
+ hashAuth: any;
492
494
  }> {
493
495
  console.log(
494
496
  '[Daeryuntalk 초기화 시작] 전체 흐름 실행',
@@ -528,6 +530,13 @@ export async function initializeDaeryuntalk(
528
530
  // console.log('socket', socket);
529
531
  console.log('[Daeryuntalk 초기화] 3단계: 웹소켓 연결 객체 생성됨');
530
532
 
533
+ console.log('[DaeryuntalkContext] 로딩 상태 설정: true');
534
+ // 만약 해쉬값이 있으면 이것부터 해여함
535
+ let hashAuth;
536
+ if (hashValue) {
537
+ hashAuth = await followupAttend({ token: hashValue });
538
+ }
539
+
531
540
  console.log('authResponse', authResponse);
532
541
  // 4단계: 채팅 문의 메인 조회
533
542
  console.log('[Daeryuntalk 초기화] 4단계: 채팅 문의 메인 조회 시작');
@@ -535,7 +544,8 @@ export async function initializeDaeryuntalk(
535
544
  console.log('[Daeryuntalk 초기화] 4단계: 채팅 문의 메인 조회 완료', chatInquiryData);
536
545
  return {
537
546
  inquiryData: chatInquiryData,
538
- socket: socket
547
+ socket: socket,
548
+ hashAuth: hashAuth
539
549
  };
540
550
  console.log('[Daeryuntalk 초기화 완료] 모든 단계 성공');
541
551
  } catch (error) {
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { useCallback } from 'react';
11
- import { followupAttend, initializeDaeryuntalk as apiInitializeDaeryuntalk } from '../../_api/daeryuntalk';
11
+ import { initializeDaeryuntalk as apiInitializeDaeryuntalk } from '../../_api/daeryuntalk';
12
12
  import { convertApiMessageToUiMessage, convertSocketObjectToUiMessage } from '../../_lib';
13
13
  import { MessageSocketType } from '../../_enums/socket_type';
14
14
  import { InquiryStatus } from '../../_enums/ask-status';
@@ -124,20 +124,19 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
124
124
  try {
125
125
  setIsLoading(true);
126
126
  console.log('[DaeryuntalkContext] 로딩 상태 설정: true');
127
- // 만약 해쉬값이 있으면 이것부터 해여함
128
- if (hashValue) {
129
- const hashAuth = yield followupAttend({ token: hashValue });
130
- console.log('hashAuth', hashAuth);
131
- if (((_a = hashAuth === null || hashAuth === void 0 ? void 0 : hashAuth.result_info) === null || _a === void 0 ? void 0 : _a.result_type_cd) === 'OK' || ((_b = hashAuth === null || hashAuth === void 0 ? void 0 : hashAuth.result_info) === null || _b === void 0 ? void 0 : _b.result_cd) === 'OK') {
132
- // 인증 완
133
- }
134
- else {
135
- toast.error('인증에 실패했습니다.');
136
- // window.location.href = '/';
137
- return;
138
- }
139
- }
140
- const { inquiryData, socket } = yield apiInitializeDaeryuntalk(socket => {
127
+ // // 만약 해쉬값이 있으면 이것부터 해여함
128
+ // if (hashValue) {
129
+ // const hashAuth = await followupAttend({ token: hashValue });
130
+ // console.log('hashAuth', hashAuth);
131
+ // if (hashAuth?.result_info?.result_type_cd === 'OK' || hashAuth?.result_info?.result_cd === 'OK') {
132
+ // // 인증 완
133
+ // } else {
134
+ // toast.error('인증에 실패했습니다.');
135
+ // // window.location.href = '/';
136
+ // return;
137
+ // }
138
+ // }
139
+ const { inquiryData, socket, hashAuth } = yield apiInitializeDaeryuntalk(hashValue || '', socket => {
141
140
  console.log('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 성공');
142
141
  setIsConnected(true);
143
142
  }, event => {
@@ -211,6 +210,14 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
211
210
  console.error('[DaeryuntalkContext] 웹소켓 메시지 처리 오류:', error);
212
211
  }
213
212
  });
213
+ if (hashValue) {
214
+ if (((_a = hashAuth === null || hashAuth === void 0 ? void 0 : hashAuth.result_info) === null || _a === void 0 ? void 0 : _a.result_cd) === 'OK' || ((_b = hashAuth === null || hashAuth === void 0 ? void 0 : hashAuth.result_info) === null || _b === void 0 ? void 0 : _b.result_type_cd) === 'OK') {
215
+ }
216
+ else {
217
+ toast.error('인증에 실패했습니다.');
218
+ window.location.hash = '/';
219
+ }
220
+ }
214
221
  if (inquiryData) {
215
222
  setInquiryMainData(inquiryData.data);
216
223
  }
@@ -154,20 +154,21 @@ export const useSocketEventHandler = ({
154
154
  try {
155
155
  setIsLoading(true);
156
156
  console.log('[DaeryuntalkContext] 로딩 상태 설정: true');
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
- }
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
+ // }
169
169
 
170
- const { inquiryData, socket } = await apiInitializeDaeryuntalk(
170
+ const { inquiryData, socket, hashAuth } = await apiInitializeDaeryuntalk(
171
+ hashValue || '',
171
172
  socket => {
172
173
  console.log('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 성공');
173
174
  setIsConnected(true);
@@ -253,6 +254,13 @@ export const useSocketEventHandler = ({
253
254
  }
254
255
  }
255
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
+ }
256
264
 
257
265
  if (inquiryData) {
258
266
  setInquiryMainData(inquiryData.data as IChatInquiryMainDataResponse);
@@ -27,7 +27,7 @@ const Daeryuntalk = ({ tel = '1800-7905' }) => {
27
27
  if (value) {
28
28
  setHashValue(value);
29
29
  // 해시 제거 (주소창에서 #... 부분 삭제)
30
- // window.history.replaceState(null, '', window.location.pathname + window.location.search);
30
+ window.history.replaceState(null, '', window.location.pathname + window.location.search);
31
31
  }
32
32
  }
33
33
  }
@@ -40,7 +40,7 @@ const Daeryuntalk: React.FC<DaeryuntalkProps> = ({ tel = '1800-7905' }) => {
40
40
  setHashValue(value);
41
41
 
42
42
  // 해시 제거 (주소창에서 #... 부분 삭제)
43
- // window.history.replaceState(null, '', window.location.pathname + window.location.search);
43
+ window.history.replaceState(null, '', window.location.pathname + window.location.search);
44
44
  }
45
45
  }
46
46
  }