@daeryun/dr_components 0.8.19 → 0.8.20
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 +3 -3
- package/dist/components/Daeryuntalk/ChatConversation.tsx +4 -3
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +28 -28
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +30 -28
- package/dist/components/Daeryuntalk/ChatWidget.jsx +4 -4
- package/dist/components/Daeryuntalk/ChatWidget.tsx +4 -4
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +3 -1
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +3 -1
- 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/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/_hooks/talkprovider/useSocketEventHandler.d.ts +4 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +12 -17
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +131 -117
- 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 +9 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -26,7 +26,6 @@ type ChatHomeViewProps = {
|
|
|
26
26
|
};
|
|
27
27
|
const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, setHashValue, isMobile }) => {
|
|
28
28
|
const {
|
|
29
|
-
isLoading: isProviderLoading,
|
|
30
29
|
isConnected,
|
|
31
30
|
isAuthenticated,
|
|
32
31
|
historyList,
|
|
@@ -46,19 +45,36 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, setHashValue, is
|
|
|
46
45
|
const [mainData, setMainData] = useState<IChatInquiryMainDataResponse | null>(null);
|
|
47
46
|
const [isLoading, setIsLoading] = useState(false);
|
|
48
47
|
const { containerRef, isScroll, isBottom, checkScroll } = useScrollShadow<HTMLDivElement>();
|
|
48
|
+
const toast = useDaeryunTalkToast();
|
|
49
49
|
// 아직 커버이미지 url이 안나옴
|
|
50
50
|
const backgroundImage = mainData?.sleeve_image_url ? mainData.sleeve_image_url : DaeryuntalkIntro;
|
|
51
|
+
const handleStartChat = async () => {
|
|
52
|
+
try {
|
|
53
|
+
setIsLoading(true);
|
|
54
|
+
|
|
55
|
+
// 채팅 시작 - 새 문의 생성 또는 기존 문의 조회 처리
|
|
56
|
+
await startChat();
|
|
57
|
+
// 대화 화면으로 전환
|
|
58
|
+
setViewState('conversation');
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error('채팅 시작 실패:', error);
|
|
61
|
+
} finally {
|
|
62
|
+
setIsLoading(false);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
51
66
|
useEffect(() => {
|
|
52
|
-
if (hashValue && isConnected
|
|
67
|
+
if (hashValue && isConnected) {
|
|
68
|
+
console.log('해쉬 실행');
|
|
53
69
|
handleStartChat();
|
|
70
|
+
} else {
|
|
71
|
+
console.log('해쉬 실행안함');
|
|
54
72
|
}
|
|
55
73
|
}, [hashValue, isConnected]);
|
|
56
74
|
useEffect(() => {
|
|
57
75
|
checkScroll();
|
|
58
76
|
}, [mainData]);
|
|
59
77
|
|
|
60
|
-
const toast = useDaeryunTalkToast();
|
|
61
|
-
|
|
62
78
|
useEffect(() => {
|
|
63
79
|
if (viewState === 'history') {
|
|
64
80
|
goGetHistoryList({});
|
|
@@ -72,34 +88,14 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, setHashValue, is
|
|
|
72
88
|
}, [inquiryMainData]);
|
|
73
89
|
|
|
74
90
|
useEffect(() => {
|
|
75
|
-
if (isAuthenticated) {
|
|
91
|
+
if (isConnected && isAuthenticated) {
|
|
76
92
|
sendHistoryEntered(historyList ? historyList.map(item => item.chat_inquiry_number) : []);
|
|
77
93
|
}
|
|
78
|
-
|
|
79
|
-
return () => {
|
|
80
|
-
sendHistoryLeft(historyList ? historyList.map(item => item.chat_inquiry_number) : []);
|
|
81
|
-
};
|
|
82
|
-
}, [isAuthenticated]);
|
|
94
|
+
}, [isConnected, isAuthenticated, historyList, viewState]);
|
|
83
95
|
|
|
84
96
|
// 채팅창관리
|
|
85
97
|
useChatSocketState(chatInquiryNumber, viewState, sendHeartbeat, sendInquiryLeft);
|
|
86
98
|
|
|
87
|
-
// 홈에서 사용
|
|
88
|
-
const handleStartChat = async () => {
|
|
89
|
-
try {
|
|
90
|
-
setIsLoading(true);
|
|
91
|
-
|
|
92
|
-
// 채팅 시작 - 새 문의 생성 또는 기존 문의 조회 처리
|
|
93
|
-
await startChat();
|
|
94
|
-
// 대화 화면으로 전환
|
|
95
|
-
setViewState('conversation');
|
|
96
|
-
} catch (error) {
|
|
97
|
-
console.error('채팅 시작 실패:', error);
|
|
98
|
-
} finally {
|
|
99
|
-
setIsLoading(false);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
99
|
// 히스토리에서 사용
|
|
104
100
|
const handleNewStartChat = async () => {
|
|
105
101
|
try {
|
|
@@ -142,8 +138,12 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, setHashValue, is
|
|
|
142
138
|
|
|
143
139
|
const renderWithNavigation = (content: React.ReactNode, activeView: 'home' | 'history' | 'conversation') => {
|
|
144
140
|
return (
|
|
145
|
-
<main
|
|
146
|
-
|
|
141
|
+
<main
|
|
142
|
+
className={`${isMobile ? 'h-[100dvh] w-screen' : ''} relative flex items-center justify-center rounded-[30px]`}
|
|
143
|
+
>
|
|
144
|
+
<div
|
|
145
|
+
className={`${isMobile ? 'h-[100dvh] w-full' : ' h-[690px] w-[390px]'} relative overflow-hidden rounded-[30px] bg-white shadow-[0px_12px_60px_5px_rgba(0,0,0,0.3)]`}
|
|
146
|
+
>
|
|
147
147
|
<div className="flex h-full flex-col">
|
|
148
148
|
<div className="flex-1 overflow-hidden">{content}</div>
|
|
149
149
|
|
|
@@ -166,6 +166,7 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, setHashValue, is
|
|
|
166
166
|
onBackClick={handleBackToHome}
|
|
167
167
|
isActive={viewState === 'conversation'}
|
|
168
168
|
onChatNew={handleNewStartChat}
|
|
169
|
+
isMobile={isMobile}
|
|
169
170
|
/>,
|
|
170
171
|
'conversation'
|
|
171
172
|
);
|
|
@@ -180,6 +181,7 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, setHashValue, is
|
|
|
180
181
|
isAuthenticated={isAuthenticated ?? false}
|
|
181
182
|
historyLit={historyList ?? []}
|
|
182
183
|
goGetHistoryList={goGetHistoryList}
|
|
184
|
+
isMobile={isMobile}
|
|
183
185
|
/>,
|
|
184
186
|
'history'
|
|
185
187
|
);
|
|
@@ -10,16 +10,16 @@ const ChatWidget = ({ isOpen, isMobile, onClose, hashValue, setHashValue }) => {
|
|
|
10
10
|
return (<>
|
|
11
11
|
<ImageViewer />
|
|
12
12
|
|
|
13
|
-
<div className="relative z-[999998]
|
|
13
|
+
<div className="relative z-[999998] ">
|
|
14
14
|
<div className={`
|
|
15
15
|
fixed
|
|
16
16
|
w-full transform
|
|
17
17
|
bg-white shadow-[0px_4px_10px_0px_#00000026]
|
|
18
18
|
${isMobile ? '' : 'duration-300 ease-in-out'}
|
|
19
19
|
${isHash && isMobile
|
|
20
|
-
? 'inset-0 h-
|
|
20
|
+
? 'inset-0 h-[100dvh] w-screen rounded-none'
|
|
21
21
|
: isMobile || isHash
|
|
22
|
-
? 'inset-0 h-
|
|
22
|
+
? 'inset-0 h-[100dvh] w-screen rounded-none'
|
|
23
23
|
: 'bottom-[165px] right-[30px] max-w-[390px] rounded-[30px] lg:bottom-[110px]'}
|
|
24
24
|
|
|
25
25
|
${isMobile
|
|
@@ -30,7 +30,7 @@ const ChatWidget = ({ isOpen, isMobile, onClose, hashValue, setHashValue }) => {
|
|
|
30
30
|
? 'translate-y-0 scale-100 opacity-100'
|
|
31
31
|
: 'pointer-events-none translate-y-6 opacity-0'}
|
|
32
32
|
`}>
|
|
33
|
-
<div ref={containerRef} className=
|
|
33
|
+
<div ref={containerRef} className={`${isMobile ? 'rounded-none' : 'rounded-[30px]'} no-scrollbar relative flex h-full items-center justify-center overflow-auto bg-white`}>
|
|
34
34
|
<ChatHomeView hashValue={hashValue} setHashValue={setHashValue} isMobile={isMobile}/>
|
|
35
35
|
</div>
|
|
36
36
|
|
|
@@ -21,7 +21,7 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen, isMobile, onClose, hash
|
|
|
21
21
|
<>
|
|
22
22
|
<ImageViewer />
|
|
23
23
|
|
|
24
|
-
<div className="relative z-[999998]
|
|
24
|
+
<div className="relative z-[999998] ">
|
|
25
25
|
<div
|
|
26
26
|
className={`
|
|
27
27
|
fixed
|
|
@@ -30,9 +30,9 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen, isMobile, onClose, hash
|
|
|
30
30
|
${isMobile ? '' : 'duration-300 ease-in-out'}
|
|
31
31
|
${
|
|
32
32
|
isHash && isMobile
|
|
33
|
-
? 'inset-0 h-
|
|
33
|
+
? 'inset-0 h-[100dvh] w-screen rounded-none'
|
|
34
34
|
: isMobile || isHash
|
|
35
|
-
? 'inset-0 h-
|
|
35
|
+
? 'inset-0 h-[100dvh] w-screen rounded-none'
|
|
36
36
|
: 'bottom-[165px] right-[30px] max-w-[390px] rounded-[30px] lg:bottom-[110px]'
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -49,7 +49,7 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen, isMobile, onClose, hash
|
|
|
49
49
|
>
|
|
50
50
|
<div
|
|
51
51
|
ref={containerRef}
|
|
52
|
-
className=
|
|
52
|
+
className={`${isMobile ? 'rounded-none' : 'rounded-[30px]'} no-scrollbar relative flex h-full items-center justify-center overflow-auto bg-white`}
|
|
53
53
|
>
|
|
54
54
|
<ChatHomeView hashValue={hashValue} setHashValue={setHashValue} isMobile={isMobile} />
|
|
55
55
|
</div>
|
|
@@ -163,7 +163,9 @@ export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ childr
|
|
|
163
163
|
setWorkFlowStack,
|
|
164
164
|
setMessageObject,
|
|
165
165
|
socketRef: socketRef,
|
|
166
|
-
setInquiryStatus
|
|
166
|
+
setInquiryStatus,
|
|
167
|
+
setHistoryList,
|
|
168
|
+
historyList
|
|
167
169
|
});
|
|
168
170
|
|
|
169
171
|
// MSG15591497825895676
|
|
@@ -6,7 +6,7 @@ import PrevIcon from '../../asset/images/daeryuntalk/prev.svg';
|
|
|
6
6
|
import AuthForm from './History/AuthForm';
|
|
7
7
|
import { useScrollShadow } from './_hooks/useScrollShadow';
|
|
8
8
|
import ShadowBox from './_ui/ShadowBox';
|
|
9
|
-
const HistoryView = ({ onBackClick, onChatHistoryClick, onNewChatClick, isAuthenticated, historyLit, goGetHistoryList }) => {
|
|
9
|
+
const HistoryView = ({ onBackClick, onChatHistoryClick, onNewChatClick, isAuthenticated, historyLit, goGetHistoryList, isMobile }) => {
|
|
10
10
|
const { containerRef, isScroll, isBottom, checkScroll } = useScrollShadow();
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
checkScroll();
|
|
@@ -15,6 +15,7 @@ type HistoryViewProps = {
|
|
|
15
15
|
isAuthenticated: boolean;
|
|
16
16
|
historyLit: History[];
|
|
17
17
|
goGetHistoryList: (data: { version?: string }) => void;
|
|
18
|
+
isMobile: boolean;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
const HistoryView: React.FC<HistoryViewProps> = ({
|
|
@@ -23,7 +24,8 @@ const HistoryView: React.FC<HistoryViewProps> = ({
|
|
|
23
24
|
onNewChatClick,
|
|
24
25
|
isAuthenticated,
|
|
25
26
|
historyLit,
|
|
26
|
-
goGetHistoryList
|
|
27
|
+
goGetHistoryList,
|
|
28
|
+
isMobile
|
|
27
29
|
}) => {
|
|
28
30
|
const { containerRef, isScroll, isBottom, checkScroll } = useScrollShadow<HTMLDivElement>();
|
|
29
31
|
|
|
@@ -3,7 +3,7 @@ import NoticeIcon from '../../asset/images/daeryuntalk/notice.svg';
|
|
|
3
3
|
import PrevIcon from '../../asset/images/daeryuntalk/prev.svg';
|
|
4
4
|
const NoticeMessage = ({ content }) => {
|
|
5
5
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
6
|
-
return (<div className="
|
|
6
|
+
return (<div className="bg-[#F7F7F7]/90 p-2 backdrop-blur-sm">
|
|
7
7
|
<div className="flex items-start">
|
|
8
8
|
<div className="mr-2 flex-shrink-0">
|
|
9
9
|
<NoticeIcon width={20} height={20}/>
|
|
@@ -11,7 +11,7 @@ const NoticeMessage: React.FC<NoticeMessageProps> = ({ content }) => {
|
|
|
11
11
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<div className="
|
|
14
|
+
<div className="bg-[#F7F7F7]/90 p-2 backdrop-blur-sm">
|
|
15
15
|
<div className="flex items-start">
|
|
16
16
|
<div className="mr-2 flex-shrink-0">
|
|
17
17
|
<NoticeIcon width={20} height={20} />
|
|
@@ -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
|
|
|
@@ -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,8 +11,10 @@ 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
19
|
sendHeartbeat: (chatInquiryNumber: string) => void;
|
|
18
20
|
sendInquiryJoined: (chatInquiryNumber: string) => void;
|
|
@@ -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
|
|
@@ -124,18 +124,6 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
124
124
|
try {
|
|
125
125
|
setIsLoading(true);
|
|
126
126
|
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
127
|
const { inquiryData, socket, hashAuth } = yield apiInitializeDaeryuntalk(hashValue || '', socket => {
|
|
140
128
|
console.log('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 성공');
|
|
141
129
|
setIsConnected(true);
|
|
@@ -176,7 +164,16 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
176
164
|
}
|
|
177
165
|
// 안읽음 count
|
|
178
166
|
if (data.type === MessageSocketType.INQUIRY_PREVIEW_UPDATED) {
|
|
179
|
-
|
|
167
|
+
const socketData = data === null || data === void 0 ? void 0 : data.payload;
|
|
168
|
+
setHistoryList((prev) => prev.map(item => item.chat_inquiry_number === socketData.chat_inquiry_number
|
|
169
|
+
? {
|
|
170
|
+
chat_inquiry_number: socketData.chat_inquiry_number,
|
|
171
|
+
customer_name: item.customer_name,
|
|
172
|
+
recent_message_content: socketData.recent_message_content,
|
|
173
|
+
recent_message_date_time: socketData.recent_message_date_time,
|
|
174
|
+
unread_message_count: Number(socketData.unread_message_count)
|
|
175
|
+
}
|
|
176
|
+
: item));
|
|
180
177
|
}
|
|
181
178
|
// 새로운 문의가 생성됨
|
|
182
179
|
if (data.type === MessageSocketType.INQUIRY_OPENED) {
|
|
@@ -184,7 +181,6 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
184
181
|
// 문의 워크플로우 변경됨
|
|
185
182
|
if (data.type === MessageSocketType.INQUIRY_WORKFLOW_UPDATED) {
|
|
186
183
|
const socketPayloadData = data === null || data === void 0 ? void 0 : data.payload;
|
|
187
|
-
console.log('socketPayloadData', socketPayloadData);
|
|
188
184
|
// 워크플로우 스택 업데이트
|
|
189
185
|
setWorkFlowStack(socketPayloadData.work_flow_progress_stack);
|
|
190
186
|
// 오브젝트 업데이트
|
|
@@ -197,7 +193,6 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
197
193
|
// 업무 관리자 배정
|
|
198
194
|
if (data.type === MessageSocketType.INQUIRY_ASSIGNED) {
|
|
199
195
|
const payload = data.payload;
|
|
200
|
-
// 이거는 찾아서 count를 처리해줘야하나??
|
|
201
196
|
}
|
|
202
197
|
// 할당된 상담원이 해제됨
|
|
203
198
|
if (data.type === MessageSocketType.INQUIRY_UNASSIGNED) {
|
|
@@ -232,7 +227,7 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
|
|
|
232
227
|
console.log('[DaeryuntalkContext] 로딩 상태 설정: false');
|
|
233
228
|
setIsLoading(false);
|
|
234
229
|
}
|
|
235
|
-
}), []);
|
|
230
|
+
}), [historyList]);
|
|
236
231
|
return {
|
|
237
232
|
initializeDaeryuntalk,
|
|
238
233
|
sendHeartbeat,
|