@daeryun/dr_components 0.8.47 → 0.8.48

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 (120) hide show
  1. package/dist/asset/images/daeryuntalk/close.svg +2 -2
  2. package/dist/asset/images/daeryuntalk/time.svg +2 -2
  3. package/dist/asset/images/daeryuntalk/viewer/zoom-out.svg +2 -4
  4. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  5. package/dist/components/Daeryuntalk/ChatButton.jsx +5 -2
  6. package/dist/components/Daeryuntalk/ChatButton.tsx +5 -2
  7. package/dist/components/Daeryuntalk/ChatConversation.d.ts +2 -0
  8. package/dist/components/Daeryuntalk/ChatConversation.jsx +22 -63
  9. package/dist/components/Daeryuntalk/ChatConversation.tsx +42 -79
  10. package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.d.ts +11 -0
  11. package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.jsx +27 -0
  12. package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.tsx +57 -0
  13. package/dist/components/Daeryuntalk/ChatHomeView.d.ts +3 -2
  14. package/dist/components/Daeryuntalk/ChatHomeView.jsx +59 -181
  15. package/dist/components/Daeryuntalk/ChatHomeView.tsx +102 -206
  16. package/dist/components/Daeryuntalk/ChatItem/ChatFile.jsx +15 -14
  17. package/dist/components/Daeryuntalk/ChatItem/ChatFile.tsx +15 -14
  18. package/dist/components/Daeryuntalk/ChatItem/ChatLoading.d.ts +3 -0
  19. package/dist/components/Daeryuntalk/ChatItem/ChatLoading.jsx +11 -0
  20. package/dist/components/Daeryuntalk/ChatItem/ChatLoading.tsx +21 -0
  21. package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.jsx +4 -4
  22. package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.tsx +4 -4
  23. package/dist/components/Daeryuntalk/ChatItem/RichText.jsx +2 -1
  24. package/dist/components/Daeryuntalk/ChatItem/RichText.tsx +2 -1
  25. package/dist/components/Daeryuntalk/ChatItem/TimeWrapper.d.ts +9 -0
  26. package/dist/components/Daeryuntalk/ChatItem/TimeWrapper.jsx +9 -0
  27. package/dist/components/Daeryuntalk/ChatItem/TimeWrapper.tsx +20 -0
  28. package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.jsx +3 -3
  29. package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.tsx +3 -3
  30. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.jsx +2 -2
  31. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.tsx +2 -2
  32. package/dist/components/Daeryuntalk/ChatMessage.d.ts +1 -0
  33. package/dist/components/Daeryuntalk/ChatMessage.jsx +31 -36
  34. package/dist/components/Daeryuntalk/ChatMessage.tsx +34 -38
  35. package/dist/components/Daeryuntalk/ChatObject/FieldWorkObject.jsx +2 -2
  36. package/dist/components/Daeryuntalk/ChatObject/FieldWorkObject.tsx +2 -2
  37. package/dist/components/Daeryuntalk/ChatObject/ObjectBack.jsx +1 -1
  38. package/dist/components/Daeryuntalk/ChatObject/ObjectBack.tsx +1 -1
  39. package/dist/components/Daeryuntalk/ChatObject/ObjectButton.jsx +6 -23
  40. package/dist/components/Daeryuntalk/ChatObject/ObjectButton.tsx +6 -23
  41. package/dist/components/Daeryuntalk/ChatWidget.jsx +60 -23
  42. package/dist/components/Daeryuntalk/ChatWidget.tsx +72 -34
  43. package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +2 -2
  44. package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +2 -2
  45. package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +5 -5
  46. package/dist/components/Daeryuntalk/DateSeparator.jsx +2 -2
  47. package/dist/components/Daeryuntalk/DateSeparator.tsx +2 -2
  48. package/dist/components/Daeryuntalk/FixedErrorBox.d.ts +7 -0
  49. package/dist/components/Daeryuntalk/FixedErrorBox.jsx +33 -0
  50. package/dist/components/Daeryuntalk/FixedErrorBox.tsx +73 -0
  51. package/dist/components/Daeryuntalk/History/AuthForm.d.ts +3 -1
  52. package/dist/components/Daeryuntalk/History/AuthForm.jsx +15 -45
  53. package/dist/components/Daeryuntalk/History/AuthForm.tsx +21 -53
  54. package/dist/components/Daeryuntalk/HistoryView.d.ts +4 -0
  55. package/dist/components/Daeryuntalk/HistoryView.jsx +17 -40
  56. package/dist/components/Daeryuntalk/HistoryView.tsx +36 -48
  57. package/dist/components/Daeryuntalk/HomeView.d.ts +12 -0
  58. package/dist/components/Daeryuntalk/HomeView.jsx +102 -0
  59. package/dist/components/Daeryuntalk/HomeView.tsx +150 -0
  60. package/dist/components/Daeryuntalk/NavigationFooter.jsx +17 -10
  61. package/dist/components/Daeryuntalk/NavigationFooter.tsx +22 -12
  62. package/dist/components/Daeryuntalk/NoticeMessage.jsx +7 -7
  63. package/dist/components/Daeryuntalk/NoticeMessage.tsx +7 -7
  64. package/dist/components/Daeryuntalk/Toast/ToastRender.jsx +1 -1
  65. package/dist/components/Daeryuntalk/Toast/ToastRender.tsx +2 -2
  66. package/dist/components/Daeryuntalk/Viewer/ImageViewer.d.ts +6 -0
  67. package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +18 -90
  68. package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +49 -135
  69. package/dist/components/Daeryuntalk/Viewer/MobileViewer.d.ts +16 -0
  70. package/dist/components/Daeryuntalk/Viewer/MobileViewer.jsx +66 -0
  71. package/dist/components/Daeryuntalk/Viewer/MobileViewer.tsx +121 -0
  72. package/dist/components/Daeryuntalk/Viewer/TbPcViewer.d.ts +22 -0
  73. package/dist/components/Daeryuntalk/Viewer/TbPcViewer.jsx +104 -0
  74. package/dist/components/Daeryuntalk/Viewer/TbPcViewer.tsx +195 -0
  75. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +4 -3
  76. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +81 -105
  77. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +105 -121
  78. package/dist/components/Daeryuntalk/_enums/ask-status.d.ts +7 -0
  79. package/dist/components/Daeryuntalk/_enums/ask-status.js +14 -0
  80. package/dist/components/Daeryuntalk/_enums/ask-status.ts +14 -0
  81. package/dist/components/Daeryuntalk/_enums/error.d.ts +3 -0
  82. package/dist/components/Daeryuntalk/_enums/error.js +125 -0
  83. package/dist/components/Daeryuntalk/_enums/error.ts +143 -0
  84. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +8 -8
  85. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +227 -179
  86. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +261 -185
  87. package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.d.ts +1 -1
  88. package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.js +54 -18
  89. package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.ts +68 -15
  90. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +2 -2
  91. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +8 -7
  92. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +13 -6
  93. package/dist/components/Daeryuntalk/_hooks/view/useChatSocketState.d.ts +2 -0
  94. package/dist/components/Daeryuntalk/_hooks/{talkprovider → view}/useChatSocketState.js +7 -1
  95. package/dist/components/Daeryuntalk/_hooks/{talkprovider → view}/useChatSocketState.ts +13 -1
  96. package/dist/components/Daeryuntalk/_hooks/view/useHistoryView.d.ts +26 -0
  97. package/dist/components/Daeryuntalk/_hooks/view/useHistoryView.js +72 -0
  98. package/dist/components/Daeryuntalk/_hooks/view/useHistoryView.ts +93 -0
  99. package/dist/components/Daeryuntalk/_hooks/view/useHomeView.d.ts +16 -0
  100. package/dist/components/Daeryuntalk/_hooks/view/useHomeView.js +61 -0
  101. package/dist/components/Daeryuntalk/_hooks/view/useHomeView.ts +64 -0
  102. package/dist/components/Daeryuntalk/_lib/utils.d.ts +1 -0
  103. package/dist/components/Daeryuntalk/_lib/utils.js +27 -0
  104. package/dist/components/Daeryuntalk/_lib/utils.ts +33 -0
  105. package/dist/components/Daeryuntalk/_ui/buttons/Button2.jsx +3 -3
  106. package/dist/components/Daeryuntalk/_ui/buttons/Button2.tsx +3 -3
  107. package/dist/components/Daeryuntalk/_ui/buttons/Button3.d.ts +10 -0
  108. package/dist/components/Daeryuntalk/_ui/buttons/Button3.jsx +12 -0
  109. package/dist/components/Daeryuntalk/_ui/buttons/Button3.tsx +29 -0
  110. package/dist/components/Daeryuntalk/_ui/inputs/Input2.jsx +2 -1
  111. package/dist/components/Daeryuntalk/_ui/inputs/Input2.tsx +2 -1
  112. package/dist/components/Daeryuntalk/index.jsx +1 -1
  113. package/dist/components/Daeryuntalk/index.tsx +12 -1
  114. package/dist/styles/globals.css +510 -168
  115. package/dist/tsconfig.tsbuildinfo +1 -1
  116. package/package.json +1 -1
  117. package/dist/components/Daeryuntalk/_enums/error_code.d.ts +0 -21
  118. package/dist/components/Daeryuntalk/_enums/error_code.js +0 -23
  119. package/dist/components/Daeryuntalk/_enums/error_code.ts +0 -22
  120. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.d.ts +0 -1
@@ -12,16 +12,23 @@ import { attendChatRoomByHistory, chatUserUpdate as apiChatUserUpdate, chatWorkF
12
12
  import { convertApiMessageObjectToUiMessageObject, convertApiMessageToUiMessage } from '../../_lib';
13
13
  import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
14
14
  import { useFullURL } from './useFullURL';
15
+ import { getErrorMessageMap } from '../../_enums/error';
15
16
  export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, setInquiryMainData }) => {
16
17
  const toast = useDaeryunTalkToast();
17
18
  const fullUrl = useFullURL();
19
+ const resetData = useCallback(() => {
20
+ setMessages([]);
21
+ setInquiryStatus('');
22
+ setMessageObject(null);
23
+ setIsNextPage(null);
24
+ }, []);
25
+ // const resetData = () => {};
18
26
  // 채팅 시작 (문의하기 버튼 클릭 시)
19
27
  const startChat = useCallback((inquiryNumber) => __awaiter(void 0, void 0, void 0, function* () {
20
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
28
+ var _a, _b, _c, _d, _e, _f, _g, _h;
21
29
  try {
22
30
  setIsLoading(true);
23
31
  console.log('[DaeryuntalkContext] 채팅 시작 요청');
24
- console.log('inquiryMainData', inquiryMainData);
25
32
  // 기존 문의가 있는지 확인
26
33
  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()) !== '';
27
34
  let currentChatInquiryNumber = '';
@@ -36,67 +43,63 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
36
43
  // 새 문의 생성
37
44
  console.log('[DaeryuntalkContext] 새 문의 생성 시작');
38
45
  const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '', fullUrl);
39
- if (createResponse && createResponse.data && createResponse.data.chat_inquiry_number) {
40
- currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
41
- console.log('[DaeryuntalkContext] 새 문의 생성 완료:', currentChatInquiryNumber);
42
- }
43
- else {
44
- console.error('[DaeryuntalkContext] 문의 생성 실패: 문의번호 없음');
45
- throw new Error('문의 생성 실패');
46
+ if (!(createResponse.result_info.result_cd === 'OK' ||
47
+ createResponse.result_info.result_type_cd === 'OK')) {
48
+ resetData();
49
+ toast.error(getErrorMessageMap(createResponse));
50
+ return createResponse;
46
51
  }
52
+ currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
47
53
  }
48
54
  // 문의 상세 조회
49
55
  console.log('[DaeryuntalkContext] 문의 상세 조회 시작:', currentChatInquiryNumber);
50
56
  const detailResponse = yield getChatInquiryDetailNew(currentChatInquiryNumber);
57
+ if (!(detailResponse.result_info.result_cd === 'OK' ||
58
+ detailResponse.result_info.result_type_cd === 'OK')) {
59
+ resetData();
60
+ toast.error(getErrorMessageMap(detailResponse));
61
+ return detailResponse;
62
+ }
51
63
  console.log('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
52
64
  console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 시작:', currentChatInquiryNumber);
53
65
  const chatList = yield getChatInquiryMessageList(currentChatInquiryNumber);
66
+ if (!(chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK')) {
67
+ resetData();
68
+ toast.error(getErrorMessageMap(chatList));
69
+ return chatList;
70
+ }
54
71
  console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
55
72
  // 문의 정보 저장
56
73
  setChatInquiryNumber(currentChatInquiryNumber);
57
74
  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);
58
75
  // 메시지 처리
59
- if (detailResponse.data && chatList.data) {
60
- // 메세지 리스트 후처리
61
- if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.message_list) && chatList.data.message_list.length > 0) {
62
- const uiMessages = chatList.data.message_list
63
- .sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
64
- .map(convertApiMessageToUiMessage);
65
- // const uiMessages = chatList.data.message_list
66
- // .sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime())
67
- // .map(convertApiMessageToUiMessage);
68
- setMessages(uiMessages);
69
- // const uiMessages = chatList.data.message_list.map(convertApiMessageToUiMessage);
70
- setMessages(uiMessages);
71
- console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
72
- }
73
- if (((_c = chatList.data) === null || _c === void 0 ? void 0 : _c.next_page_yn) !== null) {
74
- setIsNextPage(chatList.data.next_page_yn);
75
- }
76
- // 해당 문의 상태
77
- if ((_d = detailResponse.data) === null || _d === void 0 ? void 0 : _d.chat_inquiry_state_code) {
78
- setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
79
- }
80
- // 해당 문의 오브젝트
81
- if ((_e = detailResponse.data) === null || _e === void 0 ? void 0 : _e.object_expose_info) {
82
- const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
83
- setMessageObject(uiObject);
84
- }
85
- // 해당 문의 상태
86
- if ((_f = detailResponse.data) === null || _f === void 0 ? void 0 : _f.chat_inquiry_state_code) {
87
- setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
88
- }
89
- // 워크플로우 스택 업데이트
90
- if ((_g = detailResponse.data) === null || _g === void 0 ? void 0 : _g.work_flow_progress_stack) {
91
- setWorkFlowStack((_j = (_h = detailResponse.data) === null || _h === void 0 ? void 0 : _h.work_flow_progress_stack) !== null && _j !== void 0 ? _j : []);
92
- }
76
+ // 메세지 리스트 후처리
77
+ if (chatList.data.message_list.length > 0) {
78
+ const uiMessages = chatList.data.message_list
79
+ .sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
80
+ .map(convertApiMessageToUiMessage);
81
+ setMessages(uiMessages);
82
+ console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
93
83
  }
94
- else {
95
- setMessages([]);
96
- setInquiryStatus('');
97
- setMessageObject(null);
98
- setIsNextPage(null);
99
- console.log('[DaeryuntalkContext] 메시지 없음');
84
+ if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.next_page_yn) !== null) {
85
+ setIsNextPage(chatList.data.next_page_yn);
86
+ }
87
+ // 해당 문의 상태
88
+ if ((_c = detailResponse.data) === null || _c === void 0 ? void 0 : _c.chat_inquiry_state_code) {
89
+ setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
90
+ }
91
+ // 해당 문의 오브젝트
92
+ if ((_d = detailResponse.data) === null || _d === void 0 ? void 0 : _d.object_expose_info) {
93
+ const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
94
+ setMessageObject(uiObject);
95
+ }
96
+ // 해당 문의 상태
97
+ if ((_e = detailResponse.data) === null || _e === void 0 ? void 0 : _e.chat_inquiry_state_code) {
98
+ setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
99
+ }
100
+ // 워크플로우 스택 업데이트
101
+ if ((_f = detailResponse.data) === null || _f === void 0 ? void 0 : _f.work_flow_progress_stack) {
102
+ setWorkFlowStack((_h = (_g = detailResponse.data) === null || _g === void 0 ? void 0 : _g.work_flow_progress_stack) !== null && _h !== void 0 ? _h : []);
100
103
  }
101
104
  return currentChatInquiryNumber;
102
105
  }
@@ -112,65 +115,67 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
112
115
  }), [inquiryMainData, fullUrl]);
113
116
  // 선택된 히스토리의 채팅창 시작
114
117
  const startSelectedChat = useCallback((chatInquiryNumber) => __awaiter(void 0, void 0, void 0, function* () {
115
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
118
+ var _a, _b, _c, _d, _e, _f, _g, _h;
116
119
  try {
117
120
  setIsLoading(true);
118
121
  // 문의 상세 조회
119
122
  const detailResponse = yield getChatInquiryDetailNew(chatInquiryNumber);
123
+ if (!(detailResponse.result_info.result_cd === 'OK' ||
124
+ detailResponse.result_info.result_type_cd === 'OK')) {
125
+ resetData();
126
+ toast.error(getErrorMessageMap(detailResponse));
127
+ return detailResponse;
128
+ }
120
129
  console.log('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
121
130
  const chatList = yield getChatInquiryMessageList(chatInquiryNumber);
122
131
  console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
132
+ if (!(chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK')) {
133
+ resetData();
134
+ toast.error(getErrorMessageMap(chatList));
135
+ return chatList;
136
+ }
123
137
  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);
124
138
  // 메시지 처리
125
- if (detailResponse.data && chatList.data) {
126
- // 문의 정보 저장
127
- setChatInquiryNumber(chatInquiryNumber);
128
- //
129
- setInquiryMainData(prev => {
130
- if (prev) {
131
- return Object.assign(Object.assign({}, prev), { progress_inquiry_number: chatInquiryNumber });
132
- }
133
- else {
134
- return null;
135
- }
136
- });
137
- // 메세지 리스트 후처리
138
- if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.message_list) && chatList.data.message_list.length > 0) {
139
- const uiMessages = chatList.data.message_list
140
- .sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
141
- .map(convertApiMessageToUiMessage);
142
- setMessages(uiMessages);
143
- // const uiMessages = chatList.data.message_list.map(convertApiMessageToUiMessage);
144
- setMessages(uiMessages);
145
- console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
146
- }
147
- if (((_c = chatList.data) === null || _c === void 0 ? void 0 : _c.next_page_yn) !== null) {
148
- setIsNextPage(chatList.data.next_page_yn);
149
- }
150
- // 해당 문의 상태
151
- if ((_d = detailResponse.data) === null || _d === void 0 ? void 0 : _d.chat_inquiry_state_code) {
152
- setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
153
- }
154
- // 해당 문의 오브젝트
155
- if ((_e = detailResponse.data) === null || _e === void 0 ? void 0 : _e.object_expose_info) {
156
- const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
157
- setMessageObject(uiObject);
158
- }
159
- // 해당 문의 상태
160
- if ((_f = detailResponse.data) === null || _f === void 0 ? void 0 : _f.chat_inquiry_state_code) {
161
- setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
139
+ // 문의 정보 저장
140
+ setChatInquiryNumber(chatInquiryNumber);
141
+ //
142
+ setInquiryMainData(prev => {
143
+ if (prev) {
144
+ return Object.assign(Object.assign({}, prev), { progress_inquiry_number: chatInquiryNumber });
162
145
  }
163
- // 워크플로우 스택 업데이트
164
- if ((_g = detailResponse.data) === null || _g === void 0 ? void 0 : _g.work_flow_progress_stack) {
165
- setWorkFlowStack((_j = (_h = detailResponse.data) === null || _h === void 0 ? void 0 : _h.work_flow_progress_stack) !== null && _j !== void 0 ? _j : []);
146
+ else {
147
+ return null;
166
148
  }
149
+ });
150
+ // 메세지 리스트 후처리
151
+ if (chatList.data.message_list.length > 0) {
152
+ const uiMessages = chatList.data.message_list
153
+ .sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
154
+ .map(convertApiMessageToUiMessage);
155
+ setMessages(uiMessages);
156
+ // const uiMessages = chatList.data.message_list.map(convertApiMessageToUiMessage);
157
+ setMessages(uiMessages);
158
+ console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
167
159
  }
168
- else {
169
- setMessages([]);
170
- setInquiryStatus('');
171
- setMessageObject(null);
172
- setIsNextPage(null);
173
- console.log('[DaeryuntalkContext] 메시지 없음');
160
+ if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.next_page_yn) !== null) {
161
+ setIsNextPage(chatList.data.next_page_yn);
162
+ }
163
+ // 해당 문의 상태
164
+ if ((_c = detailResponse.data) === null || _c === void 0 ? void 0 : _c.chat_inquiry_state_code) {
165
+ setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
166
+ }
167
+ // 해당 문의 오브젝트
168
+ if ((_d = detailResponse.data) === null || _d === void 0 ? void 0 : _d.object_expose_info) {
169
+ const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
170
+ setMessageObject(uiObject);
171
+ }
172
+ // 해당 문의 상태
173
+ if ((_e = detailResponse.data) === null || _e === void 0 ? void 0 : _e.chat_inquiry_state_code) {
174
+ setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
175
+ }
176
+ // 워크플로우 스택 업데이트
177
+ if ((_f = detailResponse.data) === null || _f === void 0 ? void 0 : _f.work_flow_progress_stack) {
178
+ setWorkFlowStack((_h = (_g = detailResponse.data) === null || _g === void 0 ? void 0 : _g.work_flow_progress_stack) !== null && _h !== void 0 ? _h : []);
174
179
  }
175
180
  return chatInquiryNumber;
176
181
  }
@@ -186,16 +191,20 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
186
191
  // 메시지 전송
187
192
  const sendMessage = useCallback((htmlContent, jsonData, retry) => __awaiter(void 0, void 0, void 0, function* () {
188
193
  try {
189
- setIsLoading(true);
194
+ setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(true);
190
195
  console.log('chatInquiryNumber', chatInquiryNumber);
191
- yield sendChatMessage(chatInquiryNumber, htmlContent, jsonData);
196
+ const response = yield sendChatMessage(chatInquiryNumber, htmlContent, jsonData);
197
+ if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
198
+ toast.error(getErrorMessageMap(response));
199
+ }
200
+ return response;
192
201
  }
193
202
  catch (error) {
194
203
  toast.error('메시지 전송에 실패했습니다.');
195
204
  console.error('[DaeryuntalkContext] 메시지 전송 중 오류 발생:', error);
196
205
  }
197
206
  finally {
198
- setIsLoading(false);
207
+ setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(false);
199
208
  }
200
209
  }), [chatInquiryNumber]);
201
210
  // 신규 채팅 문의 생성
@@ -203,59 +212,63 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
203
212
  var _a, _b, _c, _d, _e, _f, _g;
204
213
  try {
205
214
  if (!inquiryMainData) {
206
- throw new Error('채널이 존재하지 않습니다.');
215
+ toast.error('채널이 존재하지 않습니다.');
216
+ return;
207
217
  }
208
- setIsLoading(true);
218
+ setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(true);
209
219
  console.log('chatInquiryNumber', chatInquiryNumber);
210
220
  const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '', fullUrl);
221
+ if (!(createResponse.result_info.result_cd === 'OK' ||
222
+ createResponse.result_info.result_type_cd === 'OK')) {
223
+ toast.error(getErrorMessageMap(createResponse));
224
+ return createResponse;
225
+ }
211
226
  console.log('[DaeryuntalkContext] 새 문의 생성 완료:', createResponse);
212
- if (createResponse.data) {
213
- const currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
214
- // 문의 상세 조회
215
- console.log('[DaeryuntalkContext] 문의 상세 조회 시작:', currentChatInquiryNumber);
216
- const detailResponse = yield getChatInquiryDetailNew(currentChatInquiryNumber);
217
- console.log('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
218
- // 메세지 리스트
219
- console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 시작:', currentChatInquiryNumber);
220
- const chatList = yield getChatInquiryMessageList(currentChatInquiryNumber);
221
- console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
222
- // 메시지 처리
223
- if (detailResponse.data && chatList.data) {
224
- setChatInquiryNumber(currentChatInquiryNumber);
225
- // 메세지 리스트 후처리
226
- if (((_a = chatList.data) === null || _a === void 0 ? void 0 : _a.message_list) && chatList.data.message_list.length > 0) {
227
- const uiMessages = chatList.data.message_list
228
- .sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime())
229
- .map(convertApiMessageToUiMessage);
230
- setMessages(uiMessages);
231
- console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
232
- }
233
- if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.next_page_yn) !== null) {
234
- setIsNextPage(chatList.data.next_page_yn);
235
- }
236
- // 해당 문의 상태
237
- if ((_c = detailResponse.data) === null || _c === void 0 ? void 0 : _c.chat_inquiry_state_code) {
238
- setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
239
- }
240
- // 워크플로우 스택 업데이트
241
- if ((_d = detailResponse.data) === null || _d === void 0 ? void 0 : _d.work_flow_progress_stack) {
242
- setWorkFlowStack((_f = (_e = detailResponse.data) === null || _e === void 0 ? void 0 : _e.work_flow_progress_stack) !== null && _f !== void 0 ? _f : []);
243
- }
244
- // 해당 문의 오브젝트
245
- if ((_g = detailResponse.data) === null || _g === void 0 ? void 0 : _g.object_expose_info) {
246
- const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
247
- setMessageObject(uiObject);
248
- }
249
- }
250
- else {
251
- setMessages([]);
252
- setInquiryStatus('');
253
- setMessageObject(null);
254
- setIsNextPage(null);
255
- console.log('[DaeryuntalkContext] 메시지 없음');
256
- }
227
+ const currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
228
+ // 문의 상세 조회
229
+ console.log('[DaeryuntalkContext] 문의 상세 조회 시작:', currentChatInquiryNumber);
230
+ const detailResponse = yield getChatInquiryDetailNew(currentChatInquiryNumber);
231
+ console.log('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
232
+ if (!(detailResponse.result_info.result_cd === 'OK' ||
233
+ detailResponse.result_info.result_type_cd === 'OK')) {
234
+ resetData();
235
+ toast.error(getErrorMessageMap(detailResponse));
236
+ return detailResponse;
257
237
  }
258
- else {
238
+ // 메세지 리스트
239
+ console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 시작:', currentChatInquiryNumber);
240
+ const chatList = yield getChatInquiryMessageList(currentChatInquiryNumber);
241
+ console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
242
+ if (!(chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK')) {
243
+ resetData();
244
+ toast.error(getErrorMessageMap(chatList));
245
+ return chatList;
246
+ }
247
+ // 메시지 처리
248
+ setChatInquiryNumber(currentChatInquiryNumber);
249
+ // 메세지 리스트 후처리
250
+ if (((_a = chatList.data) === null || _a === void 0 ? void 0 : _a.message_list) && chatList.data.message_list.length > 0) {
251
+ const uiMessages = chatList.data.message_list
252
+ .sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime())
253
+ .map(convertApiMessageToUiMessage);
254
+ setMessages(uiMessages);
255
+ console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
256
+ }
257
+ if (((_b = chatList.data) === null || _b === void 0 ? void 0 : _b.next_page_yn) !== null) {
258
+ setIsNextPage(chatList.data.next_page_yn);
259
+ }
260
+ // 해당 문의 상태
261
+ if ((_c = detailResponse.data) === null || _c === void 0 ? void 0 : _c.chat_inquiry_state_code) {
262
+ setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
263
+ }
264
+ // 워크플로우 스택 업데이트
265
+ if ((_d = detailResponse.data) === null || _d === void 0 ? void 0 : _d.work_flow_progress_stack) {
266
+ setWorkFlowStack((_f = (_e = detailResponse.data) === null || _e === void 0 ? void 0 : _e.work_flow_progress_stack) !== null && _f !== void 0 ? _f : []);
267
+ }
268
+ // 해당 문의 오브젝트
269
+ if ((_g = detailResponse.data) === null || _g === void 0 ? void 0 : _g.object_expose_info) {
270
+ const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
271
+ setMessageObject(uiObject);
259
272
  }
260
273
  }
261
274
  catch (error) {
@@ -268,90 +281,113 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
268
281
  }), [inquiryMainData, chatInquiryNumber]);
269
282
  const startWorkFlow = useCallback((data) => __awaiter(void 0, void 0, void 0, function* () {
270
283
  const { chatInquiryNumber, messageNumber, workFlowNumber, objectNumber } = data;
271
- setIsLoading(true);
272
284
  if (!chatInquiryNumber) {
273
- throw Error('채팅 문의 번호가 없습니다.');
285
+ toast.error('채팅 문의 번호가 없습니다.');
286
+ return;
274
287
  }
275
288
  if (!messageNumber) {
276
- throw Error('메시지 번호가 없습니다.');
289
+ toast.error('메시지 번호가 없습니다.');
290
+ return;
277
291
  }
278
292
  if (!workFlowNumber) {
279
- throw Error('워크플로우 번호가 없습니다.');
293
+ toast.error('워크플로우 번호가 없습니다.');
294
+ return;
280
295
  }
281
296
  if (!objectNumber) {
282
- throw Error('오브젝트 번호가 없습니다.');
297
+ toast.error('오브젝트 번호가 없습니다.');
298
+ return;
283
299
  }
284
300
  try {
285
- yield chatWorkFlow(chatInquiryNumber, messageNumber, workFlowNumber, objectNumber);
301
+ setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(true);
302
+ const response = yield chatWorkFlow(chatInquiryNumber, messageNumber, workFlowNumber, objectNumber);
303
+ if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
304
+ toast.error(getErrorMessageMap(response));
305
+ }
306
+ return response;
286
307
  }
287
308
  catch (error) {
288
309
  toast.error('워크플로우 생성에 실패했습니다.');
289
310
  console.error('[워크 플로우 생성 실패]:', error);
290
311
  }
291
312
  finally {
292
- setIsLoading(false);
313
+ setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(false);
293
314
  }
294
315
  }), []);
295
316
  const workFlowBack = useCallback((data) => __awaiter(void 0, void 0, void 0, function* () {
296
317
  const { chatInquiryNumber, messageNumber, workFlowNavigationCode } = data;
297
- setIsLoading(true);
298
318
  if (!chatInquiryNumber) {
299
- throw Error('채팅 문의 번호가 없습니다.');
319
+ toast.error('채팅 문의 번호가 없습니다.');
320
+ return;
300
321
  }
301
322
  if (!messageNumber) {
302
- throw Error('메시지 번호가 없습니다.');
323
+ toast.error('메시지 번호가 없습니다.');
324
+ return;
303
325
  }
304
326
  if (!workFlowNavigationCode) {
305
- throw Error('워크플로우 네비게이션 코드가 없습니다.');
327
+ toast.error('워크플로우 네비게이션 코드가 없습니다.');
328
+ return;
306
329
  }
307
330
  try {
308
- yield chatWorkFlowBack(chatInquiryNumber, messageNumber, workFlowNavigationCode);
331
+ setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(true);
332
+ const response = yield chatWorkFlowBack(chatInquiryNumber, messageNumber, workFlowNavigationCode);
333
+ if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
334
+ toast.error(getErrorMessageMap(response));
335
+ }
336
+ return response;
309
337
  }
310
338
  catch (error) {
311
339
  toast.error('동작에 실패했습니다.');
312
340
  console.error('[워크 플로우 생성 실패]:', error);
313
341
  }
314
342
  finally {
315
- setIsLoading(false);
343
+ setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(false);
316
344
  }
317
345
  }), []);
318
346
  const chatUserUpdate = useCallback((data) => __awaiter(void 0, void 0, void 0, function* () {
319
347
  const { chatInquiryNumber, messageNumber, name, cellPhoneNumber } = data;
320
- setIsLoading(true);
321
348
  if (!chatInquiryNumber) {
322
- throw new Error('채팅 개인 정보 업데이트: 문의 번호가 없음');
349
+ toast.error('채팅 개인 정보 업데이트: 문의 번호가 없음');
350
+ return;
323
351
  }
324
352
  if (!messageNumber) {
325
- throw new Error('채팅 개인 정보 업데이트: 메시지 번호 없음');
353
+ toast.error('채팅 개인 정보 업데이트: 메시지 번호 없음');
354
+ return;
326
355
  }
327
356
  if (!name) {
328
- throw new Error('채팅 개인 정보 업데이트: 이름 없음');
357
+ toast.error('채팅 개인 정보 업데이트: 이름 없음');
358
+ return;
329
359
  }
330
360
  if (!cellPhoneNumber) {
331
- throw new Error('채팅 개인 정보 업데이트: 메시지 번호 없음');
361
+ toast.error('채팅 개인 정보 업데이트: 메시지 번호 없음');
362
+ return;
332
363
  }
333
364
  try {
334
- yield apiChatUserUpdate(chatInquiryNumber, messageNumber, name, cellPhoneNumber);
365
+ setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(true);
366
+ const response = yield apiChatUserUpdate(chatInquiryNumber, messageNumber, name, cellPhoneNumber);
367
+ if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
368
+ toast.error(getErrorMessageMap(response));
369
+ }
370
+ return response;
335
371
  }
336
372
  catch (error) {
337
373
  toast.error('개인정보 업데이트에 실패했습니다.');
338
374
  console.error('[워크 플로우 생성 실패]:', error);
339
375
  }
340
376
  finally {
341
- setIsLoading(false);
377
+ setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(false);
342
378
  }
343
379
  }), []);
344
380
  const getNextMessageList = useCallback((chatInquiryNumber, standardDateTime) => __awaiter(void 0, void 0, void 0, function* () {
345
- const chatList = yield getChatInquiryMessageList(chatInquiryNumber, standardDateTime);
346
- if (chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK') {
347
- if (chatList.data) {
381
+ try {
382
+ const response = yield getChatInquiryMessageList(chatInquiryNumber, standardDateTime);
383
+ if (response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK') {
348
384
  // 앞에 생성될 여기서는 앞에서부터 채워야함
349
- const newMessageList = chatList.data.message_list
385
+ const newMessageList = response.data.message_list
350
386
  .sort((a, b) => a.timestamp - b.timestamp)
351
387
  .map(item => {
352
388
  return convertApiMessageToUiMessage(item);
353
389
  });
354
- setIsNextPage(chatList.data.next_page_yn);
390
+ setIsNextPage(response.data.next_page_yn);
355
391
  setMessages(prev => {
356
392
  if (newMessageList && newMessageList.length > 0) {
357
393
  return [...newMessageList, ...prev];
@@ -361,19 +397,31 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
361
397
  }
362
398
  });
363
399
  }
400
+ else {
401
+ toast.error(getErrorMessageMap(response));
402
+ return;
403
+ }
364
404
  }
365
- else {
366
- toast.error('메세지 조회에 실패했습니다.');
405
+ catch (error) {
406
+ console.error(`[실패]:`, error);
407
+ toast.error((error === null || error === void 0 ? void 0 : error.message) || '오류가 발생했습니다.');
367
408
  }
368
409
  }), []);
369
410
  const attendRoomByHistory = useCallback((chatInquiryNumber) => __awaiter(void 0, void 0, void 0, function* () {
370
- const res = yield attendChatRoomByHistory({ chatInquiryNumber });
371
- if (res.result_info.result_cd === 'OK' || res.result_info.result_type_cd === 'OK') {
411
+ try {
412
+ const response = yield attendChatRoomByHistory({ chatInquiryNumber });
413
+ if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
414
+ toast.error(getErrorMessageMap(response));
415
+ return;
416
+ }
417
+ return response;
418
+ }
419
+ catch (error) {
420
+ console.error(`[실패]:`, error);
421
+ toast.error((error === null || error === void 0 ? void 0 : error.message) || '오류가 발생했습니다.');
372
422
  }
373
- else {
374
- toast.error('채팅방 참여에 실패했습니다.');
423
+ finally {
375
424
  }
376
- return res;
377
425
  }), [chatInquiryNumber]);
378
426
  return {
379
427
  attendRoomByHistory,