@daeryun/dr_components 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Daeryuntalk/ChatButton.jsx +3 -3
- package/dist/components/Daeryuntalk/ChatButton.tsx +3 -3
- package/dist/components/Daeryuntalk/ChatConversation.jsx +1 -56
- package/dist/components/Daeryuntalk/ChatConversation.tsx +2 -56
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +2 -1
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +11 -2
- package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +5 -2
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +12 -7
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +24 -9
- package/dist/components/Daeryuntalk/Toast/Toast.jsx +4 -2
- package/dist/components/Daeryuntalk/Toast/Toast.tsx +4 -2
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +2 -3
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +6 -6
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +5 -4
- package/dist/components/Daeryuntalk/_enums/socket_type.d.ts +8 -0
- package/dist/components/Daeryuntalk/_enums/socket_type.js +9 -0
- package/dist/components/Daeryuntalk/_enums/socket_type.ts +9 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +2 -1
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +3 -3
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +13 -3
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +3 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +23 -20
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +25 -20
- package/dist/components/Daeryuntalk/_hooks/view/useChatSocketState.js +1 -1
- package/dist/components/Daeryuntalk/_hooks/view/useChatSocketState.ts +1 -1
- package/dist/components/Daeryuntalk/index.d.ts +2 -1
- package/dist/components/Daeryuntalk/index.jsx +2 -2
- package/dist/components/Daeryuntalk/index.tsx +4 -3
- package/dist/components/Seo/SeoStrength.jsx +3 -3
- package/dist/components/Seo/SeoStrength.tsx +3 -3
- package/dist/styles/globals.css +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ import { convertApiMessageObjectToUiMessageObject, convertApiMessageToUiMessage
|
|
|
13
13
|
import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
|
|
14
14
|
import { useFullURL } from './useFullURL';
|
|
15
15
|
import { getErrorMessageMap } from '../../_enums/error';
|
|
16
|
-
export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, setInquiryMainData }) => {
|
|
16
|
+
export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, setInquiryMainData, centerCode }) => {
|
|
17
17
|
const toast = useDaeryunTalkToast();
|
|
18
18
|
const fullUrl = useFullURL();
|
|
19
19
|
const resetData = useCallback(() => {
|
|
@@ -42,7 +42,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
42
42
|
else {
|
|
43
43
|
// 새 문의 생성
|
|
44
44
|
console.log('[DaeryuntalkContext] 새 문의 생성 시작');
|
|
45
|
-
const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '', fullUrl);
|
|
45
|
+
const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '', fullUrl, centerCode);
|
|
46
46
|
if (!(createResponse.result_info.result_cd === 'OK' ||
|
|
47
47
|
createResponse.result_info.result_type_cd === 'OK')) {
|
|
48
48
|
resetData();
|
|
@@ -217,7 +217,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
217
217
|
}
|
|
218
218
|
setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(true);
|
|
219
219
|
console.log('chatInquiryNumber', chatInquiryNumber);
|
|
220
|
-
const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '', fullUrl);
|
|
220
|
+
const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '', fullUrl, centerCode);
|
|
221
221
|
if (!(createResponse.result_info.result_cd === 'OK' ||
|
|
222
222
|
createResponse.result_info.result_type_cd === 'OK')) {
|
|
223
223
|
toast.error(getErrorMessageMap(createResponse));
|
|
@@ -30,6 +30,7 @@ interface props {
|
|
|
30
30
|
setIsNextPage: Dispatch<SetStateAction<boolean | null>>;
|
|
31
31
|
setWorkFlowStack: Dispatch<SetStateAction<string[]>>;
|
|
32
32
|
setInquiryMainData: Dispatch<SetStateAction<IChatInquiryMainDataResponse | null>>;
|
|
33
|
+
centerCode: string;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export const useChatHandler = ({
|
|
@@ -42,7 +43,8 @@ export const useChatHandler = ({
|
|
|
42
43
|
chatInquiryNumber,
|
|
43
44
|
setIsNextPage,
|
|
44
45
|
setWorkFlowStack,
|
|
45
|
-
setInquiryMainData
|
|
46
|
+
setInquiryMainData,
|
|
47
|
+
centerCode
|
|
46
48
|
}: props) => {
|
|
47
49
|
const toast = useDaeryunTalkToast();
|
|
48
50
|
const fullUrl = useFullURL();
|
|
@@ -77,7 +79,11 @@ export const useChatHandler = ({
|
|
|
77
79
|
} else {
|
|
78
80
|
// 새 문의 생성
|
|
79
81
|
console.log('[DaeryuntalkContext] 새 문의 생성 시작');
|
|
80
|
-
const createResponse = await generateChatInquiry(
|
|
82
|
+
const createResponse = await generateChatInquiry(
|
|
83
|
+
inquiryMainData?.channel_number || '',
|
|
84
|
+
fullUrl,
|
|
85
|
+
centerCode
|
|
86
|
+
);
|
|
81
87
|
if (
|
|
82
88
|
!(
|
|
83
89
|
createResponse.result_info.result_cd === 'OK' ||
|
|
@@ -288,7 +294,11 @@ export const useChatHandler = ({
|
|
|
288
294
|
}
|
|
289
295
|
setIsLoading?.(true);
|
|
290
296
|
console.log('chatInquiryNumber', chatInquiryNumber);
|
|
291
|
-
const createResponse = await generateChatInquiry(
|
|
297
|
+
const createResponse = await generateChatInquiry(
|
|
298
|
+
inquiryMainData?.channel_number || '',
|
|
299
|
+
fullUrl,
|
|
300
|
+
centerCode
|
|
301
|
+
);
|
|
292
302
|
if (
|
|
293
303
|
!(
|
|
294
304
|
createResponse.result_info.result_cd === 'OK' ||
|
|
@@ -18,9 +18,10 @@ interface props {
|
|
|
18
18
|
setIsAuthenticated: Dispatch<SetStateAction<boolean>>;
|
|
19
19
|
setIsTyping: Dispatch<SetStateAction<boolean>>;
|
|
20
20
|
onClose: () => void;
|
|
21
|
+
centerCode: string;
|
|
21
22
|
}
|
|
22
|
-
export declare const useSocketEventHandler: ({ setIsConnected, setIsLoading, setMessages, setInquiryMainData, socketRef, setWorkFlowStack, setMessageObject, setInquiryStatus, setHistoryList, historyList, inquiryMainData, isMobile, setIsAuthenticated, setIsTyping, onClose }: props) => {
|
|
23
|
-
initializeDaeryuntalk: (hashValue: string | null, isOpen: boolean, version?: string) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse> | null | undefined>;
|
|
23
|
+
export declare const useSocketEventHandler: ({ setIsConnected, setIsLoading, setMessages, setInquiryMainData, socketRef, setWorkFlowStack, setMessageObject, setInquiryStatus, setHistoryList, historyList, inquiryMainData, isMobile, setIsAuthenticated, setIsTyping, onClose, centerCode }: props) => {
|
|
24
|
+
initializeDaeryuntalk: (hashValue: string | null, isOpen: boolean, centerCode: string, version?: string) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse> | null | undefined>;
|
|
24
25
|
sendHeartbeat: () => void;
|
|
25
26
|
sendInquiryJoined: (chatInquiryNumber: string) => void;
|
|
26
27
|
sendInquiryLeft: (chatInquiryNumber: string) => void;
|
|
@@ -8,15 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { useCallback, useRef } from 'react';
|
|
11
|
-
import { authenticateUser, getChatInquiryMain, getHistoryList, initializeDaeryuntalk as apiInitializeDaeryuntalk
|
|
11
|
+
import { authenticateUser, getChatInquiryMain, getHistoryList, initializeDaeryuntalk as apiInitializeDaeryuntalk } from '../../_api/daeryuntalk';
|
|
12
12
|
import { convertApiMessageToUiMessage, convertSocketObjectToUiMessage } from '../../_lib';
|
|
13
|
-
import { MessageSocketType } from '../../_enums/socket_type';
|
|
13
|
+
import { MessageSendSocketType, MessageSocketType } from '../../_enums/socket_type';
|
|
14
14
|
import { InquiryStatusEnum } from '../../_enums/ask-status';
|
|
15
15
|
import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
|
|
16
16
|
import { getErrorMessageMap } from '../../_enums/error';
|
|
17
|
-
export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessages, setInquiryMainData, socketRef, setWorkFlowStack, setMessageObject, setInquiryStatus, setHistoryList, historyList, inquiryMainData, isMobile, setIsAuthenticated, setIsTyping, onClose }) => {
|
|
17
|
+
export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessages, setInquiryMainData, socketRef, setWorkFlowStack, setMessageObject, setInquiryStatus, setHistoryList, historyList, inquiryMainData, isMobile, setIsAuthenticated, setIsTyping, onClose, centerCode }) => {
|
|
18
18
|
const typingTimeoutRef = useRef(null);
|
|
19
19
|
const toast = useDaeryunTalkToast();
|
|
20
|
+
const closeTyping = () => {
|
|
21
|
+
setIsTyping(false);
|
|
22
|
+
};
|
|
20
23
|
const handleTypingStarted = () => {
|
|
21
24
|
setIsTyping(true);
|
|
22
25
|
if (typingTimeoutRef.current) {
|
|
@@ -25,7 +28,7 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
25
28
|
// 일정 시간 타이핑 이벤트 없으면 UI 제거
|
|
26
29
|
typingTimeoutRef.current = setTimeout(() => {
|
|
27
30
|
setIsTyping(false);
|
|
28
|
-
},
|
|
31
|
+
}, 3000);
|
|
29
32
|
};
|
|
30
33
|
/**
|
|
31
34
|
* 1. heartbeat
|
|
@@ -43,20 +46,20 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
43
46
|
const socket = socketRef.current;
|
|
44
47
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
45
48
|
socket.send(JSON.stringify({
|
|
46
|
-
type:
|
|
49
|
+
type: MessageSendSocketType.HEARTBEAT,
|
|
47
50
|
payload: {}
|
|
48
51
|
}));
|
|
49
|
-
console.log(
|
|
52
|
+
console.log(`[WebSocket] ${MessageSendSocketType.HEARTBEAT} 전송`);
|
|
50
53
|
}
|
|
51
54
|
}, []);
|
|
52
55
|
const sendInquiryWatching = useCallback((chatInquiryNumber) => {
|
|
53
56
|
const socket = socketRef.current;
|
|
54
57
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
55
58
|
socket.send(JSON.stringify({
|
|
56
|
-
type:
|
|
59
|
+
type: MessageSendSocketType.INQUIRY_WATCHING,
|
|
57
60
|
payload: { chat_inquiry_number: chatInquiryNumber }
|
|
58
61
|
}));
|
|
59
|
-
console.log(
|
|
62
|
+
console.log(`[WebSocket] ${MessageSendSocketType.INQUIRY_WATCHING} 전송`);
|
|
60
63
|
}
|
|
61
64
|
}, []);
|
|
62
65
|
/**
|
|
@@ -75,10 +78,10 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
75
78
|
const socket = socketRef.current;
|
|
76
79
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
77
80
|
socket.send(JSON.stringify({
|
|
78
|
-
type:
|
|
81
|
+
type: MessageSendSocketType.INQUIRY_JOINED,
|
|
79
82
|
payload: { chat_inquiry_number: chatInquiryNumber }
|
|
80
83
|
}));
|
|
81
|
-
console.log(
|
|
84
|
+
console.log(`[WebSocket] ${MessageSendSocketType.INQUIRY_JOINED} 전송`);
|
|
82
85
|
}
|
|
83
86
|
}, []);
|
|
84
87
|
/**
|
|
@@ -97,10 +100,10 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
97
100
|
const socket = socketRef.current;
|
|
98
101
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
99
102
|
socket.send(JSON.stringify({
|
|
100
|
-
type:
|
|
103
|
+
type: MessageSendSocketType.INQUIRY_LEFT,
|
|
101
104
|
payload: { chat_inquiry_number: chatInquiryNumber }
|
|
102
105
|
}));
|
|
103
|
-
console.log(
|
|
106
|
+
console.log(`[WebSocket] ${MessageSendSocketType.INQUIRY_LEFT} 전송`);
|
|
104
107
|
}
|
|
105
108
|
}, []);
|
|
106
109
|
/**
|
|
@@ -123,30 +126,30 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
123
126
|
const socket = socketRef.current;
|
|
124
127
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
125
128
|
socket.send(JSON.stringify({
|
|
126
|
-
type:
|
|
129
|
+
type: MessageSendSocketType.HISTORY_ENTERED,
|
|
127
130
|
payload: { chat_inquiry_numbers: chatInquiryNumbers }
|
|
128
131
|
}));
|
|
129
|
-
console.log(
|
|
132
|
+
console.log(`[WebSocket] ${MessageSendSocketType.HISTORY_ENTERED} 전송`);
|
|
130
133
|
}
|
|
131
134
|
}, []);
|
|
132
135
|
const sendHistoryLeft = useCallback((chatInquiryNumbers) => {
|
|
133
136
|
const socket = socketRef.current;
|
|
134
137
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
135
138
|
socket.send(JSON.stringify({
|
|
136
|
-
type:
|
|
139
|
+
type: MessageSendSocketType.HISTORY_EXITED,
|
|
137
140
|
payload: { chat_inquiry_numbers: chatInquiryNumbers }
|
|
138
141
|
}));
|
|
139
|
-
console.log(
|
|
142
|
+
console.log(`[WebSocket] ${MessageSendSocketType.HISTORY_EXITED} 전송`);
|
|
140
143
|
}
|
|
141
144
|
}, []);
|
|
142
145
|
// Daeryuntalk API 초기화 메소드
|
|
143
|
-
const initializeDaeryuntalk = useCallback((hashValue, isOpen, version) => __awaiter(void 0, void 0, void 0, function* () {
|
|
146
|
+
const initializeDaeryuntalk = useCallback((hashValue, isOpen, centerCode, version) => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
147
|
var _a, _b, _c, _d, _e;
|
|
145
148
|
console.log('[DaeryuntalkContext] 초기화 메소드 호출됨', version ? `버전: ${version}` : '기본 버전 사용');
|
|
146
149
|
try {
|
|
147
150
|
setIsLoading(true);
|
|
148
151
|
console.log('[DaeryuntalkContext] 로딩 상태 설정: true');
|
|
149
|
-
const { inquiryData, socket, hashAuth, errorCode } = yield apiInitializeDaeryuntalk(hashValue || '', isOpen, setIsConnected, isMobile, socket => {
|
|
152
|
+
const { inquiryData, socket, hashAuth, errorCode } = yield apiInitializeDaeryuntalk(hashValue || '', isOpen, setIsConnected, isMobile, centerCode, socket => {
|
|
150
153
|
console.log('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 성공');
|
|
151
154
|
setIsConnected(true);
|
|
152
155
|
}, event => {
|
|
@@ -158,11 +161,11 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
158
161
|
// 메시지 생성
|
|
159
162
|
if (data.type === MessageSocketType.MESSAGE_CREATED && ((_a = data.payload) === null || _a === void 0 ? void 0 : _a.message)) {
|
|
160
163
|
const newMessage = convertApiMessageToUiMessage(data.payload.message);
|
|
161
|
-
console.log('메세지 넣기 시작');
|
|
162
164
|
setMessages(prev => {
|
|
163
165
|
const isDuplicate = prev.some(msg => msg.messageNumber === newMessage.messageNumber);
|
|
164
166
|
return isDuplicate ? prev : [...prev, newMessage];
|
|
165
167
|
});
|
|
168
|
+
closeTyping();
|
|
166
169
|
}
|
|
167
170
|
if (data.type === MessageSocketType.MESSAGE_UPDATED) {
|
|
168
171
|
const newMessage = convertApiMessageToUiMessage(data.payload.message);
|
|
@@ -276,7 +279,7 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
276
279
|
return result;
|
|
277
280
|
}), [inquiryMainData]);
|
|
278
281
|
const retryInitData = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
279
|
-
const authRes = yield authenticateUser(
|
|
282
|
+
const authRes = yield authenticateUser(centerCode);
|
|
280
283
|
const result = yield getChatInquiryMain(authRes.data.channel_number);
|
|
281
284
|
setInquiryMainData(result.data);
|
|
282
285
|
}), []);
|
|
@@ -5,15 +5,14 @@ import {
|
|
|
5
5
|
followupAttend,
|
|
6
6
|
getChatInquiryMain,
|
|
7
7
|
getHistoryList,
|
|
8
|
-
initializeDaeryuntalk as apiInitializeDaeryuntalk
|
|
9
|
-
TEST_CENTER_CODE
|
|
8
|
+
initializeDaeryuntalk as apiInitializeDaeryuntalk
|
|
10
9
|
} from '../../_api/daeryuntalk';
|
|
11
10
|
import { Message } from '../../_types/message';
|
|
12
11
|
import { History, IChatInquiryMainDataResponse } from '../../_api/daeryuntalk/type/response';
|
|
13
12
|
import { convertApiMessageToUiMessage, convertSocketObjectToUiMessage } from '../../_lib';
|
|
14
13
|
import { MessageObject } from '../../_types/message_object';
|
|
15
14
|
import { IInquiryWorkFlowUpdate } from '../../_types/socket/workflow';
|
|
16
|
-
import { MessageSocketType } from '../../_enums/socket_type';
|
|
15
|
+
import { MessageSendSocketType, MessageSocketType } from '../../_enums/socket_type';
|
|
17
16
|
import { InquiryStatusEnum } from '../../_enums/ask-status';
|
|
18
17
|
import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
|
|
19
18
|
import { getErrorMessageMap } from '../../_enums/error';
|
|
@@ -34,6 +33,7 @@ interface props {
|
|
|
34
33
|
setIsAuthenticated: Dispatch<SetStateAction<boolean>>;
|
|
35
34
|
setIsTyping: Dispatch<SetStateAction<boolean>>;
|
|
36
35
|
onClose: () => void;
|
|
36
|
+
centerCode: string;
|
|
37
37
|
}
|
|
38
38
|
export const useSocketEventHandler = ({
|
|
39
39
|
setIsConnected,
|
|
@@ -50,10 +50,14 @@ export const useSocketEventHandler = ({
|
|
|
50
50
|
isMobile,
|
|
51
51
|
setIsAuthenticated,
|
|
52
52
|
setIsTyping,
|
|
53
|
-
onClose
|
|
53
|
+
onClose,
|
|
54
|
+
centerCode
|
|
54
55
|
}: props) => {
|
|
55
56
|
const typingTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
56
57
|
const toast = useDaeryunTalkToast();
|
|
58
|
+
const closeTyping = () => {
|
|
59
|
+
setIsTyping(false);
|
|
60
|
+
};
|
|
57
61
|
|
|
58
62
|
const handleTypingStarted = () => {
|
|
59
63
|
setIsTyping(true);
|
|
@@ -65,7 +69,7 @@ export const useSocketEventHandler = ({
|
|
|
65
69
|
// 일정 시간 타이핑 이벤트 없으면 UI 제거
|
|
66
70
|
typingTimeoutRef.current = setTimeout(() => {
|
|
67
71
|
setIsTyping(false);
|
|
68
|
-
},
|
|
72
|
+
}, 3000);
|
|
69
73
|
};
|
|
70
74
|
|
|
71
75
|
/**
|
|
@@ -85,11 +89,11 @@ export const useSocketEventHandler = ({
|
|
|
85
89
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
86
90
|
socket.send(
|
|
87
91
|
JSON.stringify({
|
|
88
|
-
type:
|
|
92
|
+
type: MessageSendSocketType.HEARTBEAT,
|
|
89
93
|
payload: {}
|
|
90
94
|
})
|
|
91
95
|
);
|
|
92
|
-
console.log(
|
|
96
|
+
console.log(`[WebSocket] ${MessageSendSocketType.HEARTBEAT} 전송`);
|
|
93
97
|
}
|
|
94
98
|
}, []);
|
|
95
99
|
|
|
@@ -98,11 +102,11 @@ export const useSocketEventHandler = ({
|
|
|
98
102
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
99
103
|
socket.send(
|
|
100
104
|
JSON.stringify({
|
|
101
|
-
type:
|
|
105
|
+
type: MessageSendSocketType.INQUIRY_WATCHING,
|
|
102
106
|
payload: { chat_inquiry_number: chatInquiryNumber }
|
|
103
107
|
})
|
|
104
108
|
);
|
|
105
|
-
console.log(
|
|
109
|
+
console.log(`[WebSocket] ${MessageSendSocketType.INQUIRY_WATCHING} 전송`);
|
|
106
110
|
}
|
|
107
111
|
}, []);
|
|
108
112
|
|
|
@@ -123,11 +127,11 @@ export const useSocketEventHandler = ({
|
|
|
123
127
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
124
128
|
socket.send(
|
|
125
129
|
JSON.stringify({
|
|
126
|
-
type:
|
|
130
|
+
type: MessageSendSocketType.INQUIRY_JOINED,
|
|
127
131
|
payload: { chat_inquiry_number: chatInquiryNumber }
|
|
128
132
|
})
|
|
129
133
|
);
|
|
130
|
-
console.log(
|
|
134
|
+
console.log(`[WebSocket] ${MessageSendSocketType.INQUIRY_JOINED} 전송`);
|
|
131
135
|
}
|
|
132
136
|
}, []);
|
|
133
137
|
|
|
@@ -148,11 +152,11 @@ export const useSocketEventHandler = ({
|
|
|
148
152
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
149
153
|
socket.send(
|
|
150
154
|
JSON.stringify({
|
|
151
|
-
type:
|
|
155
|
+
type: MessageSendSocketType.INQUIRY_LEFT,
|
|
152
156
|
payload: { chat_inquiry_number: chatInquiryNumber }
|
|
153
157
|
})
|
|
154
158
|
);
|
|
155
|
-
console.log(
|
|
159
|
+
console.log(`[WebSocket] ${MessageSendSocketType.INQUIRY_LEFT} 전송`);
|
|
156
160
|
}
|
|
157
161
|
}, []);
|
|
158
162
|
|
|
@@ -177,11 +181,11 @@ export const useSocketEventHandler = ({
|
|
|
177
181
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
178
182
|
socket.send(
|
|
179
183
|
JSON.stringify({
|
|
180
|
-
type:
|
|
184
|
+
type: MessageSendSocketType.HISTORY_ENTERED,
|
|
181
185
|
payload: { chat_inquiry_numbers: chatInquiryNumbers }
|
|
182
186
|
})
|
|
183
187
|
);
|
|
184
|
-
console.log(
|
|
188
|
+
console.log(`[WebSocket] ${MessageSendSocketType.HISTORY_ENTERED} 전송`);
|
|
185
189
|
}
|
|
186
190
|
}, []);
|
|
187
191
|
|
|
@@ -190,17 +194,17 @@ export const useSocketEventHandler = ({
|
|
|
190
194
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
191
195
|
socket.send(
|
|
192
196
|
JSON.stringify({
|
|
193
|
-
type:
|
|
197
|
+
type: MessageSendSocketType.HISTORY_EXITED,
|
|
194
198
|
payload: { chat_inquiry_numbers: chatInquiryNumbers }
|
|
195
199
|
})
|
|
196
200
|
);
|
|
197
|
-
console.log(
|
|
201
|
+
console.log(`[WebSocket] ${MessageSendSocketType.HISTORY_EXITED} 전송`);
|
|
198
202
|
}
|
|
199
203
|
}, []);
|
|
200
204
|
|
|
201
205
|
// Daeryuntalk API 초기화 메소드
|
|
202
206
|
const initializeDaeryuntalk = useCallback(
|
|
203
|
-
async (hashValue: string | null, isOpen: boolean, version?: string) => {
|
|
207
|
+
async (hashValue: string | null, isOpen: boolean, centerCode: string, version?: string) => {
|
|
204
208
|
console.log('[DaeryuntalkContext] 초기화 메소드 호출됨', version ? `버전: ${version}` : '기본 버전 사용');
|
|
205
209
|
try {
|
|
206
210
|
setIsLoading(true);
|
|
@@ -211,6 +215,7 @@ export const useSocketEventHandler = ({
|
|
|
211
215
|
isOpen,
|
|
212
216
|
setIsConnected,
|
|
213
217
|
isMobile,
|
|
218
|
+
centerCode,
|
|
214
219
|
socket => {
|
|
215
220
|
console.log('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 성공');
|
|
216
221
|
setIsConnected(true);
|
|
@@ -223,13 +228,13 @@ export const useSocketEventHandler = ({
|
|
|
223
228
|
// 메시지 생성
|
|
224
229
|
if (data.type === MessageSocketType.MESSAGE_CREATED && data.payload?.message) {
|
|
225
230
|
const newMessage = convertApiMessageToUiMessage(data.payload.message);
|
|
226
|
-
console.log('메세지 넣기 시작');
|
|
227
231
|
setMessages(prev => {
|
|
228
232
|
const isDuplicate = prev.some(
|
|
229
233
|
msg => msg.messageNumber === newMessage.messageNumber
|
|
230
234
|
);
|
|
231
235
|
return isDuplicate ? prev : [...prev, newMessage];
|
|
232
236
|
});
|
|
237
|
+
closeTyping();
|
|
233
238
|
}
|
|
234
239
|
|
|
235
240
|
if (data.type === MessageSocketType.MESSAGE_UPDATED) {
|
|
@@ -376,7 +381,7 @@ export const useSocketEventHandler = ({
|
|
|
376
381
|
[inquiryMainData]
|
|
377
382
|
);
|
|
378
383
|
const retryInitData = useCallback(async () => {
|
|
379
|
-
const authRes = await authenticateUser(
|
|
384
|
+
const authRes = await authenticateUser(centerCode);
|
|
380
385
|
const result = await getChatInquiryMain(authRes.data.channel_number);
|
|
381
386
|
setInquiryMainData(result.data as IChatInquiryMainDataResponse);
|
|
382
387
|
}, []);
|
|
@@ -5,7 +5,7 @@ export const useChatSocketState = (chatInquiryNumber, viewState, sendInquiryWatc
|
|
|
5
5
|
sendHeartbeat();
|
|
6
6
|
const heartbeatInterval = setInterval(() => {
|
|
7
7
|
sendHeartbeat();
|
|
8
|
-
},
|
|
8
|
+
}, 30000);
|
|
9
9
|
return () => clearInterval(heartbeatInterval);
|
|
10
10
|
}, [sendHeartbeat]);
|
|
11
11
|
// 2. 뷰 상태에 따른 watch / leave
|
|
@@ -6,7 +6,7 @@ import { DaeryuntalkProvider } from './DaeryuntalkContext';
|
|
|
6
6
|
import { DaeryuntalkToastProvider } from './Toast/DaeryuntalkToastProvider';
|
|
7
7
|
import mobile from 'is-mobile';
|
|
8
8
|
import ViewportHandler from './ViewportHandler';
|
|
9
|
-
const Daeryuntalk = ({ tel = '1800-7905' }) => {
|
|
9
|
+
const Daeryuntalk = ({ tel = '1800-7905', centerCode = 'CT0000' }) => {
|
|
10
10
|
const [isOpen, setIsOpen] = useState(false);
|
|
11
11
|
const [isMobile, setIsMobile] = useState(false);
|
|
12
12
|
// const isMobile = mobile();
|
|
@@ -77,7 +77,7 @@ const Daeryuntalk = ({ tel = '1800-7905' }) => {
|
|
|
77
77
|
return (<div className="daeryuntalk-wrapper">
|
|
78
78
|
<DaeryuntalkToastProvider>
|
|
79
79
|
<ViewportHandler />
|
|
80
|
-
<DaeryuntalkProvider propsTel={tel} isMobile={isMobile} onClose={closeModal}>
|
|
80
|
+
<DaeryuntalkProvider propsTel={tel} isMobile={isMobile} onClose={closeModal} centerCode={centerCode}>
|
|
81
81
|
{isMobile ? (isOpen ? null : (<ChatButton isOpen={isOpen} isMobile={isMobile} hashValue={hashValue} onClick={toggleChat}/>)) : (<ChatButton isOpen={isOpen} isMobile={isMobile} hashValue={hashValue} onClick={toggleChat}/>)}
|
|
82
82
|
<ChatWidget isOpen={hashValue ? true : isOpen} isMobile={isMobile} onClose={closeModal} hashValue={hashValue} setHashValue={setHashValue} animationState={animationState}/>
|
|
83
83
|
</DaeryuntalkProvider>
|
|
@@ -9,10 +9,11 @@ import mobile from 'is-mobile';
|
|
|
9
9
|
import ViewportHandler from './ViewportHandler';
|
|
10
10
|
|
|
11
11
|
type DaeryuntalkProps = {
|
|
12
|
-
tel
|
|
12
|
+
tel?: string;
|
|
13
|
+
centerCode?: string;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
const Daeryuntalk: React.FC<DaeryuntalkProps> = ({ tel = '1800-7905' }) => {
|
|
16
|
+
const Daeryuntalk: React.FC<DaeryuntalkProps> = ({ tel = '1800-7905', centerCode = 'CT0000' }) => {
|
|
16
17
|
const [isOpen, setIsOpen] = useState(false);
|
|
17
18
|
const [isMobile, setIsMobile] = useState(false);
|
|
18
19
|
|
|
@@ -95,7 +96,7 @@ const Daeryuntalk: React.FC<DaeryuntalkProps> = ({ tel = '1800-7905' }) => {
|
|
|
95
96
|
<div className="daeryuntalk-wrapper">
|
|
96
97
|
<DaeryuntalkToastProvider>
|
|
97
98
|
<ViewportHandler />
|
|
98
|
-
<DaeryuntalkProvider propsTel={tel} isMobile={isMobile} onClose={closeModal}>
|
|
99
|
+
<DaeryuntalkProvider propsTel={tel} isMobile={isMobile} onClose={closeModal} centerCode={centerCode}>
|
|
99
100
|
{isMobile ? (
|
|
100
101
|
isOpen ? null : (
|
|
101
102
|
<ChatButton
|
|
@@ -9,9 +9,9 @@ import Image from 'next/image';
|
|
|
9
9
|
import Link from 'next/link';
|
|
10
10
|
const SeoStrength = ({ initialData }) => {
|
|
11
11
|
const data = [
|
|
12
|
-
'
|
|
13
|
-
`<b>${initialData.pro_count}명 이상</b>의\n
|
|
14
|
-
|
|
12
|
+
'로펌 대륜만의 <b>AI·IT</b>\n기술 활용 소송 전략',
|
|
13
|
+
`<b>${initialData.pro_count}명 이상</b>의\n주요 구성원`,
|
|
14
|
+
`사건 규모에 따른\n<b>1~20인 법무법인 TF</b>` // Use template literal to inject initialData
|
|
15
15
|
];
|
|
16
16
|
const iconComponents = {
|
|
17
17
|
0: Icon1,
|
|
@@ -13,9 +13,9 @@ import Link from 'next/link';
|
|
|
13
13
|
|
|
14
14
|
const SeoStrength = ({ initialData }: { initialData: IInitialDataTypes }) => {
|
|
15
15
|
const data = [
|
|
16
|
-
'
|
|
17
|
-
`<b>${initialData.pro_count}명 이상</b>의\n
|
|
18
|
-
|
|
16
|
+
'로펌 대륜만의 <b>AI·IT</b>\n기술 활용 소송 전략',
|
|
17
|
+
`<b>${initialData.pro_count}명 이상</b>의\n주요 구성원`,
|
|
18
|
+
`사건 규모에 따른\n<b>1~20인 법무법인 TF</b>` // Use template literal to inject initialData
|
|
19
19
|
];
|
|
20
20
|
|
|
21
21
|
const iconComponents: any = {
|