@daeryun/dr_components 0.7.87 → 0.7.89
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 -1
- package/dist/components/Daeryuntalk/ChatButton.tsx +3 -1
- package/dist/components/Daeryuntalk/ChatConversation.jsx +23 -5
- package/dist/components/Daeryuntalk/ChatConversation.tsx +27 -5
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +28 -11
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +34 -9
- package/dist/components/Daeryuntalk/ChatInput.tsx +1 -1
- package/dist/components/Daeryuntalk/ChatWidget.jsx +5 -2
- package/dist/components/Daeryuntalk/ChatWidget.tsx +5 -2
- package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +21 -3
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +32 -11
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +69 -23
- package/dist/components/Daeryuntalk/History/AuthForm.d.ts +8 -0
- package/dist/components/Daeryuntalk/History/AuthForm.jsx +149 -0
- package/dist/components/Daeryuntalk/History/AuthForm.tsx +196 -0
- package/dist/components/Daeryuntalk/HistoryView.d.ts +6 -0
- package/dist/components/Daeryuntalk/HistoryView.jsx +55 -35
- package/dist/components/Daeryuntalk/HistoryView.tsx +86 -47
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.jsx +9 -1
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.tsx +10 -1
- package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.d.ts +12 -0
- package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.jsx +33 -0
- package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.tsx +67 -0
- package/dist/components/Daeryuntalk/Toast/Toast.d.ts +11 -0
- package/dist/components/Daeryuntalk/Toast/Toast.jsx +61 -0
- package/dist/components/Daeryuntalk/Toast/Toast.tsx +94 -0
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +1 -1
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +1 -1
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +29 -1
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +98 -7
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +136 -8
- package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.d.ts +13 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.ts +17 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +3 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +76 -8
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +88 -12
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.d.ts +24 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.js +75 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.ts +90 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +12 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +16 -2
- package/dist/components/Daeryuntalk/_lib/utils.d.ts +10 -0
- package/dist/components/Daeryuntalk/_lib/utils.js +25 -0
- package/dist/components/Daeryuntalk/_lib/utils.ts +39 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button2.d.ts +10 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button2.jsx +12 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button2.tsx +28 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input2.d.ts +13 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input2.jsx +9 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input2.tsx +42 -0
- package/dist/styles/globals.css +65 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
3
3
|
const ChatButton = ({ isOpen, onClick, apiVersion }) => {
|
|
4
|
-
const { initializeDaeryuntalk } = useDaeryuntalk();
|
|
4
|
+
const { initializeDaeryuntalk, goGetHistoryList } = useDaeryuntalk();
|
|
5
5
|
const handleClick = useCallback(() => {
|
|
6
6
|
// 채팅 버튼이 클릭되면 초기화 메소드 호출
|
|
7
7
|
if (!isOpen) {
|
|
8
8
|
// 여기서 대륜톡 초기화
|
|
9
9
|
initializeDaeryuntalk(apiVersion);
|
|
10
10
|
}
|
|
11
|
+
// 히스토리도 불러와서 인증 확인
|
|
12
|
+
goGetHistoryList({});
|
|
11
13
|
// 원래 onClick 핸들러 호출
|
|
12
14
|
onClick();
|
|
13
15
|
}, [isOpen, onClick, initializeDaeryuntalk, apiVersion]);
|
|
@@ -8,7 +8,7 @@ interface ChatButtonProps {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const ChatButton: React.FC<ChatButtonProps> = ({ isOpen, onClick, apiVersion }) => {
|
|
11
|
-
const { initializeDaeryuntalk } = useDaeryuntalk();
|
|
11
|
+
const { initializeDaeryuntalk, goGetHistoryList } = useDaeryuntalk();
|
|
12
12
|
|
|
13
13
|
const handleClick = useCallback(() => {
|
|
14
14
|
// 채팅 버튼이 클릭되면 초기화 메소드 호출
|
|
@@ -17,6 +17,8 @@ const ChatButton: React.FC<ChatButtonProps> = ({ isOpen, onClick, apiVersion })
|
|
|
17
17
|
initializeDaeryuntalk(apiVersion);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// 히스토리도 불러와서 인증 확인
|
|
21
|
+
goGetHistoryList({});
|
|
20
22
|
// 원래 onClick 핸들러 호출
|
|
21
23
|
onClick();
|
|
22
24
|
}, [isOpen, onClick, initializeDaeryuntalk, apiVersion]);
|
|
@@ -8,15 +8,33 @@ import PrevIcon from '../../asset/images/daeryuntalk/prev.svg';
|
|
|
8
8
|
import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
9
9
|
import Image from 'next/image';
|
|
10
10
|
const ChatConversation = ({ onBackClick, isActive }) => {
|
|
11
|
-
const { messages, isLoading, inquiryMainData, messageObject, workFlowBack, workFlowStack, chatInquiryNumber, sendHeartbeat } = useDaeryuntalk();
|
|
11
|
+
const { messages, isLoading, inquiryMainData, messageObject, workFlowBack, workFlowStack, chatInquiryNumber, sendHeartbeat, sendInquiryLeft, sendInquiryJoined } = useDaeryuntalk();
|
|
12
12
|
const [isHovered, setIsHovered] = useState(false);
|
|
13
13
|
const messagesEndRef = useRef(null);
|
|
14
14
|
const defaultNoticeContent = '본 채팅을 통해 제공되는 서비스는 일반적인 법률정보 제공 및 고객 편의 도모를 위한 것 입니다. 본 채팅을 통해 제공된 정보를 이용한 행위에 대해서는 당사는 어떠한 법적 책임을 지지 않으며 구체적인 사안에 대한 적용은 변호사와의 추가 상담을 통해 자문을 받으시기를 권해드립니다.';
|
|
15
15
|
const noticeContent = defaultNoticeContent;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
// 컴포넌트 마운트 시: 입장 처리
|
|
18
|
+
if (chatInquiryNumber) {
|
|
19
|
+
sendInquiryJoined(chatInquiryNumber);
|
|
20
|
+
}
|
|
21
|
+
// 10초 간격으로 sendHeartbeat 호출
|
|
22
|
+
let heartbeatInterval = null;
|
|
23
|
+
if (chatInquiryNumber) {
|
|
24
|
+
heartbeatInterval = setInterval(() => {
|
|
25
|
+
sendHeartbeat(chatInquiryNumber);
|
|
26
|
+
}, 10000); // 10,000ms = 10초
|
|
27
|
+
}
|
|
28
|
+
// 언마운트 시: 퇴장 처리 및 인터벌 해제
|
|
29
|
+
return () => {
|
|
30
|
+
if (chatInquiryNumber) {
|
|
31
|
+
sendInquiryLeft(chatInquiryNumber);
|
|
32
|
+
}
|
|
33
|
+
if (heartbeatInterval) {
|
|
34
|
+
clearInterval(heartbeatInterval);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}, [chatInquiryNumber]);
|
|
20
38
|
const scrollEnd = () => {
|
|
21
39
|
var _a;
|
|
22
40
|
(_a = messagesEndRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: 'smooth' });
|
|
@@ -24,7 +24,9 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, isActi
|
|
|
24
24
|
workFlowBack,
|
|
25
25
|
workFlowStack,
|
|
26
26
|
chatInquiryNumber,
|
|
27
|
-
sendHeartbeat
|
|
27
|
+
sendHeartbeat,
|
|
28
|
+
sendInquiryLeft,
|
|
29
|
+
sendInquiryJoined
|
|
28
30
|
} = useDaeryuntalk();
|
|
29
31
|
const [isHovered, setIsHovered] = useState<boolean>(false);
|
|
30
32
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
@@ -33,10 +35,30 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, isActi
|
|
|
33
35
|
'본 채팅을 통해 제공되는 서비스는 일반적인 법률정보 제공 및 고객 편의 도모를 위한 것 입니다. 본 채팅을 통해 제공된 정보를 이용한 행위에 대해서는 당사는 어떠한 법적 책임을 지지 않으며 구체적인 사안에 대한 적용은 변호사와의 추가 상담을 통해 자문을 받으시기를 권해드립니다.';
|
|
34
36
|
|
|
35
37
|
const noticeContent = defaultNoticeContent;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
// 컴포넌트 마운트 시: 입장 처리
|
|
40
|
+
if (chatInquiryNumber) {
|
|
41
|
+
sendInquiryJoined(chatInquiryNumber);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 10초 간격으로 sendHeartbeat 호출
|
|
45
|
+
let heartbeatInterval: ReturnType<typeof setInterval> | null = null;
|
|
46
|
+
if (chatInquiryNumber) {
|
|
47
|
+
heartbeatInterval = setInterval(() => {
|
|
48
|
+
sendHeartbeat(chatInquiryNumber);
|
|
49
|
+
}, 10000); // 10,000ms = 10초
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 언마운트 시: 퇴장 처리 및 인터벌 해제
|
|
53
|
+
return () => {
|
|
54
|
+
if (chatInquiryNumber) {
|
|
55
|
+
sendInquiryLeft(chatInquiryNumber);
|
|
56
|
+
}
|
|
57
|
+
if (heartbeatInterval) {
|
|
58
|
+
clearInterval(heartbeatInterval);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}, [chatInquiryNumber]);
|
|
40
62
|
|
|
41
63
|
const scrollEnd = () => {
|
|
42
64
|
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
@@ -19,17 +19,26 @@ import InfoIcon from '../../asset/images/daeryuntalk/info.svg';
|
|
|
19
19
|
import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
20
20
|
import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk-intro.png';
|
|
21
21
|
import { useChatSocketState } from './_hooks/talkprovider/useChatSocketState';
|
|
22
|
+
import { useDearyunTalkToast } from './Toast/DaeryuntalkToastProvider';
|
|
22
23
|
const ChatHomeView = () => {
|
|
23
|
-
const {
|
|
24
|
+
const { isAuthenticated, historyList, inquiryMainData, startChat, createNewChat, chatInquiryNumber, sendHeartbeat, sendInquiryLeft, goGetHistoryList, sendHistoryEntered, sendHistoryLeft, startSelectedChat } = useDaeryuntalk();
|
|
24
25
|
const [viewState, setViewState] = useState('home');
|
|
25
|
-
const [selectedHistoryId, setSelectedHistoryId] = useState(null);
|
|
26
26
|
const [mainData, setMainData] = useState(null);
|
|
27
27
|
const [isLoading, setIsLoading] = useState(false);
|
|
28
|
+
const toast = useDearyunTalkToast();
|
|
28
29
|
useEffect(() => {
|
|
29
30
|
if (inquiryMainData) {
|
|
30
31
|
setMainData(inquiryMainData);
|
|
31
32
|
}
|
|
32
33
|
}, [inquiryMainData]);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (isAuthenticated) {
|
|
36
|
+
sendHistoryEntered(historyList ? historyList.map(item => item.chat_inquiry_number) : []);
|
|
37
|
+
}
|
|
38
|
+
return () => {
|
|
39
|
+
sendHistoryLeft(historyList ? historyList.map(item => item.chat_inquiry_number) : []);
|
|
40
|
+
};
|
|
41
|
+
}, [isAuthenticated]);
|
|
33
42
|
// 채팅창관리
|
|
34
43
|
useChatSocketState(chatInquiryNumber, viewState, sendHeartbeat, sendInquiryLeft);
|
|
35
44
|
// 홈에서 사용
|
|
@@ -64,18 +73,26 @@ const ChatHomeView = () => {
|
|
|
64
73
|
setIsLoading(false);
|
|
65
74
|
}
|
|
66
75
|
});
|
|
67
|
-
const handleHistoryClick = () => {
|
|
68
|
-
viewHistory();
|
|
76
|
+
const handleHistoryClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
77
|
setViewState('history');
|
|
70
|
-
};
|
|
78
|
+
});
|
|
71
79
|
const handleBackToHome = () => {
|
|
72
80
|
setViewState('home');
|
|
73
81
|
};
|
|
74
|
-
const handleChatHistoryClick = (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
const handleChatHistoryClick = (chatNumber) => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
+
try {
|
|
84
|
+
setIsLoading(true);
|
|
85
|
+
const res = yield startSelectedChat(chatNumber);
|
|
86
|
+
console.log('res', res);
|
|
87
|
+
setViewState('conversation');
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
console.error('e', e);
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
setIsLoading(false);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
79
96
|
// 채팅 문의 창
|
|
80
97
|
if (viewState === 'conversation') {
|
|
81
98
|
return (<main className="flex h-[690px] w-[390px] items-center justify-center rounded-[30px]">
|
|
@@ -96,7 +113,7 @@ const ChatHomeView = () => {
|
|
|
96
113
|
</main>);
|
|
97
114
|
};
|
|
98
115
|
if (viewState === 'history') {
|
|
99
|
-
return renderWithNavigation(<HistoryView onBackClick={handleBackToHome} onChatHistoryClick={handleChatHistoryClick} onNewChatClick={handleNewStartChat}/>, 'history');
|
|
116
|
+
return renderWithNavigation(<HistoryView onBackClick={handleBackToHome} onChatHistoryClick={handleChatHistoryClick} onNewChatClick={handleNewStartChat} isAuthenticated={isAuthenticated !== null && isAuthenticated !== void 0 ? isAuthenticated : false} historyLit={historyList !== null && historyList !== void 0 ? historyList : []} goGetHistoryList={goGetHistoryList}/>, 'history');
|
|
100
117
|
}
|
|
101
118
|
// 아직 커버이미지 url이 안나옴
|
|
102
119
|
// const backgroundImage = mainData?.sleeve_image_url ? mainData.sleeve_image_url : DaeryuntalkIntro;
|
|
@@ -11,23 +11,29 @@ import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
|
11
11
|
import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk-intro.png';
|
|
12
12
|
import { IChatInquiryMainDataResponse } from './_api/daeryuntalk/type/response';
|
|
13
13
|
import { useChatSocketState } from './_hooks/talkprovider/useChatSocketState';
|
|
14
|
+
import { useDearyunTalkToast } from './Toast/DaeryuntalkToastProvider';
|
|
14
15
|
|
|
15
16
|
type ViewState = 'home' | 'conversation' | 'history';
|
|
16
17
|
|
|
17
18
|
const ChatHomeView: React.FC = () => {
|
|
18
19
|
const {
|
|
19
|
-
|
|
20
|
+
isAuthenticated,
|
|
21
|
+
historyList,
|
|
20
22
|
inquiryMainData,
|
|
21
23
|
startChat,
|
|
22
24
|
createNewChat,
|
|
23
25
|
chatInquiryNumber,
|
|
24
26
|
sendHeartbeat,
|
|
25
|
-
sendInquiryLeft
|
|
27
|
+
sendInquiryLeft,
|
|
28
|
+
goGetHistoryList,
|
|
29
|
+
sendHistoryEntered,
|
|
30
|
+
sendHistoryLeft,
|
|
31
|
+
startSelectedChat
|
|
26
32
|
} = useDaeryuntalk();
|
|
27
33
|
const [viewState, setViewState] = useState<ViewState>('home');
|
|
28
|
-
const [selectedHistoryId, setSelectedHistoryId] = useState<string | null>(null);
|
|
29
34
|
const [mainData, setMainData] = useState<IChatInquiryMainDataResponse | null>(null);
|
|
30
35
|
const [isLoading, setIsLoading] = useState(false);
|
|
36
|
+
const toast = useDearyunTalkToast();
|
|
31
37
|
|
|
32
38
|
useEffect(() => {
|
|
33
39
|
if (inquiryMainData) {
|
|
@@ -35,6 +41,16 @@ const ChatHomeView: React.FC = () => {
|
|
|
35
41
|
}
|
|
36
42
|
}, [inquiryMainData]);
|
|
37
43
|
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (isAuthenticated) {
|
|
46
|
+
sendHistoryEntered(historyList ? historyList.map(item => item.chat_inquiry_number) : []);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return () => {
|
|
50
|
+
sendHistoryLeft(historyList ? historyList.map(item => item.chat_inquiry_number) : []);
|
|
51
|
+
};
|
|
52
|
+
}, [isAuthenticated]);
|
|
53
|
+
|
|
38
54
|
// 채팅창관리
|
|
39
55
|
useChatSocketState(chatInquiryNumber, viewState, sendHeartbeat, sendInquiryLeft);
|
|
40
56
|
|
|
@@ -70,8 +86,7 @@ const ChatHomeView: React.FC = () => {
|
|
|
70
86
|
}
|
|
71
87
|
};
|
|
72
88
|
|
|
73
|
-
const handleHistoryClick = () => {
|
|
74
|
-
viewHistory();
|
|
89
|
+
const handleHistoryClick = async () => {
|
|
75
90
|
setViewState('history');
|
|
76
91
|
};
|
|
77
92
|
|
|
@@ -79,10 +94,17 @@ const ChatHomeView: React.FC = () => {
|
|
|
79
94
|
setViewState('home');
|
|
80
95
|
};
|
|
81
96
|
|
|
82
|
-
const handleChatHistoryClick = (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
97
|
+
const handleChatHistoryClick = async (chatNumber: string) => {
|
|
98
|
+
try {
|
|
99
|
+
setIsLoading(true);
|
|
100
|
+
const res = await startSelectedChat(chatNumber);
|
|
101
|
+
console.log('res', res);
|
|
102
|
+
setViewState('conversation');
|
|
103
|
+
} catch (e) {
|
|
104
|
+
console.error('e', e);
|
|
105
|
+
} finally {
|
|
106
|
+
setIsLoading(false);
|
|
107
|
+
}
|
|
86
108
|
};
|
|
87
109
|
|
|
88
110
|
// 채팅 문의 창
|
|
@@ -120,6 +142,9 @@ const ChatHomeView: React.FC = () => {
|
|
|
120
142
|
onBackClick={handleBackToHome}
|
|
121
143
|
onChatHistoryClick={handleChatHistoryClick}
|
|
122
144
|
onNewChatClick={handleNewStartChat}
|
|
145
|
+
isAuthenticated={isAuthenticated ?? false}
|
|
146
|
+
historyLit={historyList ?? []}
|
|
147
|
+
goGetHistoryList={goGetHistoryList}
|
|
123
148
|
/>,
|
|
124
149
|
'history'
|
|
125
150
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
3
3
|
import SendIcon from '../../asset/images/daeryuntalk/send.svg';
|
|
4
4
|
import Tiptap, { TiptapEditorRef } from './Tiptap/Tiptap';
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ChatHomeView from './ChatHomeView';
|
|
3
3
|
import ImageViewer from './Viewer/ImageViewer';
|
|
4
|
+
import { DaeryuntalkToastProvider } from './Toast/DaeryuntalkToastProvider';
|
|
4
5
|
const ChatWidget = ({ isOpen }) => {
|
|
5
6
|
return (<>
|
|
6
7
|
<ImageViewer />
|
|
7
|
-
<div className={`
|
|
8
|
+
<div className={`
|
|
8
9
|
fixed bottom-[110px] right-[30px] z-[999998]
|
|
9
10
|
transition-all duration-300 ease-out
|
|
10
11
|
${isOpen ? 'translate-y-0 scale-100 opacity-100' : 'pointer-events-none translate-y-6 opacity-0'}
|
|
11
12
|
`}>
|
|
12
|
-
<
|
|
13
|
+
<DaeryuntalkToastProvider>
|
|
14
|
+
<ChatHomeView />
|
|
15
|
+
</DaeryuntalkToastProvider>
|
|
13
16
|
</div>
|
|
14
17
|
</>);
|
|
15
18
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ChatHomeView from './ChatHomeView';
|
|
3
3
|
import ImageViewer from './Viewer/ImageViewer';
|
|
4
|
+
import { DaeryuntalkToastProvider } from './Toast/DaeryuntalkToastProvider';
|
|
4
5
|
|
|
5
6
|
interface ChatWidgetProps {
|
|
6
7
|
isOpen: boolean;
|
|
@@ -11,13 +12,15 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen }) => {
|
|
|
11
12
|
<>
|
|
12
13
|
<ImageViewer />
|
|
13
14
|
<div
|
|
14
|
-
className={`
|
|
15
|
+
className={`
|
|
15
16
|
fixed bottom-[110px] right-[30px] z-[999998]
|
|
16
17
|
transition-all duration-300 ease-out
|
|
17
18
|
${isOpen ? 'translate-y-0 scale-100 opacity-100' : 'pointer-events-none translate-y-6 opacity-0'}
|
|
18
19
|
`}
|
|
19
20
|
>
|
|
20
|
-
<
|
|
21
|
+
<DaeryuntalkToastProvider>
|
|
22
|
+
<ChatHomeView />
|
|
23
|
+
</DaeryuntalkToastProvider>
|
|
21
24
|
</div>
|
|
22
25
|
</>
|
|
23
26
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { FileInfo, Message } from './_types/message';
|
|
3
|
-
import { ChatInquiryDetailDataResponse, IChatInquiryMainDataResponse } from './_api/daeryuntalk/type/response';
|
|
3
|
+
import { ChatInquiryDetailDataResponse, History, IChatInquiryMainDataResponse } from './_api/daeryuntalk/type/response';
|
|
4
4
|
import { MessageObject } from './_types/message_object';
|
|
5
5
|
type DaeryuntalkContextType = {
|
|
6
6
|
messages: Message[];
|
|
@@ -10,7 +10,6 @@ type DaeryuntalkContextType = {
|
|
|
10
10
|
isConnected: boolean;
|
|
11
11
|
isLoading: boolean;
|
|
12
12
|
sendMessage: (htmlContent: string, jsonData: any) => void;
|
|
13
|
-
viewHistory: () => void;
|
|
14
13
|
initializeDaeryuntalk: (version?: string) => void;
|
|
15
14
|
startChat: () => Promise<string | void>;
|
|
16
15
|
createNewChat: () => void;
|
|
@@ -39,7 +38,7 @@ type DaeryuntalkContextType = {
|
|
|
39
38
|
isOpen?: boolean;
|
|
40
39
|
chatData?: ChatInquiryDetailDataResponse | null;
|
|
41
40
|
inquiryMainData?: IChatInquiryMainDataResponse | null;
|
|
42
|
-
isAuthenticated
|
|
41
|
+
isAuthenticated: boolean;
|
|
43
42
|
isSocketInitialized?: boolean;
|
|
44
43
|
isSocketConnected?: boolean;
|
|
45
44
|
error?: Error | null;
|
|
@@ -50,6 +49,25 @@ type DaeryuntalkContextType = {
|
|
|
50
49
|
openImageViewer?: (file: FileInfo, message: Message) => void;
|
|
51
50
|
closeImageViewer?: () => void;
|
|
52
51
|
tel: string;
|
|
52
|
+
goRequestPhone: (data: {
|
|
53
|
+
name: string;
|
|
54
|
+
cellPhoneNumber: string;
|
|
55
|
+
version?: string;
|
|
56
|
+
}) => void;
|
|
57
|
+
goHistoryPhoneAuth: (data: {
|
|
58
|
+
name: string;
|
|
59
|
+
cellPhoneNumber: string;
|
|
60
|
+
certificationNumber: string;
|
|
61
|
+
version?: string;
|
|
62
|
+
}) => void;
|
|
63
|
+
goGetHistoryList: (data: {
|
|
64
|
+
version?: string;
|
|
65
|
+
}) => void;
|
|
66
|
+
historyList: History[];
|
|
67
|
+
sendHistoryEntered: (chatInquiryNumbers: string[]) => void;
|
|
68
|
+
sendHistoryLeft: (chatInquiryNumbers: string[]) => void;
|
|
69
|
+
startSelectedChat: (chatInquiryNumbers: string) => void;
|
|
70
|
+
sendInquiryJoined: (chatInquiryNumber: string) => void;
|
|
53
71
|
};
|
|
54
72
|
declare const DaeryuntalkContext: React.Context<DaeryuntalkContextType>;
|
|
55
73
|
type DaeryuntalkProviderProps = {
|
|
@@ -7,10 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import React, { createContext,
|
|
10
|
+
import React, { createContext, useContext, useRef, useState } from 'react';
|
|
11
11
|
import { useSocketEventHandler } from './_hooks/talkprovider/useSocketEventHandler';
|
|
12
12
|
import { useChatHandler } from './_hooks/talkprovider/useChatHandler';
|
|
13
13
|
import { useViewerHook } from './_hooks/talkprovider/useViewerHook';
|
|
14
|
+
import { useHistoryHandler } from './_hooks/talkprovider/useHistoryHandler';
|
|
14
15
|
// 기본값으로 컨텍스트 생성
|
|
15
16
|
const DaeryuntalkContext = createContext({
|
|
16
17
|
messages: [],
|
|
@@ -21,7 +22,6 @@ const DaeryuntalkContext = createContext({
|
|
|
21
22
|
isConnected: false,
|
|
22
23
|
isLoading: false,
|
|
23
24
|
sendMessage: () => { },
|
|
24
|
-
viewHistory: () => { },
|
|
25
25
|
initializeDaeryuntalk: () => { },
|
|
26
26
|
startChat: () => __awaiter(void 0, void 0, void 0, function* () { }),
|
|
27
27
|
createNewChat: () => __awaiter(void 0, void 0, void 0, function* () { }),
|
|
@@ -42,12 +42,21 @@ const DaeryuntalkContext = createContext({
|
|
|
42
42
|
isSocketConnected: false,
|
|
43
43
|
error: null,
|
|
44
44
|
closeDaeryuntalk: () => { },
|
|
45
|
-
tel: ''
|
|
46
|
-
|
|
45
|
+
tel: '',
|
|
46
|
+
goRequestPhone: () => { },
|
|
47
|
+
goHistoryPhoneAuth: () => { },
|
|
48
|
+
goGetHistoryList: () => { },
|
|
49
|
+
historyList: [],
|
|
50
|
+
sendHistoryEntered: () => { },
|
|
51
|
+
sendHistoryLeft: () => { },
|
|
52
|
+
startSelectedChat: () => { },
|
|
53
|
+
sendInquiryJoined: () => { }
|
|
47
54
|
});
|
|
48
55
|
export const DaeryuntalkProvider = ({ children, propsTel }) => {
|
|
49
56
|
const [inquiryStatus, setInquiryStatus] = useState('');
|
|
50
57
|
const [tel, setTel] = useState(propsTel);
|
|
58
|
+
// 인증 여부
|
|
59
|
+
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
51
60
|
// 채팅 진행중에 필요한 state들
|
|
52
61
|
const [messages, setMessages] = useState([]);
|
|
53
62
|
const [messageObject, setMessageObject] = useState(null);
|
|
@@ -59,8 +68,10 @@ export const DaeryuntalkProvider = ({ children, propsTel }) => {
|
|
|
59
68
|
const [isLoading, setIsLoading] = useState(false);
|
|
60
69
|
const [inquiryMainData, setInquiryMainData] = useState(null);
|
|
61
70
|
const socketRef = useRef(null);
|
|
71
|
+
// 히스토리 리스트
|
|
72
|
+
const [historyList, setHistoryList] = useState([]);
|
|
62
73
|
// 소켓 관련 API + 채팅 시작
|
|
63
|
-
const { initializeDaeryuntalk, sendHeartbeat, sendInquiryJoined, sendInquiryLeft, sendHistoryEntered } = useSocketEventHandler({
|
|
74
|
+
const { initializeDaeryuntalk, sendHeartbeat, sendInquiryJoined, sendInquiryLeft, sendHistoryEntered, sendHistoryLeft } = useSocketEventHandler({
|
|
64
75
|
setIsConnected,
|
|
65
76
|
setIsLoading,
|
|
66
77
|
setMessages,
|
|
@@ -71,7 +82,7 @@ export const DaeryuntalkProvider = ({ children, propsTel }) => {
|
|
|
71
82
|
});
|
|
72
83
|
// MSG15591497825895676
|
|
73
84
|
// 채팅 관련
|
|
74
|
-
const { startChat, sendMessage, createNewChat, startWorkFlow, workFlowBack, chatUserUpdate, getNextMessageList, getDownLoadUrl } = useChatHandler({
|
|
85
|
+
const { startChat, sendMessage, createNewChat, startWorkFlow, workFlowBack, chatUserUpdate, getNextMessageList, getDownLoadUrl, startSelectedChat } = useChatHandler({
|
|
75
86
|
setIsLoading,
|
|
76
87
|
inquiryMainData,
|
|
77
88
|
setChatInquiryNumber,
|
|
@@ -81,18 +92,19 @@ export const DaeryuntalkProvider = ({ children, propsTel }) => {
|
|
|
81
92
|
chatInquiryNumber,
|
|
82
93
|
setIsNextPage,
|
|
83
94
|
setWorkFlowStack,
|
|
84
|
-
|
|
95
|
+
setInquiryMainData
|
|
85
96
|
});
|
|
86
97
|
// 이미지 뷰어용
|
|
87
98
|
const { isImageViewerOpen, selectedImageFile, imageViewerMessage, openImageViewer, closeImageViewer } = useViewerHook();
|
|
88
|
-
|
|
89
|
-
|
|
99
|
+
const { goRequestPhone, goHistoryPhoneAuth, goGetHistoryList } = useHistoryHandler({
|
|
100
|
+
setIsAuthenticated,
|
|
101
|
+
setHistoryList
|
|
102
|
+
});
|
|
90
103
|
return (<DaeryuntalkContext.Provider value={{
|
|
91
104
|
messages,
|
|
92
105
|
isConnected,
|
|
93
106
|
isLoading,
|
|
94
107
|
sendMessage,
|
|
95
|
-
viewHistory,
|
|
96
108
|
initializeDaeryuntalk,
|
|
97
109
|
startChat,
|
|
98
110
|
inquiryMainData,
|
|
@@ -113,7 +125,16 @@ export const DaeryuntalkProvider = ({ children, propsTel }) => {
|
|
|
113
125
|
imageViewerMessage,
|
|
114
126
|
openImageViewer,
|
|
115
127
|
closeImageViewer,
|
|
116
|
-
tel: tel
|
|
128
|
+
tel: tel,
|
|
129
|
+
goRequestPhone,
|
|
130
|
+
goHistoryPhoneAuth,
|
|
131
|
+
goGetHistoryList,
|
|
132
|
+
isAuthenticated,
|
|
133
|
+
historyList,
|
|
134
|
+
sendHistoryEntered,
|
|
135
|
+
sendHistoryLeft,
|
|
136
|
+
startSelectedChat,
|
|
137
|
+
sendInquiryJoined
|
|
117
138
|
}}>
|
|
118
139
|
{children}
|
|
119
140
|
</DaeryuntalkContext.Provider>);
|