@daeryun/dr_components 0.8.46 → 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.
- package/dist/asset/images/daeryuntalk/close.svg +2 -2
- package/dist/asset/images/daeryuntalk/time.svg +2 -2
- package/dist/asset/images/daeryuntalk/viewer/zoom-out.svg +2 -4
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/components/Daeryuntalk/ChatButton.jsx +5 -2
- package/dist/components/Daeryuntalk/ChatButton.tsx +5 -2
- package/dist/components/Daeryuntalk/ChatConversation.d.ts +2 -0
- package/dist/components/Daeryuntalk/ChatConversation.jsx +22 -63
- package/dist/components/Daeryuntalk/ChatConversation.tsx +42 -79
- package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.d.ts +11 -0
- package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.jsx +27 -0
- package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.tsx +57 -0
- package/dist/components/Daeryuntalk/ChatHomeView.d.ts +3 -2
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +59 -181
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +102 -206
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.jsx +15 -14
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.tsx +15 -14
- package/dist/components/Daeryuntalk/ChatItem/ChatLoading.d.ts +3 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatLoading.jsx +11 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatLoading.tsx +21 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.jsx +4 -4
- package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.tsx +4 -4
- package/dist/components/Daeryuntalk/ChatItem/RichText.jsx +2 -1
- package/dist/components/Daeryuntalk/ChatItem/RichText.tsx +2 -1
- package/dist/components/Daeryuntalk/ChatItem/TimeWrapper.d.ts +9 -0
- package/dist/components/Daeryuntalk/ChatItem/TimeWrapper.jsx +9 -0
- package/dist/components/Daeryuntalk/ChatItem/TimeWrapper.tsx +20 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.jsx +3 -3
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.tsx +3 -3
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.jsx +2 -2
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.tsx +2 -2
- package/dist/components/Daeryuntalk/ChatMessage.d.ts +1 -0
- package/dist/components/Daeryuntalk/ChatMessage.jsx +31 -36
- package/dist/components/Daeryuntalk/ChatMessage.tsx +34 -38
- package/dist/components/Daeryuntalk/ChatObject/FieldWorkObject.jsx +2 -2
- package/dist/components/Daeryuntalk/ChatObject/FieldWorkObject.tsx +2 -2
- package/dist/components/Daeryuntalk/ChatObject/ObjectBack.jsx +1 -1
- package/dist/components/Daeryuntalk/ChatObject/ObjectBack.tsx +1 -1
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.jsx +6 -23
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.tsx +6 -23
- package/dist/components/Daeryuntalk/ChatWidget.jsx +60 -23
- package/dist/components/Daeryuntalk/ChatWidget.tsx +72 -34
- package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +2 -2
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +2 -2
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +5 -5
- package/dist/components/Daeryuntalk/DateSeparator.jsx +2 -2
- package/dist/components/Daeryuntalk/DateSeparator.tsx +2 -2
- package/dist/components/Daeryuntalk/FixedErrorBox.d.ts +7 -0
- package/dist/components/Daeryuntalk/FixedErrorBox.jsx +33 -0
- package/dist/components/Daeryuntalk/FixedErrorBox.tsx +73 -0
- package/dist/components/Daeryuntalk/History/AuthForm.d.ts +3 -1
- package/dist/components/Daeryuntalk/History/AuthForm.jsx +15 -45
- package/dist/components/Daeryuntalk/History/AuthForm.tsx +21 -53
- package/dist/components/Daeryuntalk/HistoryView.d.ts +4 -0
- package/dist/components/Daeryuntalk/HistoryView.jsx +17 -40
- package/dist/components/Daeryuntalk/HistoryView.tsx +36 -48
- package/dist/components/Daeryuntalk/HomeView.d.ts +12 -0
- package/dist/components/Daeryuntalk/HomeView.jsx +102 -0
- package/dist/components/Daeryuntalk/HomeView.tsx +150 -0
- package/dist/components/Daeryuntalk/NavigationFooter.jsx +17 -10
- package/dist/components/Daeryuntalk/NavigationFooter.tsx +22 -12
- package/dist/components/Daeryuntalk/NoticeMessage.jsx +7 -7
- package/dist/components/Daeryuntalk/NoticeMessage.tsx +7 -7
- package/dist/components/Daeryuntalk/Toast/ToastRender.jsx +1 -1
- package/dist/components/Daeryuntalk/Toast/ToastRender.tsx +2 -2
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.d.ts +6 -0
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +18 -90
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +49 -135
- package/dist/components/Daeryuntalk/Viewer/MobileViewer.d.ts +16 -0
- package/dist/components/Daeryuntalk/Viewer/MobileViewer.jsx +66 -0
- package/dist/components/Daeryuntalk/Viewer/MobileViewer.tsx +121 -0
- package/dist/components/Daeryuntalk/Viewer/TbPcViewer.d.ts +22 -0
- package/dist/components/Daeryuntalk/Viewer/TbPcViewer.jsx +104 -0
- package/dist/components/Daeryuntalk/Viewer/TbPcViewer.tsx +195 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +4 -3
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +81 -105
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +105 -121
- package/dist/components/Daeryuntalk/_enums/ask-status.d.ts +7 -0
- package/dist/components/Daeryuntalk/_enums/ask-status.js +14 -0
- package/dist/components/Daeryuntalk/_enums/ask-status.ts +14 -0
- package/dist/components/Daeryuntalk/_enums/error.d.ts +3 -0
- package/dist/components/Daeryuntalk/_enums/error.js +125 -0
- package/dist/components/Daeryuntalk/_enums/error.ts +143 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +8 -8
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +227 -179
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +261 -185
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.d.ts +1 -1
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.js +54 -18
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.ts +68 -15
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +2 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +8 -7
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +13 -6
- package/dist/components/Daeryuntalk/_hooks/view/useChatSocketState.d.ts +2 -0
- package/dist/components/Daeryuntalk/_hooks/{talkprovider → view}/useChatSocketState.js +7 -1
- package/dist/components/Daeryuntalk/_hooks/{talkprovider → view}/useChatSocketState.ts +13 -1
- package/dist/components/Daeryuntalk/_hooks/view/useHistoryView.d.ts +26 -0
- package/dist/components/Daeryuntalk/_hooks/view/useHistoryView.js +72 -0
- package/dist/components/Daeryuntalk/_hooks/view/useHistoryView.ts +93 -0
- package/dist/components/Daeryuntalk/_hooks/view/useHomeView.d.ts +16 -0
- package/dist/components/Daeryuntalk/_hooks/view/useHomeView.js +61 -0
- package/dist/components/Daeryuntalk/_hooks/view/useHomeView.ts +64 -0
- package/dist/components/Daeryuntalk/_lib/utils.d.ts +1 -0
- package/dist/components/Daeryuntalk/_lib/utils.js +27 -0
- package/dist/components/Daeryuntalk/_lib/utils.ts +33 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button2.jsx +3 -3
- package/dist/components/Daeryuntalk/_ui/buttons/Button2.tsx +3 -3
- package/dist/components/Daeryuntalk/_ui/buttons/Button3.d.ts +10 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button3.jsx +12 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button3.tsx +29 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input2.jsx +2 -1
- package/dist/components/Daeryuntalk/_ui/inputs/Input2.tsx +2 -1
- package/dist/components/Daeryuntalk/index.jsx +1 -1
- package/dist/components/Daeryuntalk/index.tsx +12 -1
- package/dist/components/Seo/SeoStrength.jsx +5 -2
- package/dist/components/Seo/SeoStrength.tsx +5 -2
- package/dist/styles/globals.css +518 -172
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/components/Daeryuntalk/_enums/error_code.d.ts +0 -21
- package/dist/components/Daeryuntalk/_enums/error_code.js +0 -23
- package/dist/components/Daeryuntalk/_enums/error_code.ts +0 -22
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.d.ts +0 -1
|
@@ -18,6 +18,7 @@ import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
|
|
|
18
18
|
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
|
19
19
|
import { router } from 'next/client';
|
|
20
20
|
import { useFullURL } from './useFullURL';
|
|
21
|
+
import { getErrorMessageMap } from '../../_enums/error';
|
|
21
22
|
interface props {
|
|
22
23
|
setIsLoading: Dispatch<SetStateAction<boolean>>;
|
|
23
24
|
inquiryMainData: IChatInquiryMainDataResponse | null;
|
|
@@ -45,13 +46,21 @@ export const useChatHandler = ({
|
|
|
45
46
|
}: props) => {
|
|
46
47
|
const toast = useDaeryunTalkToast();
|
|
47
48
|
const fullUrl = useFullURL();
|
|
49
|
+
|
|
50
|
+
const resetData = useCallback(() => {
|
|
51
|
+
setMessages([]);
|
|
52
|
+
setInquiryStatus('');
|
|
53
|
+
setMessageObject(null);
|
|
54
|
+
setIsNextPage(null);
|
|
55
|
+
}, []);
|
|
56
|
+
// const resetData = () => {};
|
|
57
|
+
|
|
48
58
|
// 채팅 시작 (문의하기 버튼 클릭 시)
|
|
49
59
|
const startChat = useCallback(
|
|
50
60
|
async (inquiryNumber?: string) => {
|
|
51
61
|
try {
|
|
52
62
|
setIsLoading(true);
|
|
53
63
|
console.log('[DaeryuntalkContext] 채팅 시작 요청');
|
|
54
|
-
console.log('inquiryMainData', inquiryMainData);
|
|
55
64
|
|
|
56
65
|
// 기존 문의가 있는지 확인
|
|
57
66
|
const hasExistingInquiry =
|
|
@@ -69,23 +78,41 @@ export const useChatHandler = ({
|
|
|
69
78
|
// 새 문의 생성
|
|
70
79
|
console.log('[DaeryuntalkContext] 새 문의 생성 시작');
|
|
71
80
|
const createResponse = await generateChatInquiry(inquiryMainData?.channel_number || '', fullUrl);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
if (
|
|
82
|
+
!(
|
|
83
|
+
createResponse.result_info.result_cd === 'OK' ||
|
|
84
|
+
createResponse.result_info.result_type_cd === 'OK'
|
|
85
|
+
)
|
|
86
|
+
) {
|
|
87
|
+
resetData();
|
|
88
|
+
toast.error(getErrorMessageMap(createResponse));
|
|
89
|
+
return createResponse;
|
|
79
90
|
}
|
|
91
|
+
currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
80
92
|
}
|
|
81
93
|
|
|
82
94
|
// 문의 상세 조회
|
|
83
95
|
console.log('[DaeryuntalkContext] 문의 상세 조회 시작:', currentChatInquiryNumber);
|
|
84
96
|
const detailResponse = await getChatInquiryDetailNew(currentChatInquiryNumber);
|
|
97
|
+
if (
|
|
98
|
+
!(
|
|
99
|
+
detailResponse.result_info.result_cd === 'OK' ||
|
|
100
|
+
detailResponse.result_info.result_type_cd === 'OK'
|
|
101
|
+
)
|
|
102
|
+
) {
|
|
103
|
+
resetData();
|
|
104
|
+
toast.error(getErrorMessageMap(detailResponse));
|
|
105
|
+
return detailResponse;
|
|
106
|
+
}
|
|
85
107
|
console.log('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
|
|
86
108
|
|
|
87
109
|
console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 시작:', currentChatInquiryNumber);
|
|
88
110
|
const chatList = await getChatInquiryMessageList(currentChatInquiryNumber);
|
|
111
|
+
if (!(chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK')) {
|
|
112
|
+
resetData();
|
|
113
|
+
toast.error(getErrorMessageMap(chatList));
|
|
114
|
+
return chatList;
|
|
115
|
+
}
|
|
89
116
|
console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
|
|
90
117
|
|
|
91
118
|
// 문의 정보 저장
|
|
@@ -94,50 +121,35 @@ export const useChatHandler = ({
|
|
|
94
121
|
console.log('detailResponse.data.message_list', chatList?.data?.message_list);
|
|
95
122
|
|
|
96
123
|
// 메시지 처리
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
// const uiMessages = chatList.data.message_list.map(convertApiMessageToUiMessage);
|
|
109
|
-
setMessages(uiMessages);
|
|
110
|
-
|
|
111
|
-
console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
112
|
-
}
|
|
113
|
-
if (chatList.data?.next_page_yn !== null) {
|
|
114
|
-
setIsNextPage(chatList.data.next_page_yn);
|
|
115
|
-
}
|
|
124
|
+
// 메세지 리스트 후처리
|
|
125
|
+
if (chatList.data.message_list.length > 0) {
|
|
126
|
+
const uiMessages = chatList.data.message_list
|
|
127
|
+
.sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
|
|
128
|
+
.map(convertApiMessageToUiMessage);
|
|
129
|
+
setMessages(uiMessages);
|
|
130
|
+
console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
131
|
+
}
|
|
132
|
+
if (chatList.data?.next_page_yn !== null) {
|
|
133
|
+
setIsNextPage(chatList.data.next_page_yn);
|
|
134
|
+
}
|
|
116
135
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
// 해당 문의 상태
|
|
137
|
+
if (detailResponse.data?.chat_inquiry_state_code) {
|
|
138
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
139
|
+
}
|
|
140
|
+
// 해당 문의 오브젝트
|
|
141
|
+
if (detailResponse.data?.object_expose_info) {
|
|
142
|
+
const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
|
|
143
|
+
setMessageObject(uiObject);
|
|
144
|
+
}
|
|
126
145
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
} else {
|
|
136
|
-
setMessages([]);
|
|
137
|
-
setInquiryStatus('');
|
|
138
|
-
setMessageObject(null);
|
|
139
|
-
setIsNextPage(null);
|
|
140
|
-
console.log('[DaeryuntalkContext] 메시지 없음');
|
|
146
|
+
// 해당 문의 상태
|
|
147
|
+
if (detailResponse.data?.chat_inquiry_state_code) {
|
|
148
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
149
|
+
}
|
|
150
|
+
// 워크플로우 스택 업데이트
|
|
151
|
+
if (detailResponse.data?.work_flow_progress_stack) {
|
|
152
|
+
setWorkFlowStack(detailResponse.data?.work_flow_progress_stack ?? []);
|
|
141
153
|
}
|
|
142
154
|
|
|
143
155
|
return currentChatInquiryNumber;
|
|
@@ -162,70 +174,77 @@ export const useChatHandler = ({
|
|
|
162
174
|
|
|
163
175
|
// 문의 상세 조회
|
|
164
176
|
const detailResponse = await getChatInquiryDetailNew(chatInquiryNumber);
|
|
177
|
+
if (
|
|
178
|
+
!(
|
|
179
|
+
detailResponse.result_info.result_cd === 'OK' ||
|
|
180
|
+
detailResponse.result_info.result_type_cd === 'OK'
|
|
181
|
+
)
|
|
182
|
+
) {
|
|
183
|
+
resetData();
|
|
184
|
+
toast.error(getErrorMessageMap(detailResponse));
|
|
185
|
+
return detailResponse;
|
|
186
|
+
}
|
|
187
|
+
|
|
165
188
|
console.log('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
|
|
166
189
|
|
|
167
190
|
const chatList = await getChatInquiryMessageList(chatInquiryNumber);
|
|
168
191
|
console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
|
|
192
|
+
if (!(chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK')) {
|
|
193
|
+
resetData();
|
|
194
|
+
toast.error(getErrorMessageMap(chatList));
|
|
195
|
+
return chatList;
|
|
196
|
+
}
|
|
169
197
|
|
|
170
198
|
console.log('detailResponse.data.message_list', chatList?.data?.message_list);
|
|
171
199
|
|
|
172
200
|
// 메시지 처리
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
// 메세지 리스트 후처리
|
|
188
|
-
if (chatList.data?.message_list && chatList.data.message_list.length > 0) {
|
|
189
|
-
const uiMessages = chatList.data.message_list
|
|
190
|
-
.sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
|
|
191
|
-
.map(convertApiMessageToUiMessage);
|
|
192
|
-
setMessages(uiMessages);
|
|
193
|
-
|
|
194
|
-
// const uiMessages = chatList.data.message_list.map(convertApiMessageToUiMessage);
|
|
195
|
-
setMessages(uiMessages);
|
|
196
|
-
|
|
197
|
-
console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
198
|
-
}
|
|
199
|
-
if (chatList.data?.next_page_yn !== null) {
|
|
200
|
-
setIsNextPage(chatList.data.next_page_yn);
|
|
201
|
+
// 문의 정보 저장
|
|
202
|
+
setChatInquiryNumber(chatInquiryNumber);
|
|
203
|
+
//
|
|
204
|
+
setInquiryMainData(prev => {
|
|
205
|
+
if (prev) {
|
|
206
|
+
return {
|
|
207
|
+
...prev,
|
|
208
|
+
progress_inquiry_number: chatInquiryNumber
|
|
209
|
+
};
|
|
210
|
+
} else {
|
|
211
|
+
return null;
|
|
201
212
|
}
|
|
213
|
+
});
|
|
214
|
+
// 메세지 리스트 후처리
|
|
215
|
+
if (chatList.data.message_list.length > 0) {
|
|
216
|
+
const uiMessages = chatList.data.message_list
|
|
217
|
+
.sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
|
|
218
|
+
.map(convertApiMessageToUiMessage);
|
|
219
|
+
setMessages(uiMessages);
|
|
202
220
|
|
|
203
|
-
//
|
|
204
|
-
|
|
205
|
-
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
206
|
-
}
|
|
207
|
-
// 해당 문의 오브젝트
|
|
208
|
-
if (detailResponse.data?.object_expose_info) {
|
|
209
|
-
const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
|
|
210
|
-
setMessageObject(uiObject);
|
|
211
|
-
}
|
|
221
|
+
// const uiMessages = chatList.data.message_list.map(convertApiMessageToUiMessage);
|
|
222
|
+
setMessages(uiMessages);
|
|
212
223
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
225
|
+
}
|
|
226
|
+
if (chatList.data?.next_page_yn !== null) {
|
|
227
|
+
setIsNextPage(chatList.data.next_page_yn);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// 해당 문의 상태
|
|
231
|
+
if (detailResponse.data?.chat_inquiry_state_code) {
|
|
232
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
233
|
+
}
|
|
234
|
+
// 해당 문의 오브젝트
|
|
235
|
+
if (detailResponse.data?.object_expose_info) {
|
|
236
|
+
const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
|
|
237
|
+
setMessageObject(uiObject);
|
|
227
238
|
}
|
|
228
239
|
|
|
240
|
+
// 해당 문의 상태
|
|
241
|
+
if (detailResponse.data?.chat_inquiry_state_code) {
|
|
242
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
243
|
+
}
|
|
244
|
+
// 워크플로우 스택 업데이트
|
|
245
|
+
if (detailResponse.data?.work_flow_progress_stack) {
|
|
246
|
+
setWorkFlowStack(detailResponse.data?.work_flow_progress_stack ?? []);
|
|
247
|
+
}
|
|
229
248
|
return chatInquiryNumber;
|
|
230
249
|
} catch (error) {
|
|
231
250
|
toast.error('채팅 시작에 실패했습니다.');
|
|
@@ -242,14 +261,18 @@ export const useChatHandler = ({
|
|
|
242
261
|
const sendMessage = useCallback(
|
|
243
262
|
async (htmlContent: string, jsonData: any, retry?: boolean) => {
|
|
244
263
|
try {
|
|
245
|
-
setIsLoading(true);
|
|
264
|
+
setIsLoading?.(true);
|
|
246
265
|
console.log('chatInquiryNumber', chatInquiryNumber);
|
|
247
|
-
await sendChatMessage(chatInquiryNumber as string, htmlContent, jsonData);
|
|
266
|
+
const response = await sendChatMessage(chatInquiryNumber as string, htmlContent, jsonData);
|
|
267
|
+
if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
|
|
268
|
+
toast.error(getErrorMessageMap(response));
|
|
269
|
+
}
|
|
270
|
+
return response;
|
|
248
271
|
} catch (error) {
|
|
249
272
|
toast.error('메시지 전송에 실패했습니다.');
|
|
250
273
|
console.error('[DaeryuntalkContext] 메시지 전송 중 오류 발생:', error);
|
|
251
274
|
} finally {
|
|
252
|
-
setIsLoading(false);
|
|
275
|
+
setIsLoading?.(false);
|
|
253
276
|
}
|
|
254
277
|
},
|
|
255
278
|
[chatInquiryNumber]
|
|
@@ -260,59 +283,75 @@ export const useChatHandler = ({
|
|
|
260
283
|
async (version?: string) => {
|
|
261
284
|
try {
|
|
262
285
|
if (!inquiryMainData) {
|
|
263
|
-
|
|
286
|
+
toast.error('채널이 존재하지 않습니다.');
|
|
287
|
+
return;
|
|
264
288
|
}
|
|
265
|
-
setIsLoading(true);
|
|
289
|
+
setIsLoading?.(true);
|
|
266
290
|
console.log('chatInquiryNumber', chatInquiryNumber);
|
|
267
291
|
const createResponse = await generateChatInquiry(inquiryMainData?.channel_number || '', fullUrl);
|
|
292
|
+
if (
|
|
293
|
+
!(
|
|
294
|
+
createResponse.result_info.result_cd === 'OK' ||
|
|
295
|
+
createResponse.result_info.result_type_cd === 'OK'
|
|
296
|
+
)
|
|
297
|
+
) {
|
|
298
|
+
toast.error(getErrorMessageMap(createResponse));
|
|
299
|
+
return createResponse;
|
|
300
|
+
}
|
|
301
|
+
|
|
268
302
|
console.log('[DaeryuntalkContext] 새 문의 생성 완료:', createResponse);
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
303
|
+
const currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
|
|
304
|
+
// 문의 상세 조회
|
|
305
|
+
console.log('[DaeryuntalkContext] 문의 상세 조회 시작:', currentChatInquiryNumber);
|
|
306
|
+
const detailResponse = await getChatInquiryDetailNew(currentChatInquiryNumber);
|
|
307
|
+
console.log('[DaeryuntalkContext] 문의 상세 조회 완료:', detailResponse);
|
|
308
|
+
if (
|
|
309
|
+
!(
|
|
310
|
+
detailResponse.result_info.result_cd === 'OK' ||
|
|
311
|
+
detailResponse.result_info.result_type_cd === 'OK'
|
|
312
|
+
)
|
|
313
|
+
) {
|
|
314
|
+
resetData();
|
|
315
|
+
toast.error(getErrorMessageMap(detailResponse));
|
|
316
|
+
return detailResponse;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// 메세지 리스트
|
|
320
|
+
console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 시작:', currentChatInquiryNumber);
|
|
321
|
+
const chatList = await getChatInquiryMessageList(currentChatInquiryNumber);
|
|
322
|
+
console.log('[DaeryuntalkContext] 문의 채팅 리스트 조회 완료:', chatList);
|
|
323
|
+
|
|
324
|
+
if (!(chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK')) {
|
|
325
|
+
resetData();
|
|
326
|
+
toast.error(getErrorMessageMap(chatList));
|
|
327
|
+
return chatList;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// 메시지 처리
|
|
331
|
+
setChatInquiryNumber(currentChatInquiryNumber);
|
|
332
|
+
// 메세지 리스트 후처리
|
|
333
|
+
if (chatList.data?.message_list && chatList.data.message_list.length > 0) {
|
|
334
|
+
const uiMessages = chatList.data.message_list
|
|
335
|
+
.sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime())
|
|
336
|
+
.map(convertApiMessageToUiMessage);
|
|
337
|
+
setMessages(uiMessages);
|
|
338
|
+
console.log('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
|
|
339
|
+
}
|
|
340
|
+
if (chatList.data?.next_page_yn !== null) {
|
|
341
|
+
setIsNextPage(chatList.data.next_page_yn);
|
|
342
|
+
}
|
|
343
|
+
// 해당 문의 상태
|
|
344
|
+
if (detailResponse.data?.chat_inquiry_state_code) {
|
|
345
|
+
setInquiryStatus(detailResponse.data.chat_inquiry_state_code);
|
|
346
|
+
}
|
|
347
|
+
// 워크플로우 스택 업데이트
|
|
348
|
+
if (detailResponse.data?.work_flow_progress_stack) {
|
|
349
|
+
setWorkFlowStack(detailResponse.data?.work_flow_progress_stack ?? []);
|
|
350
|
+
}
|
|
351
|
+
// 해당 문의 오브젝트
|
|
352
|
+
if (detailResponse.data?.object_expose_info) {
|
|
353
|
+
const uiObject = convertApiMessageObjectToUiMessageObject(detailResponse.data);
|
|
354
|
+
setMessageObject(uiObject);
|
|
316
355
|
}
|
|
317
356
|
} catch (error) {
|
|
318
357
|
toast.error('채팅 문의 생성에 실패했습니다.');
|
|
@@ -332,26 +371,35 @@ export const useChatHandler = ({
|
|
|
332
371
|
objectNumber: string;
|
|
333
372
|
}) => {
|
|
334
373
|
const { chatInquiryNumber, messageNumber, workFlowNumber, objectNumber } = data;
|
|
335
|
-
|
|
374
|
+
|
|
336
375
|
if (!chatInquiryNumber) {
|
|
337
|
-
|
|
376
|
+
toast.error('채팅 문의 번호가 없습니다.');
|
|
377
|
+
return;
|
|
338
378
|
}
|
|
339
379
|
if (!messageNumber) {
|
|
340
|
-
|
|
380
|
+
toast.error('메시지 번호가 없습니다.');
|
|
381
|
+
return;
|
|
341
382
|
}
|
|
342
383
|
if (!workFlowNumber) {
|
|
343
|
-
|
|
384
|
+
toast.error('워크플로우 번호가 없습니다.');
|
|
385
|
+
return;
|
|
344
386
|
}
|
|
345
387
|
if (!objectNumber) {
|
|
346
|
-
|
|
388
|
+
toast.error('오브젝트 번호가 없습니다.');
|
|
389
|
+
return;
|
|
347
390
|
}
|
|
348
391
|
try {
|
|
349
|
-
|
|
392
|
+
setIsLoading?.(true);
|
|
393
|
+
const response = await chatWorkFlow(chatInquiryNumber, messageNumber, workFlowNumber, objectNumber);
|
|
394
|
+
if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
|
|
395
|
+
toast.error(getErrorMessageMap(response));
|
|
396
|
+
}
|
|
397
|
+
return response;
|
|
350
398
|
} catch (error) {
|
|
351
399
|
toast.error('워크플로우 생성에 실패했습니다.');
|
|
352
400
|
console.error('[워크 플로우 생성 실패]:', error);
|
|
353
401
|
} finally {
|
|
354
|
-
setIsLoading(false);
|
|
402
|
+
setIsLoading?.(false);
|
|
355
403
|
}
|
|
356
404
|
},
|
|
357
405
|
[]
|
|
@@ -360,23 +408,31 @@ export const useChatHandler = ({
|
|
|
360
408
|
const workFlowBack = useCallback(
|
|
361
409
|
async (data: { chatInquiryNumber: string; messageNumber: string; workFlowNavigationCode: string }) => {
|
|
362
410
|
const { chatInquiryNumber, messageNumber, workFlowNavigationCode } = data;
|
|
363
|
-
|
|
411
|
+
|
|
364
412
|
if (!chatInquiryNumber) {
|
|
365
|
-
|
|
413
|
+
toast.error('채팅 문의 번호가 없습니다.');
|
|
414
|
+
return;
|
|
366
415
|
}
|
|
367
416
|
if (!messageNumber) {
|
|
368
|
-
|
|
417
|
+
toast.error('메시지 번호가 없습니다.');
|
|
418
|
+
return;
|
|
369
419
|
}
|
|
370
420
|
if (!workFlowNavigationCode) {
|
|
371
|
-
|
|
421
|
+
toast.error('워크플로우 네비게이션 코드가 없습니다.');
|
|
422
|
+
return;
|
|
372
423
|
}
|
|
373
424
|
try {
|
|
374
|
-
|
|
425
|
+
setIsLoading?.(true);
|
|
426
|
+
const response = await chatWorkFlowBack(chatInquiryNumber, messageNumber, workFlowNavigationCode);
|
|
427
|
+
if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
|
|
428
|
+
toast.error(getErrorMessageMap(response));
|
|
429
|
+
}
|
|
430
|
+
return response;
|
|
375
431
|
} catch (error) {
|
|
376
432
|
toast.error('동작에 실패했습니다.');
|
|
377
433
|
console.error('[워크 플로우 생성 실패]:', error);
|
|
378
434
|
} finally {
|
|
379
|
-
setIsLoading(false);
|
|
435
|
+
setIsLoading?.(false);
|
|
380
436
|
}
|
|
381
437
|
},
|
|
382
438
|
[]
|
|
@@ -385,45 +441,55 @@ export const useChatHandler = ({
|
|
|
385
441
|
const chatUserUpdate = useCallback(
|
|
386
442
|
async (data: { chatInquiryNumber: string; messageNumber: string; name: string; cellPhoneNumber: string }) => {
|
|
387
443
|
const { chatInquiryNumber, messageNumber, name, cellPhoneNumber } = data;
|
|
388
|
-
|
|
444
|
+
|
|
389
445
|
if (!chatInquiryNumber) {
|
|
390
|
-
|
|
446
|
+
toast.error('채팅 개인 정보 업데이트: 문의 번호가 없음');
|
|
447
|
+
return;
|
|
391
448
|
}
|
|
392
449
|
|
|
393
450
|
if (!messageNumber) {
|
|
394
|
-
|
|
451
|
+
toast.error('채팅 개인 정보 업데이트: 메시지 번호 없음');
|
|
452
|
+
return;
|
|
395
453
|
}
|
|
396
454
|
|
|
397
455
|
if (!name) {
|
|
398
|
-
|
|
456
|
+
toast.error('채팅 개인 정보 업데이트: 이름 없음');
|
|
457
|
+
return;
|
|
399
458
|
}
|
|
400
459
|
|
|
401
460
|
if (!cellPhoneNumber) {
|
|
402
|
-
|
|
461
|
+
toast.error('채팅 개인 정보 업데이트: 메시지 번호 없음');
|
|
462
|
+
return;
|
|
403
463
|
}
|
|
464
|
+
|
|
404
465
|
try {
|
|
405
|
-
|
|
466
|
+
setIsLoading?.(true);
|
|
467
|
+
const response = await apiChatUserUpdate(chatInquiryNumber, messageNumber, name, cellPhoneNumber);
|
|
468
|
+
if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
|
|
469
|
+
toast.error(getErrorMessageMap(response));
|
|
470
|
+
}
|
|
471
|
+
return response;
|
|
406
472
|
} catch (error) {
|
|
407
473
|
toast.error('개인정보 업데이트에 실패했습니다.');
|
|
408
474
|
console.error('[워크 플로우 생성 실패]:', error);
|
|
409
475
|
} finally {
|
|
410
|
-
setIsLoading(false);
|
|
476
|
+
setIsLoading?.(false);
|
|
411
477
|
}
|
|
412
478
|
},
|
|
413
479
|
[]
|
|
414
480
|
);
|
|
415
481
|
|
|
416
482
|
const getNextMessageList = useCallback(async (chatInquiryNumber: string, standardDateTime: any) => {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
if (
|
|
483
|
+
try {
|
|
484
|
+
const response = await getChatInquiryMessageList(chatInquiryNumber, standardDateTime);
|
|
485
|
+
if (response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK') {
|
|
420
486
|
// 앞에 생성될 여기서는 앞에서부터 채워야함
|
|
421
|
-
const newMessageList =
|
|
487
|
+
const newMessageList = response.data.message_list
|
|
422
488
|
.sort((a, b) => a.timestamp - b.timestamp)
|
|
423
489
|
.map(item => {
|
|
424
490
|
return convertApiMessageToUiMessage(item);
|
|
425
491
|
});
|
|
426
|
-
setIsNextPage(
|
|
492
|
+
setIsNextPage(response.data.next_page_yn);
|
|
427
493
|
setMessages(prev => {
|
|
428
494
|
if (newMessageList && newMessageList.length > 0) {
|
|
429
495
|
return [...newMessageList, ...prev];
|
|
@@ -431,20 +497,30 @@ export const useChatHandler = ({
|
|
|
431
497
|
return [...prev];
|
|
432
498
|
}
|
|
433
499
|
});
|
|
500
|
+
} else {
|
|
501
|
+
toast.error(getErrorMessageMap(response));
|
|
502
|
+
return;
|
|
434
503
|
}
|
|
435
|
-
}
|
|
436
|
-
|
|
504
|
+
} catch (error: any) {
|
|
505
|
+
console.error(`[실패]:`, error);
|
|
506
|
+
toast.error(error?.message || '오류가 발생했습니다.');
|
|
437
507
|
}
|
|
438
508
|
}, []);
|
|
439
509
|
|
|
440
510
|
const attendRoomByHistory = useCallback(
|
|
441
511
|
async (chatInquiryNumber: string) => {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
512
|
+
try {
|
|
513
|
+
const response = await attendChatRoomByHistory({ chatInquiryNumber });
|
|
514
|
+
if (!(response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK')) {
|
|
515
|
+
toast.error(getErrorMessageMap(response));
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
return response;
|
|
519
|
+
} catch (error: any) {
|
|
520
|
+
console.error(`[실패]:`, error);
|
|
521
|
+
toast.error(error?.message || '오류가 발생했습니다.');
|
|
522
|
+
} finally {
|
|
446
523
|
}
|
|
447
|
-
return res;
|
|
448
524
|
},
|
|
449
525
|
[chatInquiryNumber]
|
|
450
526
|
);
|
|
@@ -19,6 +19,6 @@ export declare const useHistoryHandler: ({ setLoading, setIsAuthenticated, setHi
|
|
|
19
19
|
}) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<unknown> | undefined>;
|
|
20
20
|
goGetHistoryList: ({ version }: {
|
|
21
21
|
version?: string;
|
|
22
|
-
}) => Promise<
|
|
22
|
+
}) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<import("../../_api/daeryuntalk/type/response").HistoryListResponse> | undefined>;
|
|
23
23
|
};
|
|
24
24
|
export {};
|