@daeryun/dr_components 0.7.87 → 0.7.88

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.
Files changed (43) hide show
  1. package/dist/components/Daeryuntalk/ChatButton.jsx +3 -1
  2. package/dist/components/Daeryuntalk/ChatButton.tsx +3 -1
  3. package/dist/components/Daeryuntalk/ChatConversation.jsx +23 -5
  4. package/dist/components/Daeryuntalk/ChatConversation.tsx +27 -5
  5. package/dist/components/Daeryuntalk/ChatHomeView.jsx +26 -11
  6. package/dist/components/Daeryuntalk/ChatHomeView.tsx +32 -9
  7. package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +21 -3
  8. package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +32 -11
  9. package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +69 -23
  10. package/dist/components/Daeryuntalk/History/AuthForm.d.ts +8 -0
  11. package/dist/components/Daeryuntalk/History/AuthForm.jsx +140 -0
  12. package/dist/components/Daeryuntalk/History/AuthForm.tsx +186 -0
  13. package/dist/components/Daeryuntalk/HistoryView.d.ts +6 -0
  14. package/dist/components/Daeryuntalk/HistoryView.jsx +49 -35
  15. package/dist/components/Daeryuntalk/HistoryView.tsx +78 -47
  16. package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +1 -1
  17. package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +1 -1
  18. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +29 -1
  19. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +98 -7
  20. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +136 -8
  21. package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.d.ts +13 -0
  22. package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.ts +17 -0
  23. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +3 -2
  24. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +76 -8
  25. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +88 -12
  26. package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.d.ts +24 -0
  27. package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.js +75 -0
  28. package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.ts +90 -0
  29. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +1 -0
  30. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +12 -2
  31. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +16 -2
  32. package/dist/components/Daeryuntalk/_lib/utils.d.ts +10 -0
  33. package/dist/components/Daeryuntalk/_lib/utils.js +25 -0
  34. package/dist/components/Daeryuntalk/_lib/utils.ts +39 -0
  35. package/dist/components/Daeryuntalk/_ui/buttons/Button2.d.ts +10 -0
  36. package/dist/components/Daeryuntalk/_ui/buttons/Button2.jsx +12 -0
  37. package/dist/components/Daeryuntalk/_ui/buttons/Button2.tsx +28 -0
  38. package/dist/components/Daeryuntalk/_ui/inputs/Input2.d.ts +13 -0
  39. package/dist/components/Daeryuntalk/_ui/inputs/Input2.jsx +9 -0
  40. package/dist/components/Daeryuntalk/_ui/inputs/Input2.tsx +42 -0
  41. package/dist/styles/globals.css +27 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +1 -1
@@ -7,7 +7,8 @@
7
7
  * 3. 웹소켓 연결
8
8
  * 4. 채팅 문의 관리
9
9
  */
10
- import { IDaeryunTalkResponseWrapper, WebSocketInitDataResponse, IChatInquiryMainDataResponse, ChatInquiryCreateDataResponse, ChatInquiryDetailDataResponse, SendMessageResponse, ChatInquiryMessageListDataResponse } from './type/response';
10
+ import { IDaeryunTalkResponseWrapper, WebSocketInitDataResponse, IChatInquiryMainDataResponse, ChatInquiryCreateDataResponse, ChatInquiryDetailDataResponse, SendMessageResponse, ChatInquiryMessageListDataResponse, HistoryListResponse, RequestConfirmNumberResponse } from './type/response';
11
+ export declare const DEFAULT_API_VERSION = "1.0.0";
11
12
  export declare const MESSAGE_TYPES: {
12
13
  SYSTEM: string;
13
14
  BOT: string;
@@ -131,3 +132,30 @@ export declare const getMessageFileDownloadUrl: ({ chatInquiryNumber, fileNumber
131
132
  }) => Promise<IDaeryunTalkResponseWrapper<{
132
133
  url: string;
133
134
  }>>;
135
+ /**
136
+ * 점유 인증 번호 요청
137
+ * @param name
138
+ * @param cellPhoneNumber
139
+ * @param version
140
+ */
141
+ export declare const requestPhone: ({ name, cellPhoneNumber, version }: {
142
+ name: string;
143
+ cellPhoneNumber: string;
144
+ version?: string;
145
+ }) => Promise<IDaeryunTalkResponseWrapper<RequestConfirmNumberResponse>>;
146
+ /**
147
+ * 점유 인증 번호 검증
148
+ * @param name
149
+ * @param cellPhoneNumber
150
+ * @param certificationNumber
151
+ * @param version
152
+ */
153
+ export declare const historyPhoneAuth: ({ name, cellPhoneNumber, certificationNumber, version }: {
154
+ name: string;
155
+ cellPhoneNumber: string;
156
+ certificationNumber: string;
157
+ version?: string;
158
+ }) => Promise<IDaeryunTalkResponseWrapper<unknown>>;
159
+ export declare const getHistoryList: ({ version }: {
160
+ version?: string;
161
+ }) => Promise<IDaeryunTalkResponseWrapper<HistoryListResponse>>;
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  // API 기본 URL
11
11
  const API_BASE_URL = 'https://chat-client-api.lawmance.com';
12
12
  // API 기본 버전
13
- const DEFAULT_API_VERSION = '1.0.0';
13
+ export const DEFAULT_API_VERSION = '1.0.0';
14
14
  // API 엔드포인트
15
15
  const ENDPOINTS = {
16
16
  /* 시작점 */
@@ -28,7 +28,11 @@ const ENDPOINTS = {
28
28
  CHAT_MESSAGE_WORKFLOW_START: '/chatctm/chi/chatinquiryworkflowprogress', // 채팅 문의 워크플로우 진행
29
29
  CHAT_MESSAGE_WORKFLOW_BACK: '/chatctm/chi/chatinquiryworkflowrollback', // 채팅 문의 워크플로우 되돌리기
30
30
  /* 유저 */
31
- USER_INFO_UPDATE: '/chatctm/chi/individualinformationupdate' //개인 정보 업데이트
31
+ USER_INFO_UPDATE: '/chatctm/chi/individualinformationupdate', //개인 정보 업데이트
32
+ /* 히스토리 */
33
+ HISTORY_PHONE_REQUEST: '/chatctm/his/occupancycertificationnumbersend', // 점유 인증 번호 요청
34
+ HISTORY_PHONE_AUTHENTICATION: '/chatctm/his/occupancycertificationnumberverification', // 점유 인증 번호 검증
35
+ HISTORY_LIST: '/chatctm/his/historychatinquirylistsearch' // 히스토리 채팅 문의 목록 조회
32
36
  };
33
37
  // 메인
34
38
  const TEST_CENTER_CODE = 'CT0000';
@@ -46,6 +50,7 @@ export const MESSAGE_TYPES = {
46
50
  function fetchWithCookies(url_1) {
47
51
  return __awaiter(this, arguments, void 0, function* (url, options = {}, version = DEFAULT_API_VERSION // 버전 매개변수 추가
48
52
  ) {
53
+ var _a;
49
54
  const headers = new Headers(options.headers || {});
50
55
  // Content-Type 헤더가 없으면 추가
51
56
  if (!headers.has('Content-Type')) {
@@ -75,16 +80,25 @@ function fetchWithCookies(url_1) {
75
80
  try {
76
81
  const response = yield fetch(url, mergedOptions);
77
82
  if (!response.ok) {
83
+ let errorData = null;
78
84
  // 400 에러 상세 정보 추출 시도
79
85
  try {
80
- const errorData = yield response.json();
86
+ errorData = yield response.json();
81
87
  console.error(`[API 오류] ${response.status} ${response.statusText}`, errorData);
82
- throw new Error(`API 오류: ${response.status} - ${response.statusText} - ${JSON.stringify(errorData)}`);
88
+ // throw new Error(`API 오류: ${response.status} - ${response.statusText} - ${JSON.stringify(errorData)}`);
83
89
  }
84
90
  catch (parseError) {
85
91
  console.error(`[API 오류] ${response.status} ${response.statusText} - 응답 파싱 실패`, parseError);
86
- throw new Error(`API 오류: ${response.status} - ${response.statusText}`);
92
+ // throw new Error(`API 오류: ${response.status} - ${response.statusText}`);
87
93
  }
94
+ return {
95
+ result_info: {
96
+ result_type_cd: 'ERROR',
97
+ result_cd: String(response.status),
98
+ result_msg: ((_a = errorData === null || errorData === void 0 ? void 0 : errorData.result_info) === null || _a === void 0 ? void 0 : _a.result_msg) || 'API 오류가 발생했습니다.'
99
+ },
100
+ data: null
101
+ };
88
102
  }
89
103
  // 응답 본문이 비어 있는지 확인
90
104
  const contentLength = response.headers.get('content-length');
@@ -308,8 +322,7 @@ export function getChatInquiryDetailNew(chat_inquiry_number, version) {
308
322
  return __awaiter(this, void 0, void 0, function* () {
309
323
  const body = {
310
324
  d: {
311
- chat_inquiry_number: chat_inquiry_number, // 채팅문의 번호
312
- size: 10
325
+ chat_inquiry_number: chat_inquiry_number // 채팅문의 번호
313
326
  }
314
327
  };
315
328
  console.log('[채팅 문의 상세 조회 시작 (개선)] 문의 번호:', chat_inquiry_number, version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
@@ -581,3 +594,81 @@ export const getMessageFileDownloadUrl = (_a) => __awaiter(void 0, [_a], void 0,
581
594
  throw error;
582
595
  }
583
596
  });
597
+ // /* 히스토리 */
598
+ // HISTORY_PHONE_REQUEST: '/chatctm/his/occupancycertificationnumbersend', // 점유 인증 번호 요청
599
+ // HISTORY_PHONE_AUTHENTICATION: '/chatctm/his/occupancycertificationnumberverification', // 점유 인증 번호 검증
600
+ // HISTORY_LIST: '/chatctm/his/historychatinquirylistsearch' // 히스토리 채팅 문의 목록 조회
601
+ /**
602
+ * 점유 인증 번호 요청
603
+ * @param name
604
+ * @param cellPhoneNumber
605
+ * @param version
606
+ */
607
+ export const requestPhone = (_a) => __awaiter(void 0, [_a], void 0, function* ({ name, cellPhoneNumber, version = DEFAULT_API_VERSION }) {
608
+ const consoleName = '점유 인증 번호 요청';
609
+ try {
610
+ const body = {
611
+ d: {
612
+ name: name, // required
613
+ cell_phone_number: cellPhoneNumber // required
614
+ }
615
+ };
616
+ console.log(`[${consoleName} 진행]`);
617
+ const response = yield fetchWithCookies(`${API_BASE_URL}${ENDPOINTS.HISTORY_PHONE_REQUEST}`, {
618
+ method: 'POST',
619
+ body: JSON.stringify(body)
620
+ }, version);
621
+ console.log(`[${consoleName} 완료]`, response);
622
+ return response;
623
+ }
624
+ catch (error) {
625
+ console.error(`[${consoleName} 실패] 오류:`, error);
626
+ throw error;
627
+ }
628
+ });
629
+ /**
630
+ * 점유 인증 번호 검증
631
+ * @param name
632
+ * @param cellPhoneNumber
633
+ * @param certificationNumber
634
+ * @param version
635
+ */
636
+ export const historyPhoneAuth = (_a) => __awaiter(void 0, [_a], void 0, function* ({ name, cellPhoneNumber, certificationNumber, version = DEFAULT_API_VERSION }) {
637
+ const consoleName = '점유 인증 번호 검증';
638
+ try {
639
+ const body = {
640
+ d: {
641
+ name: name, // required
642
+ cell_phone_number: cellPhoneNumber, // required
643
+ certification_number: certificationNumber // required
644
+ }
645
+ };
646
+ console.log(`[${consoleName} 진행]`);
647
+ const response = yield fetchWithCookies(`${API_BASE_URL}${ENDPOINTS.HISTORY_PHONE_AUTHENTICATION}`, {
648
+ method: 'POST',
649
+ body: JSON.stringify(body)
650
+ }, version);
651
+ console.log(`[${consoleName} 완료]`, response);
652
+ return response;
653
+ }
654
+ catch (error) {
655
+ console.error(`[${consoleName} 실패] 오류:`, error);
656
+ throw error;
657
+ }
658
+ });
659
+ export const getHistoryList = (_a) => __awaiter(void 0, [_a], void 0, function* ({ version = DEFAULT_API_VERSION }) {
660
+ const consoleName = '히스토리 채팅 문의 목록 조회';
661
+ try {
662
+ console.log(`[${consoleName} 진행]`);
663
+ const response = yield fetchWithCookies(`${API_BASE_URL}${ENDPOINTS.HISTORY_LIST}`, {
664
+ method: 'POST'
665
+ // body: JSON.stringify(body)
666
+ }, version);
667
+ console.log(`[${consoleName} 완료]`, response);
668
+ return response;
669
+ }
670
+ catch (error) {
671
+ console.error(`[${consoleName} 실패] 오류:`, error);
672
+ throw error;
673
+ }
674
+ });
@@ -16,14 +16,16 @@ import {
16
16
  ChatInquiryDetailDataResponse,
17
17
  ChatMessage,
18
18
  SendMessageResponse,
19
- ChatInquiryMessageListDataResponse
19
+ ChatInquiryMessageListDataResponse,
20
+ HistoryListResponse,
21
+ RequestConfirmNumberResponse
20
22
  } from './type/response';
21
23
 
22
24
  // API 기본 URL
23
25
  const API_BASE_URL = 'https://chat-client-api.lawmance.com';
24
26
 
25
27
  // API 기본 버전
26
- const DEFAULT_API_VERSION = '1.0.0';
28
+ export const DEFAULT_API_VERSION = '1.0.0';
27
29
 
28
30
  // API 엔드포인트
29
31
  const ENDPOINTS = {
@@ -42,7 +44,11 @@ const ENDPOINTS = {
42
44
  CHAT_MESSAGE_WORKFLOW_START: '/chatctm/chi/chatinquiryworkflowprogress', // 채팅 문의 워크플로우 진행
43
45
  CHAT_MESSAGE_WORKFLOW_BACK: '/chatctm/chi/chatinquiryworkflowrollback', // 채팅 문의 워크플로우 되돌리기
44
46
  /* 유저 */
45
- USER_INFO_UPDATE: '/chatctm/chi/individualinformationupdate' //개인 정보 업데이트
47
+ USER_INFO_UPDATE: '/chatctm/chi/individualinformationupdate', //개인 정보 업데이트
48
+ /* 히스토리 */
49
+ HISTORY_PHONE_REQUEST: '/chatctm/his/occupancycertificationnumbersend', // 점유 인증 번호 요청
50
+ HISTORY_PHONE_AUTHENTICATION: '/chatctm/his/occupancycertificationnumberverification', // 점유 인증 번호 검증
51
+ HISTORY_LIST: '/chatctm/his/historychatinquirylistsearch' // 히스토리 채팅 문의 목록 조회
46
52
  };
47
53
 
48
54
  // 메인
@@ -107,15 +113,26 @@ async function fetchWithCookies<T>(
107
113
  const response = await fetch(url, mergedOptions);
108
114
 
109
115
  if (!response.ok) {
116
+ let errorData: any = null;
117
+
110
118
  // 400 에러 상세 정보 추출 시도
111
119
  try {
112
- const errorData = await response.json();
120
+ errorData = await response.json();
113
121
  console.error(`[API 오류] ${response.status} ${response.statusText}`, errorData);
114
- throw new Error(`API 오류: ${response.status} - ${response.statusText} - ${JSON.stringify(errorData)}`);
122
+ // throw new Error(`API 오류: ${response.status} - ${response.statusText} - ${JSON.stringify(errorData)}`);
115
123
  } catch (parseError) {
116
124
  console.error(`[API 오류] ${response.status} ${response.statusText} - 응답 파싱 실패`, parseError);
117
- throw new Error(`API 오류: ${response.status} - ${response.statusText}`);
125
+ // throw new Error(`API 오류: ${response.status} - ${response.statusText}`);
118
126
  }
127
+
128
+ return {
129
+ result_info: {
130
+ result_type_cd: 'ERROR',
131
+ result_cd: String(response.status),
132
+ result_msg: errorData?.result_info?.result_msg || 'API 오류가 발생했습니다.'
133
+ },
134
+ data: null
135
+ } as T;
119
136
  }
120
137
 
121
138
  // 응답 본문이 비어 있는지 확인
@@ -383,8 +400,7 @@ export async function getChatInquiryDetailNew(
383
400
  ): Promise<IDaeryunTalkResponseWrapper<ChatInquiryDetailDataResponse>> {
384
401
  const body = {
385
402
  d: {
386
- chat_inquiry_number: chat_inquiry_number, // 채팅문의 번호
387
- size: 10
403
+ chat_inquiry_number: chat_inquiry_number // 채팅문의 번호
388
404
  }
389
405
  };
390
406
 
@@ -769,3 +785,115 @@ export const getMessageFileDownloadUrl = async ({
769
785
  throw error;
770
786
  }
771
787
  };
788
+
789
+ // /* 히스토리 */
790
+ // HISTORY_PHONE_REQUEST: '/chatctm/his/occupancycertificationnumbersend', // 점유 인증 번호 요청
791
+ // HISTORY_PHONE_AUTHENTICATION: '/chatctm/his/occupancycertificationnumberverification', // 점유 인증 번호 검증
792
+ // HISTORY_LIST: '/chatctm/his/historychatinquirylistsearch' // 히스토리 채팅 문의 목록 조회
793
+
794
+ /**
795
+ * 점유 인증 번호 요청
796
+ * @param name
797
+ * @param cellPhoneNumber
798
+ * @param version
799
+ */
800
+ export const requestPhone = async ({
801
+ name,
802
+ cellPhoneNumber,
803
+ version = DEFAULT_API_VERSION
804
+ }: {
805
+ name: string; // required
806
+ cellPhoneNumber: string;
807
+ version?: string;
808
+ }) => {
809
+ const consoleName = '점유 인증 번호 요청';
810
+ try {
811
+ const body = {
812
+ d: {
813
+ name: name, // required
814
+ cell_phone_number: cellPhoneNumber // required
815
+ }
816
+ };
817
+ console.log(`[${consoleName} 진행]`);
818
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<RequestConfirmNumberResponse>>(
819
+ `${API_BASE_URL}${ENDPOINTS.HISTORY_PHONE_REQUEST}`,
820
+ {
821
+ method: 'POST',
822
+ body: JSON.stringify(body)
823
+ },
824
+ version
825
+ );
826
+
827
+ console.log(`[${consoleName} 완료]`, response);
828
+ return response;
829
+ } catch (error) {
830
+ console.error(`[${consoleName} 실패] 오류:`, error);
831
+ throw error;
832
+ }
833
+ };
834
+
835
+ /**
836
+ * 점유 인증 번호 검증
837
+ * @param name
838
+ * @param cellPhoneNumber
839
+ * @param certificationNumber
840
+ * @param version
841
+ */
842
+ export const historyPhoneAuth = async ({
843
+ name,
844
+ cellPhoneNumber,
845
+ certificationNumber,
846
+ version = DEFAULT_API_VERSION
847
+ }: {
848
+ name: string; // required
849
+ cellPhoneNumber: string;
850
+ certificationNumber: string;
851
+ version?: string;
852
+ }) => {
853
+ const consoleName = '점유 인증 번호 검증';
854
+ try {
855
+ const body = {
856
+ d: {
857
+ name: name, // required
858
+ cell_phone_number: cellPhoneNumber, // required
859
+ certification_number: certificationNumber // required
860
+ }
861
+ };
862
+ console.log(`[${consoleName} 진행]`);
863
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<unknown>>(
864
+ `${API_BASE_URL}${ENDPOINTS.HISTORY_PHONE_AUTHENTICATION}`,
865
+ {
866
+ method: 'POST',
867
+ body: JSON.stringify(body)
868
+ },
869
+ version
870
+ );
871
+
872
+ console.log(`[${consoleName} 완료]`, response);
873
+ return response;
874
+ } catch (error) {
875
+ console.error(`[${consoleName} 실패] 오류:`, error);
876
+ throw error;
877
+ }
878
+ };
879
+
880
+ export const getHistoryList = async ({ version = DEFAULT_API_VERSION }: { version?: string }) => {
881
+ const consoleName = '히스토리 채팅 문의 목록 조회';
882
+ try {
883
+ console.log(`[${consoleName} 진행]`);
884
+ const response = await fetchWithCookies<IDaeryunTalkResponseWrapper<HistoryListResponse>>(
885
+ `${API_BASE_URL}${ENDPOINTS.HISTORY_LIST}`,
886
+ {
887
+ method: 'POST'
888
+ // body: JSON.stringify(body)
889
+ },
890
+ version
891
+ );
892
+
893
+ console.log(`[${consoleName} 완료]`, response);
894
+ return response;
895
+ } catch (error) {
896
+ console.error(`[${consoleName} 실패] 오류:`, error);
897
+ throw error;
898
+ }
899
+ };
@@ -114,3 +114,16 @@ export interface ChatInquiryMessageListDataResponse {
114
114
  message_list: ChatMessage[];
115
115
  next_page_yn: boolean;
116
116
  }
117
+ export interface History {
118
+ chat_inquiry_number: string;
119
+ customer_name: string;
120
+ recent_message_content: string;
121
+ recent_message_date_time: string;
122
+ unread_message_count: number;
123
+ }
124
+ export interface HistoryListResponse {
125
+ chat_inquiry_list: History[];
126
+ }
127
+ export interface RequestConfirmNumberResponse {
128
+ temp_number: string;
129
+ }
@@ -134,3 +134,20 @@ export interface ChatInquiryMessageListDataResponse {
134
134
  message_list: ChatMessage[];
135
135
  next_page_yn: boolean;
136
136
  }
137
+
138
+ export interface History {
139
+ chat_inquiry_number: string; // 채팅문의번호
140
+ customer_name: string; // 고객명
141
+ recent_message_content: string; // 최근메시지내용
142
+ recent_message_date_time: string; // 최근메시지일시 (ISO 8601 등의 문자열 형식)
143
+ unread_message_count: number; // 안읽은메시지개수
144
+ }
145
+
146
+ //
147
+ export interface HistoryListResponse {
148
+ chat_inquiry_list: History[];
149
+ }
150
+
151
+ export interface RequestConfirmNumberResponse {
152
+ temp_number: string;
153
+ }
@@ -12,9 +12,9 @@ interface props {
12
12
  chatInquiryNumber: string | null;
13
13
  setIsNextPage: Dispatch<SetStateAction<boolean | null>>;
14
14
  setWorkFlowStack: Dispatch<SetStateAction<string[]>>;
15
- sendInquiryJoined: (chatInquiryNumber: string) => void;
15
+ setInquiryMainData: Dispatch<SetStateAction<IChatInquiryMainDataResponse | null>>;
16
16
  }
17
- export declare const useChatHandler: ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, sendInquiryJoined }: props) => {
17
+ export declare const useChatHandler: ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, setInquiryMainData }: props) => {
18
18
  startChat: () => Promise<string>;
19
19
  sendMessage: (htmlContent: string, jsonData: any, retry?: boolean) => Promise<void>;
20
20
  createNewChat: (version?: string) => Promise<void>;
@@ -42,5 +42,6 @@ export declare const useChatHandler: ({ setIsLoading, inquiryMainData, setChatIn
42
42
  }) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<{
43
43
  url: string;
44
44
  }>>;
45
+ startSelectedChat: (chatInquiryNumber: string) => Promise<string>;
45
46
  };
46
47
  export {};
@@ -10,9 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { useCallback } from 'react';
11
11
  import { chatUserUpdate as apiChatUserUpdate, chatWorkFlow, chatWorkFlowBack, generateChatInquiry, getChatInquiryDetailNew, getChatInquiryMessageList, getMessageFileDownloadUrl, sendChatMessage } from '../../_api';
12
12
  import { convertApiMessageObjectToUiMessageObject, convertApiMessageToUiMessage } from '../../_lib';
13
- export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack,
14
- //
15
- sendInquiryJoined }) => {
13
+ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, setInquiryMainData }) => {
16
14
  // 채팅 시작 (문의하기 버튼 클릭 시)
17
15
  const startChat = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
18
16
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
@@ -52,8 +50,6 @@ sendInquiryJoined }) => {
52
50
  console.log('detailResponse.data.message_list', (_a = chatList === null || chatList === void 0 ? void 0 : chatList.data) === null || _a === void 0 ? void 0 : _a.message_list);
53
51
  // 메시지 처리
54
52
  if (detailResponse.data && chatList.data) {
55
- // 해당 무의 입장 소켓1
56
- sendInquiryJoined(currentChatInquiryNumber);
57
53
  // 메세지 리스트 후처리
58
54
  if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.message_list) && chatList.data.message_list.length > 0) {
59
55
  const uiMessages = chatList.data.message_list
@@ -105,6 +101,78 @@ sendInquiryJoined }) => {
105
101
  setIsLoading(false);
106
102
  }
107
103
  }), [inquiryMainData]);
104
+ // 선택된 히스토리의 채팅창 시작
105
+ const startSelectedChat = useCallback((chatInquiryNumber) => __awaiter(void 0, void 0, void 0, function* () {
106
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
107
+ try {
108
+ setIsLoading(true);
109
+ // 문의 상세 조회
110
+ const detailResponse = yield getChatInquiryDetailNew(chatInquiryNumber);
111
+ console.log('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
112
+ const chatList = yield getChatInquiryMessageList(chatInquiryNumber);
113
+ console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
114
+ console.log('detailResponse.data.message_list', (_a = chatList === null || chatList === void 0 ? void 0 : chatList.data) === null || _a === void 0 ? void 0 : _a.message_list);
115
+ // 메시지 처리
116
+ if (detailResponse.data && chatList.data) {
117
+ // 문의 정보 저장
118
+ setChatInquiryNumber(chatInquiryNumber);
119
+ //
120
+ setInquiryMainData(prev => {
121
+ if (prev) {
122
+ return Object.assign(Object.assign({}, prev), { progress_inquiry_number: chatInquiryNumber });
123
+ }
124
+ else {
125
+ return null;
126
+ }
127
+ });
128
+ // 메세지 리스트 후처리
129
+ if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.message_list) && chatList.data.message_list.length > 0) {
130
+ const uiMessages = chatList.data.message_list
131
+ .sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
132
+ .map(convertApiMessageToUiMessage);
133
+ setMessages(uiMessages);
134
+ // const uiMessages = chatList.data.message_list.map(convertApiMessageToUiMessage);
135
+ setMessages(uiMessages);
136
+ console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
137
+ }
138
+ if (((_c = chatList.data) === null || _c === void 0 ? void 0 : _c.next_page_yn) !== null) {
139
+ setIsNextPage(chatList.data.next_page_yn);
140
+ }
141
+ // 해당 문의 상태
142
+ if ((_d = detailResponse.data) === null || _d === void 0 ? void 0 : _d.chat_inquiry_state_code) {
143
+ setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
144
+ }
145
+ // 해당 문의 오브젝트
146
+ if ((_e = detailResponse.data) === null || _e === void 0 ? void 0 : _e.object_expose_info) {
147
+ const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
148
+ setMessageObject(uiObject);
149
+ }
150
+ // 해당 문의 상태
151
+ if ((_f = detailResponse.data) === null || _f === void 0 ? void 0 : _f.chat_inquiry_state_code) {
152
+ setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
153
+ }
154
+ // 워크플로우 스택 업데이트
155
+ if ((_g = detailResponse.data) === null || _g === void 0 ? void 0 : _g.work_flow_progress_stack) {
156
+ setWorkFlowStack((_j = (_h = detailResponse.data) === null || _h === void 0 ? void 0 : _h.work_flow_progress_stack) !== null && _j !== void 0 ? _j : []);
157
+ }
158
+ }
159
+ else {
160
+ setMessages([]);
161
+ setInquiryStatus('');
162
+ setMessageObject(null);
163
+ setIsNextPage(null);
164
+ console.log('[DaeryuntalkContext] 메시지 없음');
165
+ }
166
+ return chatInquiryNumber;
167
+ }
168
+ catch (error) {
169
+ console.error('[DaeryuntalkContext] 채팅 시작 오류:', error);
170
+ throw error;
171
+ }
172
+ finally {
173
+ setIsLoading(false);
174
+ }
175
+ }), [inquiryMainData]);
108
176
  // 메시지 전송
109
177
  const sendMessage = useCallback((htmlContent, jsonData, retry) => __awaiter(void 0, void 0, void 0, function* () {
110
178
  try {
@@ -142,8 +210,7 @@ sendInquiryJoined }) => {
142
210
  console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
143
211
  // 메시지 처리
144
212
  if (detailResponse.data && chatList.data) {
145
- // 해당 무의 입장 소켓
146
- sendInquiryJoined(currentChatInquiryNumber);
213
+ setChatInquiryNumber(currentChatInquiryNumber);
147
214
  // 메세지 리스트 후처리
148
215
  if (((_a = chatList.data) === null || _a === void 0 ? void 0 : _a.message_list) && chatList.data.message_list.length > 0) {
149
216
  const uiMessages = chatList.data.message_list
@@ -291,6 +358,7 @@ sendInquiryJoined }) => {
291
358
  workFlowBack,
292
359
  chatUserUpdate,
293
360
  getNextMessageList,
294
- getDownLoadUrl
361
+ getDownLoadUrl,
362
+ startSelectedChat
295
363
  };
296
364
  };