@daeryun/dr_components 0.8.19 → 0.8.21
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/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/components/Daeryuntalk/ChatConversation.d.ts +1 -0
- package/dist/components/Daeryuntalk/ChatConversation.jsx +28 -26
- package/dist/components/Daeryuntalk/ChatConversation.tsx +28 -30
- package/dist/components/Daeryuntalk/ChatHomeView.d.ts +1 -0
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +34 -33
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +47 -33
- package/dist/components/Daeryuntalk/ChatMessage.jsx +3 -4
- package/dist/components/Daeryuntalk/ChatMessage.tsx +1 -3
- package/dist/components/Daeryuntalk/ChatWidget.jsx +6 -6
- package/dist/components/Daeryuntalk/ChatWidget.tsx +11 -6
- package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +2 -1
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +6 -2
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +9 -3
- package/dist/components/Daeryuntalk/HistoryView.d.ts +1 -0
- package/dist/components/Daeryuntalk/HistoryView.jsx +1 -1
- package/dist/components/Daeryuntalk/HistoryView.tsx +3 -1
- package/dist/components/Daeryuntalk/NavigationFooter.d.ts +3 -0
- package/dist/components/Daeryuntalk/NavigationFooter.jsx +9 -2
- package/dist/components/Daeryuntalk/NavigationFooter.tsx +24 -2
- package/dist/components/Daeryuntalk/NoticeMessage.jsx +1 -1
- package/dist/components/Daeryuntalk/NoticeMessage.tsx +1 -1
- package/dist/components/Daeryuntalk/ViewportHandler.jsx +11 -17
- package/dist/components/Daeryuntalk/ViewportHandler.tsx +13 -17
- package/dist/components/Daeryuntalk/_enums/socket_type.js +2 -2
- package/dist/components/Daeryuntalk/_enums/socket_type.ts +2 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +2 -5
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +2 -4
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.d.ts +1 -1
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.js +18 -13
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.ts +24 -16
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +6 -3
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +27 -19
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +149 -119
- package/dist/components/Daeryuntalk/index.jsx +10 -8
- package/dist/components/Daeryuntalk/index.tsx +16 -14
- package/dist/components/page/Login/_fetch/fetch.js +0 -1
- package/dist/components/page/Login/_fetch/fetch.ts +0 -1
- package/dist/styles/globals.css +17 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -2,30 +2,24 @@
|
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
export default function ViewportHandler() {
|
|
4
4
|
useEffect(() => {
|
|
5
|
+
var _a;
|
|
6
|
+
const originalContent = (_a = document.querySelector('meta[name="viewport"]')) === null || _a === void 0 ? void 0 : _a.getAttribute('content');
|
|
5
7
|
function updateViewport() {
|
|
6
|
-
|
|
7
|
-
if (!viewportMeta)
|
|
8
|
-
|
|
9
|
-
viewportMeta.name = 'viewport';
|
|
10
|
-
document.head.appendChild(viewportMeta);
|
|
11
|
-
}
|
|
12
|
-
const currentContent = viewportMeta.getAttribute('content');
|
|
13
|
-
let newContent = '';
|
|
8
|
+
const viewportMeta = document.querySelector('meta[name="viewport"]');
|
|
9
|
+
if (!viewportMeta)
|
|
10
|
+
return;
|
|
14
11
|
if (window.screen.width < 360) {
|
|
15
12
|
const scale = window.screen.width / 360;
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
newContent = `width=device-width, initial-scale=1, user-scalable=yes, maximum-scale=5, viewport-fit=contain`;
|
|
20
|
-
}
|
|
21
|
-
if (currentContent !== newContent) {
|
|
22
|
-
viewportMeta.setAttribute('content', newContent);
|
|
13
|
+
viewportMeta.setAttribute('content', `width=device-width, initial-scale=${scale.toFixed(2)}, user-scalable=yes, maximum-scale=5, viewport-fit=contain`);
|
|
23
14
|
}
|
|
24
15
|
}
|
|
25
16
|
updateViewport();
|
|
26
|
-
|
|
17
|
+
// cleanup: 원래 상태로 복원
|
|
27
18
|
return () => {
|
|
28
|
-
|
|
19
|
+
const viewportMeta = document.querySelector('meta[name="viewport"]');
|
|
20
|
+
if (viewportMeta && originalContent) {
|
|
21
|
+
viewportMeta.setAttribute('content', originalContent);
|
|
22
|
+
}
|
|
29
23
|
};
|
|
30
24
|
}, []);
|
|
31
25
|
return null;
|
|
@@ -4,34 +4,30 @@ import { useEffect } from 'react';
|
|
|
4
4
|
|
|
5
5
|
export default function ViewportHandler() {
|
|
6
6
|
useEffect(() => {
|
|
7
|
+
const originalContent = document.querySelector('meta[name="viewport"]')?.getAttribute('content');
|
|
8
|
+
|
|
7
9
|
function updateViewport() {
|
|
8
|
-
|
|
9
|
-
if (!viewportMeta) {
|
|
10
|
-
viewportMeta = document.createElement('meta');
|
|
11
|
-
viewportMeta.name = 'viewport';
|
|
12
|
-
document.head.appendChild(viewportMeta);
|
|
13
|
-
}
|
|
10
|
+
const viewportMeta = document.querySelector('meta[name="viewport"]') as HTMLMetaElement;
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
if (!viewportMeta) return;
|
|
16
13
|
|
|
17
|
-
let newContent = '';
|
|
18
14
|
if (window.screen.width < 360) {
|
|
19
15
|
const scale = window.screen.width / 360;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (currentContent !== newContent) {
|
|
26
|
-
viewportMeta.setAttribute('content', newContent);
|
|
16
|
+
viewportMeta.setAttribute(
|
|
17
|
+
'content',
|
|
18
|
+
`width=device-width, initial-scale=${scale.toFixed(2)}, user-scalable=yes, maximum-scale=5, viewport-fit=contain`
|
|
19
|
+
);
|
|
27
20
|
}
|
|
28
21
|
}
|
|
29
22
|
|
|
30
23
|
updateViewport();
|
|
31
|
-
window.addEventListener('resize', updateViewport);
|
|
32
24
|
|
|
25
|
+
// cleanup: 원래 상태로 복원
|
|
33
26
|
return () => {
|
|
34
|
-
|
|
27
|
+
const viewportMeta = document.querySelector('meta[name="viewport"]') as HTMLMetaElement;
|
|
28
|
+
if (viewportMeta && originalContent) {
|
|
29
|
+
viewportMeta.setAttribute('content', originalContent);
|
|
30
|
+
}
|
|
35
31
|
};
|
|
36
32
|
}, []);
|
|
37
33
|
|
|
@@ -11,10 +11,10 @@ export var MessageSocketType;
|
|
|
11
11
|
// -> 해당 메시지 UI 삭제 처리
|
|
12
12
|
/** 문의 목록에서 보여지는 미리보기 정보 갱신 */
|
|
13
13
|
MessageSocketType["INQUIRY_PREVIEW_UPDATED"] = "inquiry.preview.updated";
|
|
14
|
-
// ->
|
|
14
|
+
// -> 미처리
|
|
15
15
|
/** 새로운 문의가 생성됨 */
|
|
16
16
|
MessageSocketType["INQUIRY_OPENED"] = "inquiry.opened";
|
|
17
|
-
// ->
|
|
17
|
+
// -> 미처리
|
|
18
18
|
/** 문의 워크플로우 변경됨 */
|
|
19
19
|
MessageSocketType["INQUIRY_WORKFLOW_UPDATED"] = "inquiry.workflow.updated";
|
|
20
20
|
// -> 워크플로우 업데이트 처리
|
|
@@ -13,11 +13,11 @@ export enum MessageSocketType {
|
|
|
13
13
|
|
|
14
14
|
/** 문의 목록에서 보여지는 미리보기 정보 갱신 */
|
|
15
15
|
INQUIRY_PREVIEW_UPDATED = 'inquiry.preview.updated',
|
|
16
|
-
// ->
|
|
16
|
+
// -> 미처리
|
|
17
17
|
|
|
18
18
|
/** 새로운 문의가 생성됨 */
|
|
19
19
|
INQUIRY_OPENED = 'inquiry.opened',
|
|
20
|
-
// ->
|
|
20
|
+
// -> 미처리
|
|
21
21
|
|
|
22
22
|
/** 문의 워크플로우 변경됨 */
|
|
23
23
|
INQUIRY_WORKFLOW_UPDATED = 'inquiry.workflow.updated',
|
|
@@ -11,20 +11,17 @@ import { useCallback } from 'react';
|
|
|
11
11
|
import { attendChatRoomByHistory, chatUserUpdate as apiChatUserUpdate, chatWorkFlow, chatWorkFlowBack, generateChatInquiry, getChatInquiryDetailNew, getChatInquiryMessageList, sendChatMessage } from '../../_api';
|
|
12
12
|
import { convertApiMessageObjectToUiMessageObject, convertApiMessageToUiMessage } from '../../_lib';
|
|
13
13
|
import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
|
|
14
|
-
import { usePathname, useSearchParams } from 'next/navigation';
|
|
15
14
|
import { useFullURL } from './useFullURL';
|
|
16
15
|
export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, setInquiryMainData }) => {
|
|
17
16
|
const toast = useDaeryunTalkToast();
|
|
18
|
-
const pathname = usePathname(); // => "/daeryuntalk"
|
|
19
|
-
const searchParams = useSearchParams(); // => URLSearchParams 객체
|
|
20
17
|
const fullUrl = useFullURL();
|
|
21
|
-
console.log('fullUrl', fullUrl);
|
|
22
18
|
// 채팅 시작 (문의하기 버튼 클릭 시)
|
|
23
19
|
const startChat = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
20
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
25
21
|
try {
|
|
26
22
|
setIsLoading(true);
|
|
27
23
|
console.log('[DaeryuntalkContext] 채팅 시작 요청');
|
|
24
|
+
console.log('inquiryMainData', inquiryMainData);
|
|
28
25
|
// 기존 문의가 있는지 확인
|
|
29
26
|
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()) !== '';
|
|
30
27
|
let currentChatInquiryNumber = '';
|
|
@@ -109,7 +106,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
|
|
|
109
106
|
finally {
|
|
110
107
|
setIsLoading(false);
|
|
111
108
|
}
|
|
112
|
-
}), [inquiryMainData]);
|
|
109
|
+
}), [inquiryMainData, fullUrl]);
|
|
113
110
|
// 선택된 히스토리의 채팅창 시작
|
|
114
111
|
const startSelectedChat = useCallback((chatInquiryNumber) => __awaiter(void 0, void 0, void 0, function* () {
|
|
115
112
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
@@ -44,15 +44,13 @@ export const useChatHandler = ({
|
|
|
44
44
|
setInquiryMainData
|
|
45
45
|
}: props) => {
|
|
46
46
|
const toast = useDaeryunTalkToast();
|
|
47
|
-
const pathname = usePathname(); // => "/daeryuntalk"
|
|
48
|
-
const searchParams = useSearchParams(); // => URLSearchParams 객체
|
|
49
47
|
const fullUrl = useFullURL();
|
|
50
|
-
console.log('fullUrl', fullUrl);
|
|
51
48
|
// 채팅 시작 (문의하기 버튼 클릭 시)
|
|
52
49
|
const startChat = useCallback(async () => {
|
|
53
50
|
try {
|
|
54
51
|
setIsLoading(true);
|
|
55
52
|
console.log('[DaeryuntalkContext] 채팅 시작 요청');
|
|
53
|
+
console.log('inquiryMainData', inquiryMainData);
|
|
56
54
|
|
|
57
55
|
// 기존 문의가 있는지 확인
|
|
58
56
|
const hasExistingInquiry =
|
|
@@ -147,7 +145,7 @@ export const useChatHandler = ({
|
|
|
147
145
|
} finally {
|
|
148
146
|
setIsLoading(false);
|
|
149
147
|
}
|
|
150
|
-
}, [inquiryMainData]);
|
|
148
|
+
}, [inquiryMainData, fullUrl]);
|
|
151
149
|
|
|
152
150
|
// 선택된 히스토리의 채팅창 시작
|
|
153
151
|
const startSelectedChat = useCallback(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useChatSocketState: (chatInquiryNumber: string | null, viewState: "home" | "conversation" | "history",
|
|
1
|
+
export declare const useChatSocketState: (chatInquiryNumber: string | null, viewState: "home" | "conversation" | "history", sendInquiryWatching: (chatInquiryNumber: string) => void, sendInquiryJoined: (chatInquiryNumber: string) => void, sendHeartbeat: () => void, sendInquiryLeft: (chatInquiryNumber: string) => void) => void;
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
export const useChatSocketState = (chatInquiryNumber, viewState, sendHeartbeat, sendInquiryLeft) => {
|
|
2
|
+
export const useChatSocketState = (chatInquiryNumber, viewState, sendInquiryWatching, sendInquiryJoined, sendHeartbeat, sendInquiryLeft) => {
|
|
3
|
+
// 1. 공통 하트비트 (항상 실행)
|
|
3
4
|
useEffect(() => {
|
|
4
|
-
|
|
5
|
+
sendHeartbeat();
|
|
6
|
+
const heartbeatInterval = setInterval(() => {
|
|
7
|
+
sendHeartbeat();
|
|
8
|
+
}, 5000);
|
|
9
|
+
return () => clearInterval(heartbeatInterval);
|
|
10
|
+
}, [sendHeartbeat]);
|
|
11
|
+
// 2. 뷰 상태에 따른 watch / leave
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!chatInquiryNumber)
|
|
5
14
|
return;
|
|
6
|
-
}
|
|
7
15
|
if (viewState === 'conversation') {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
16
|
+
sendInquiryJoined(chatInquiryNumber);
|
|
17
|
+
sendInquiryWatching(chatInquiryNumber);
|
|
18
|
+
const watchingInterval = setInterval(() => {
|
|
19
|
+
sendInquiryWatching(chatInquiryNumber);
|
|
12
20
|
}, 5000);
|
|
13
|
-
return () => clearInterval(
|
|
21
|
+
return () => clearInterval(watchingInterval);
|
|
14
22
|
}
|
|
15
|
-
// 접속 채팅이 있다면 떠나감 처리
|
|
16
23
|
else {
|
|
17
|
-
|
|
18
|
-
sendInquiryLeft(chatInquiryNumber);
|
|
19
|
-
}
|
|
24
|
+
sendInquiryLeft(chatInquiryNumber);
|
|
20
25
|
}
|
|
21
|
-
}, [chatInquiryNumber, viewState,
|
|
26
|
+
}, [chatInquiryNumber, viewState, sendInquiryWatching, sendInquiryLeft]);
|
|
22
27
|
};
|
|
@@ -3,28 +3,36 @@ import { useEffect } from 'react';
|
|
|
3
3
|
export const useChatSocketState = (
|
|
4
4
|
chatInquiryNumber: string | null,
|
|
5
5
|
viewState: 'home' | 'conversation' | 'history',
|
|
6
|
-
|
|
6
|
+
sendInquiryWatching: (chatInquiryNumber: string) => void,
|
|
7
|
+
sendInquiryJoined: (chatInquiryNumber: string) => void,
|
|
8
|
+
sendHeartbeat: () => void,
|
|
7
9
|
sendInquiryLeft: (chatInquiryNumber: string) => void
|
|
8
10
|
) => {
|
|
11
|
+
// 1. 공통 하트비트 (항상 실행)
|
|
9
12
|
useEffect(() => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
sendHeartbeat();
|
|
14
|
+
const heartbeatInterval = setInterval(() => {
|
|
15
|
+
sendHeartbeat();
|
|
16
|
+
}, 5000);
|
|
17
|
+
|
|
18
|
+
return () => clearInterval(heartbeatInterval);
|
|
19
|
+
}, [sendHeartbeat]);
|
|
20
|
+
|
|
21
|
+
// 2. 뷰 상태에 따른 watch / leave
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!chatInquiryNumber) return;
|
|
13
24
|
|
|
14
25
|
if (viewState === 'conversation') {
|
|
15
|
-
|
|
16
|
-
|
|
26
|
+
sendInquiryJoined(chatInquiryNumber);
|
|
27
|
+
sendInquiryWatching(chatInquiryNumber);
|
|
17
28
|
|
|
18
|
-
const
|
|
19
|
-
|
|
29
|
+
const watchingInterval = setInterval(() => {
|
|
30
|
+
sendInquiryWatching(chatInquiryNumber);
|
|
20
31
|
}, 5000);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (chatInquiryNumber) {
|
|
26
|
-
sendInquiryLeft(chatInquiryNumber);
|
|
27
|
-
}
|
|
32
|
+
|
|
33
|
+
return () => clearInterval(watchingInterval);
|
|
34
|
+
} else {
|
|
35
|
+
sendInquiryLeft(chatInquiryNumber);
|
|
28
36
|
}
|
|
29
|
-
}, [chatInquiryNumber, viewState,
|
|
37
|
+
}, [chatInquiryNumber, viewState, sendInquiryWatching, sendInquiryLeft]);
|
|
30
38
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
|
2
2
|
import { Message } from '../../_types/message';
|
|
3
|
-
import { IChatInquiryMainDataResponse } from '../../_api/daeryuntalk/type/response';
|
|
3
|
+
import { History, IChatInquiryMainDataResponse } from '../../_api/daeryuntalk/type/response';
|
|
4
4
|
import { MessageObject } from '../../_types/message_object';
|
|
5
5
|
interface props {
|
|
6
6
|
setIsConnected: Dispatch<SetStateAction<boolean>>;
|
|
@@ -11,13 +11,16 @@ interface props {
|
|
|
11
11
|
setInquiryMainData: Dispatch<SetStateAction<IChatInquiryMainDataResponse | null>>;
|
|
12
12
|
socketRef: MutableRefObject<WebSocket | null>;
|
|
13
13
|
setInquiryStatus: Dispatch<SetStateAction<string>>;
|
|
14
|
+
setHistoryList: Dispatch<SetStateAction<History[]>>;
|
|
15
|
+
historyList: History[];
|
|
14
16
|
}
|
|
15
|
-
export declare const useSocketEventHandler: ({ setIsConnected, setIsLoading, setMessages, setInquiryMainData, socketRef, setWorkFlowStack, setMessageObject, setInquiryStatus }: props) => {
|
|
17
|
+
export declare const useSocketEventHandler: ({ setIsConnected, setIsLoading, setMessages, setInquiryMainData, socketRef, setWorkFlowStack, setMessageObject, setInquiryStatus, setHistoryList, historyList }: props) => {
|
|
16
18
|
initializeDaeryuntalk: (hashValue: string | null, version?: string) => Promise<void>;
|
|
17
|
-
sendHeartbeat: (
|
|
19
|
+
sendHeartbeat: () => void;
|
|
18
20
|
sendInquiryJoined: (chatInquiryNumber: string) => void;
|
|
19
21
|
sendInquiryLeft: (chatInquiryNumber: string) => void;
|
|
20
22
|
sendHistoryEntered: (chatInquiryNumbers: string[]) => void;
|
|
21
23
|
sendHistoryLeft: (chatInquiryNumbers: string[]) => void;
|
|
24
|
+
sendInquiryWatching: (chatInquiryNumber: string) => void;
|
|
22
25
|
};
|
|
23
26
|
export {};
|
|
@@ -13,7 +13,7 @@ import { convertApiMessageToUiMessage, convertSocketObjectToUiMessage } from '..
|
|
|
13
13
|
import { MessageSocketType } from '../../_enums/socket_type';
|
|
14
14
|
import { InquiryStatus } from '../../_enums/ask-status';
|
|
15
15
|
import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
|
|
16
|
-
export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessages, setInquiryMainData, socketRef, setWorkFlowStack, setMessageObject, setInquiryStatus }) => {
|
|
16
|
+
export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessages, setInquiryMainData, socketRef, setWorkFlowStack, setMessageObject, setInquiryStatus, setHistoryList, historyList }) => {
|
|
17
17
|
const toast = useDaeryunTalkToast();
|
|
18
18
|
/**
|
|
19
19
|
* 1. heartbeat
|
|
@@ -27,11 +27,21 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
27
27
|
* }
|
|
28
28
|
* }
|
|
29
29
|
*/
|
|
30
|
-
const sendHeartbeat = useCallback((
|
|
30
|
+
const sendHeartbeat = useCallback(() => {
|
|
31
31
|
const socket = socketRef.current;
|
|
32
32
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
33
33
|
socket.send(JSON.stringify({
|
|
34
34
|
type: 'heartbeat',
|
|
35
|
+
payload: {}
|
|
36
|
+
}));
|
|
37
|
+
console.log('[WebSocket] heartbeat 전송');
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
const sendInquiryWatching = useCallback((chatInquiryNumber) => {
|
|
41
|
+
const socket = socketRef.current;
|
|
42
|
+
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
43
|
+
socket.send(JSON.stringify({
|
|
44
|
+
type: 'inquiry.watching',
|
|
35
45
|
payload: { chat_inquiry_number: chatInquiryNumber }
|
|
36
46
|
}));
|
|
37
47
|
console.log('[WebSocket] heartbeat 전송');
|
|
@@ -124,18 +134,6 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
124
134
|
try {
|
|
125
135
|
setIsLoading(true);
|
|
126
136
|
console.log('[DaeryuntalkContext] 로딩 상태 설정: true');
|
|
127
|
-
// // 만약 해쉬값이 있으면 이것부터 해여함
|
|
128
|
-
// if (hashValue) {
|
|
129
|
-
// const hashAuth = await followupAttend({ token: hashValue });
|
|
130
|
-
// console.log('hashAuth', hashAuth);
|
|
131
|
-
// if (hashAuth?.result_info?.result_type_cd === 'OK' || hashAuth?.result_info?.result_cd === 'OK') {
|
|
132
|
-
// // 인증 완
|
|
133
|
-
// } else {
|
|
134
|
-
// toast.error('인증에 실패했습니다.');
|
|
135
|
-
// // window.location.href = '/';
|
|
136
|
-
// return;
|
|
137
|
-
// }
|
|
138
|
-
// }
|
|
139
137
|
const { inquiryData, socket, hashAuth } = yield apiInitializeDaeryuntalk(hashValue || '', socket => {
|
|
140
138
|
console.log('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 성공');
|
|
141
139
|
setIsConnected(true);
|
|
@@ -176,7 +174,16 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
176
174
|
}
|
|
177
175
|
// 안읽음 count
|
|
178
176
|
if (data.type === MessageSocketType.INQUIRY_PREVIEW_UPDATED) {
|
|
179
|
-
|
|
177
|
+
const socketData = data === null || data === void 0 ? void 0 : data.payload;
|
|
178
|
+
setHistoryList((prev) => prev.map(item => item.chat_inquiry_number === socketData.chat_inquiry_number
|
|
179
|
+
? {
|
|
180
|
+
chat_inquiry_number: socketData.chat_inquiry_number,
|
|
181
|
+
customer_name: item.customer_name,
|
|
182
|
+
recent_message_content: socketData.recent_message_content,
|
|
183
|
+
recent_message_date_time: socketData.recent_message_date_time,
|
|
184
|
+
unread_message_count: Number(socketData.unread_message_count)
|
|
185
|
+
}
|
|
186
|
+
: item));
|
|
180
187
|
}
|
|
181
188
|
// 새로운 문의가 생성됨
|
|
182
189
|
if (data.type === MessageSocketType.INQUIRY_OPENED) {
|
|
@@ -184,7 +191,6 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
184
191
|
// 문의 워크플로우 변경됨
|
|
185
192
|
if (data.type === MessageSocketType.INQUIRY_WORKFLOW_UPDATED) {
|
|
186
193
|
const socketPayloadData = data === null || data === void 0 ? void 0 : data.payload;
|
|
187
|
-
console.log('socketPayloadData', socketPayloadData);
|
|
188
194
|
// 워크플로우 스택 업데이트
|
|
189
195
|
setWorkFlowStack(socketPayloadData.work_flow_progress_stack);
|
|
190
196
|
// 오브젝트 업데이트
|
|
@@ -197,7 +203,6 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
197
203
|
// 업무 관리자 배정
|
|
198
204
|
if (data.type === MessageSocketType.INQUIRY_ASSIGNED) {
|
|
199
205
|
const payload = data.payload;
|
|
200
|
-
// 이거는 찾아서 count를 처리해줘야하나??
|
|
201
206
|
}
|
|
202
207
|
// 할당된 상담원이 해제됨
|
|
203
208
|
if (data.type === MessageSocketType.INQUIRY_UNASSIGNED) {
|
|
@@ -210,8 +215,10 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
210
215
|
console.error('[DaeryuntalkContext] 웹소켓 메시지 처리 오류:', error);
|
|
211
216
|
}
|
|
212
217
|
});
|
|
218
|
+
console.log('hashValue', hashValue);
|
|
213
219
|
if (hashValue) {
|
|
214
220
|
if (((_a = hashAuth === null || hashAuth === void 0 ? void 0 : hashAuth.result_info) === null || _a === void 0 ? void 0 : _a.result_cd) === 'OK' || ((_b = hashAuth === null || hashAuth === void 0 ? void 0 : hashAuth.result_info) === null || _b === void 0 ? void 0 : _b.result_type_cd) === 'OK') {
|
|
221
|
+
console.log('해쉬 인증 완료');
|
|
215
222
|
}
|
|
216
223
|
else {
|
|
217
224
|
toast.error('인증에 실패했습니다.');
|
|
@@ -232,13 +239,14 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
232
239
|
console.log('[DaeryuntalkContext] 로딩 상태 설정: false');
|
|
233
240
|
setIsLoading(false);
|
|
234
241
|
}
|
|
235
|
-
}), []);
|
|
242
|
+
}), [historyList]);
|
|
236
243
|
return {
|
|
237
244
|
initializeDaeryuntalk,
|
|
238
245
|
sendHeartbeat,
|
|
239
246
|
sendInquiryJoined,
|
|
240
247
|
sendInquiryLeft,
|
|
241
248
|
sendHistoryEntered,
|
|
242
|
-
sendHistoryLeft
|
|
249
|
+
sendHistoryLeft,
|
|
250
|
+
sendInquiryWatching
|
|
243
251
|
};
|
|
244
252
|
};
|