@daeryun/dr_components 0.7.87 → 0.7.88
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 +26 -11
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +32 -9
- 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 +140 -0
- package/dist/components/Daeryuntalk/History/AuthForm.tsx +186 -0
- package/dist/components/Daeryuntalk/HistoryView.d.ts +6 -0
- package/dist/components/Daeryuntalk/HistoryView.jsx +49 -35
- package/dist/components/Daeryuntalk/HistoryView.tsx +78 -47
- 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 +27 -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' });
|
|
@@ -20,9 +20,8 @@ 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
22
|
const ChatHomeView = () => {
|
|
23
|
-
const {
|
|
23
|
+
const { isAuthenticated, historyList, inquiryMainData, startChat, createNewChat, chatInquiryNumber, sendHeartbeat, sendInquiryLeft, goGetHistoryList, sendHistoryEntered, sendHistoryLeft, startSelectedChat } = useDaeryuntalk();
|
|
24
24
|
const [viewState, setViewState] = useState('home');
|
|
25
|
-
const [selectedHistoryId, setSelectedHistoryId] = useState(null);
|
|
26
25
|
const [mainData, setMainData] = useState(null);
|
|
27
26
|
const [isLoading, setIsLoading] = useState(false);
|
|
28
27
|
useEffect(() => {
|
|
@@ -30,6 +29,14 @@ const ChatHomeView = () => {
|
|
|
30
29
|
setMainData(inquiryMainData);
|
|
31
30
|
}
|
|
32
31
|
}, [inquiryMainData]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (isAuthenticated) {
|
|
34
|
+
sendHistoryEntered(historyList ? historyList.map(item => item.chat_inquiry_number) : []);
|
|
35
|
+
}
|
|
36
|
+
return () => {
|
|
37
|
+
sendHistoryLeft(historyList ? historyList.map(item => item.chat_inquiry_number) : []);
|
|
38
|
+
};
|
|
39
|
+
}, [isAuthenticated]);
|
|
33
40
|
// 채팅창관리
|
|
34
41
|
useChatSocketState(chatInquiryNumber, viewState, sendHeartbeat, sendInquiryLeft);
|
|
35
42
|
// 홈에서 사용
|
|
@@ -64,18 +71,26 @@ const ChatHomeView = () => {
|
|
|
64
71
|
setIsLoading(false);
|
|
65
72
|
}
|
|
66
73
|
});
|
|
67
|
-
const handleHistoryClick = () => {
|
|
68
|
-
viewHistory();
|
|
74
|
+
const handleHistoryClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
75
|
setViewState('history');
|
|
70
|
-
};
|
|
76
|
+
});
|
|
71
77
|
const handleBackToHome = () => {
|
|
72
78
|
setViewState('home');
|
|
73
79
|
};
|
|
74
|
-
const handleChatHistoryClick = (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
const handleChatHistoryClick = (chatNumber) => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
+
try {
|
|
82
|
+
setIsLoading(true);
|
|
83
|
+
const res = yield startSelectedChat(chatNumber);
|
|
84
|
+
console.log('res', res);
|
|
85
|
+
setViewState('conversation');
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
console.error('e', e);
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
setIsLoading(false);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
79
94
|
// 채팅 문의 창
|
|
80
95
|
if (viewState === 'conversation') {
|
|
81
96
|
return (<main className="flex h-[690px] w-[390px] items-center justify-center rounded-[30px]">
|
|
@@ -96,7 +111,7 @@ const ChatHomeView = () => {
|
|
|
96
111
|
</main>);
|
|
97
112
|
};
|
|
98
113
|
if (viewState === 'history') {
|
|
99
|
-
return renderWithNavigation(<HistoryView onBackClick={handleBackToHome} onChatHistoryClick={handleChatHistoryClick} onNewChatClick={handleNewStartChat}/>, 'history');
|
|
114
|
+
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
115
|
}
|
|
101
116
|
// 아직 커버이미지 url이 안나옴
|
|
102
117
|
// const backgroundImage = mainData?.sleeve_image_url ? mainData.sleeve_image_url : DaeryuntalkIntro;
|
|
@@ -16,16 +16,20 @@ type ViewState = 'home' | 'conversation' | 'history';
|
|
|
16
16
|
|
|
17
17
|
const ChatHomeView: React.FC = () => {
|
|
18
18
|
const {
|
|
19
|
-
|
|
19
|
+
isAuthenticated,
|
|
20
|
+
historyList,
|
|
20
21
|
inquiryMainData,
|
|
21
22
|
startChat,
|
|
22
23
|
createNewChat,
|
|
23
24
|
chatInquiryNumber,
|
|
24
25
|
sendHeartbeat,
|
|
25
|
-
sendInquiryLeft
|
|
26
|
+
sendInquiryLeft,
|
|
27
|
+
goGetHistoryList,
|
|
28
|
+
sendHistoryEntered,
|
|
29
|
+
sendHistoryLeft,
|
|
30
|
+
startSelectedChat
|
|
26
31
|
} = useDaeryuntalk();
|
|
27
32
|
const [viewState, setViewState] = useState<ViewState>('home');
|
|
28
|
-
const [selectedHistoryId, setSelectedHistoryId] = useState<string | null>(null);
|
|
29
33
|
const [mainData, setMainData] = useState<IChatInquiryMainDataResponse | null>(null);
|
|
30
34
|
const [isLoading, setIsLoading] = useState(false);
|
|
31
35
|
|
|
@@ -35,6 +39,16 @@ const ChatHomeView: React.FC = () => {
|
|
|
35
39
|
}
|
|
36
40
|
}, [inquiryMainData]);
|
|
37
41
|
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (isAuthenticated) {
|
|
44
|
+
sendHistoryEntered(historyList ? historyList.map(item => item.chat_inquiry_number) : []);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return () => {
|
|
48
|
+
sendHistoryLeft(historyList ? historyList.map(item => item.chat_inquiry_number) : []);
|
|
49
|
+
};
|
|
50
|
+
}, [isAuthenticated]);
|
|
51
|
+
|
|
38
52
|
// 채팅창관리
|
|
39
53
|
useChatSocketState(chatInquiryNumber, viewState, sendHeartbeat, sendInquiryLeft);
|
|
40
54
|
|
|
@@ -70,8 +84,7 @@ const ChatHomeView: React.FC = () => {
|
|
|
70
84
|
}
|
|
71
85
|
};
|
|
72
86
|
|
|
73
|
-
const handleHistoryClick = () => {
|
|
74
|
-
viewHistory();
|
|
87
|
+
const handleHistoryClick = async () => {
|
|
75
88
|
setViewState('history');
|
|
76
89
|
};
|
|
77
90
|
|
|
@@ -79,10 +92,17 @@ const ChatHomeView: React.FC = () => {
|
|
|
79
92
|
setViewState('home');
|
|
80
93
|
};
|
|
81
94
|
|
|
82
|
-
const handleChatHistoryClick = (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
95
|
+
const handleChatHistoryClick = async (chatNumber: string) => {
|
|
96
|
+
try {
|
|
97
|
+
setIsLoading(true);
|
|
98
|
+
const res = await startSelectedChat(chatNumber);
|
|
99
|
+
console.log('res', res);
|
|
100
|
+
setViewState('conversation');
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.error('e', e);
|
|
103
|
+
} finally {
|
|
104
|
+
setIsLoading(false);
|
|
105
|
+
}
|
|
86
106
|
};
|
|
87
107
|
|
|
88
108
|
// 채팅 문의 창
|
|
@@ -120,6 +140,9 @@ const ChatHomeView: React.FC = () => {
|
|
|
120
140
|
onBackClick={handleBackToHome}
|
|
121
141
|
onChatHistoryClick={handleChatHistoryClick}
|
|
122
142
|
onNewChatClick={handleNewStartChat}
|
|
143
|
+
isAuthenticated={isAuthenticated ?? false}
|
|
144
|
+
historyLit={historyList ?? []}
|
|
145
|
+
goGetHistoryList={goGetHistoryList}
|
|
123
146
|
/>,
|
|
124
147
|
'history'
|
|
125
148
|
);
|
|
@@ -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>);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { createContext, ReactNode, useCallback, useContext, useRef, useState } 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
|
import { useSocketEventHandler } from './_hooks/talkprovider/useSocketEventHandler';
|
|
6
6
|
import { useChatHandler } from './_hooks/talkprovider/useChatHandler';
|
|
7
7
|
import { useViewerHook } from './_hooks/talkprovider/useViewerHook';
|
|
8
|
+
import { useHistoryHandler } from './_hooks/talkprovider/useHistoryHandler';
|
|
8
9
|
|
|
9
10
|
type DaeryuntalkContextType = {
|
|
10
11
|
messages: Message[];
|
|
@@ -15,7 +16,6 @@ type DaeryuntalkContextType = {
|
|
|
15
16
|
isConnected: boolean;
|
|
16
17
|
isLoading: boolean;
|
|
17
18
|
sendMessage: (htmlContent: string, jsonData: any) => void;
|
|
18
|
-
viewHistory: () => void;
|
|
19
19
|
initializeDaeryuntalk: (version?: string) => void;
|
|
20
20
|
startChat: () => Promise<string | void>;
|
|
21
21
|
createNewChat: () => void;
|
|
@@ -41,7 +41,7 @@ type DaeryuntalkContextType = {
|
|
|
41
41
|
isOpen?: boolean;
|
|
42
42
|
chatData?: ChatInquiryDetailDataResponse | null;
|
|
43
43
|
inquiryMainData?: IChatInquiryMainDataResponse | null;
|
|
44
|
-
isAuthenticated
|
|
44
|
+
isAuthenticated: boolean;
|
|
45
45
|
isSocketInitialized?: boolean;
|
|
46
46
|
isSocketConnected?: boolean;
|
|
47
47
|
error?: Error | null;
|
|
@@ -54,6 +54,25 @@ type DaeryuntalkContextType = {
|
|
|
54
54
|
openImageViewer?: (file: FileInfo, message: Message) => void;
|
|
55
55
|
closeImageViewer?: () => void;
|
|
56
56
|
tel: string;
|
|
57
|
+
|
|
58
|
+
// 히스토리
|
|
59
|
+
goRequestPhone: (data: {
|
|
60
|
+
name: string; // required
|
|
61
|
+
cellPhoneNumber: string;
|
|
62
|
+
version?: string;
|
|
63
|
+
}) => void;
|
|
64
|
+
goHistoryPhoneAuth: (data: {
|
|
65
|
+
name: string; // required
|
|
66
|
+
cellPhoneNumber: string;
|
|
67
|
+
certificationNumber: string;
|
|
68
|
+
version?: string;
|
|
69
|
+
}) => void;
|
|
70
|
+
goGetHistoryList: (data: { version?: string }) => void;
|
|
71
|
+
historyList: History[];
|
|
72
|
+
sendHistoryEntered: (chatInquiryNumbers: string[]) => void;
|
|
73
|
+
sendHistoryLeft: (chatInquiryNumbers: string[]) => void;
|
|
74
|
+
startSelectedChat: (chatInquiryNumbers: string) => void;
|
|
75
|
+
sendInquiryJoined: (chatInquiryNumber: string) => void;
|
|
57
76
|
};
|
|
58
77
|
|
|
59
78
|
// 기본값으로 컨텍스트 생성
|
|
@@ -66,7 +85,6 @@ const DaeryuntalkContext = createContext<DaeryuntalkContextType>({
|
|
|
66
85
|
isConnected: false,
|
|
67
86
|
isLoading: false,
|
|
68
87
|
sendMessage: () => {},
|
|
69
|
-
viewHistory: () => {},
|
|
70
88
|
initializeDaeryuntalk: () => {},
|
|
71
89
|
startChat: async () => {},
|
|
72
90
|
createNewChat: async () => {},
|
|
@@ -87,9 +105,15 @@ const DaeryuntalkContext = createContext<DaeryuntalkContextType>({
|
|
|
87
105
|
isSocketConnected: false,
|
|
88
106
|
error: null,
|
|
89
107
|
closeDaeryuntalk: () => {},
|
|
90
|
-
tel: ''
|
|
91
|
-
|
|
92
|
-
|
|
108
|
+
tel: '',
|
|
109
|
+
goRequestPhone: () => {},
|
|
110
|
+
goHistoryPhoneAuth: () => {},
|
|
111
|
+
goGetHistoryList: () => {},
|
|
112
|
+
historyList: [],
|
|
113
|
+
sendHistoryEntered: () => {},
|
|
114
|
+
sendHistoryLeft: () => {},
|
|
115
|
+
startSelectedChat: () => {},
|
|
116
|
+
sendInquiryJoined: () => {}
|
|
93
117
|
});
|
|
94
118
|
|
|
95
119
|
// 프로바이더 컴포넌트 생성
|
|
@@ -101,6 +125,8 @@ type DaeryuntalkProviderProps = {
|
|
|
101
125
|
export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ children, propsTel }) => {
|
|
102
126
|
const [inquiryStatus, setInquiryStatus] = useState<string>('');
|
|
103
127
|
const [tel, setTel] = useState(propsTel);
|
|
128
|
+
// 인증 여부
|
|
129
|
+
const [isAuthenticated, setIsAuthenticated] = useState<boolean>(false);
|
|
104
130
|
|
|
105
131
|
// 채팅 진행중에 필요한 state들
|
|
106
132
|
const [messages, setMessages] = useState<Message[]>([]);
|
|
@@ -116,17 +142,26 @@ export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ childr
|
|
|
116
142
|
|
|
117
143
|
const socketRef = useRef<WebSocket | null>(null);
|
|
118
144
|
|
|
145
|
+
// 히스토리 리스트
|
|
146
|
+
const [historyList, setHistoryList] = useState<History[]>([]);
|
|
147
|
+
|
|
119
148
|
// 소켓 관련 API + 채팅 시작
|
|
120
|
-
const {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
149
|
+
const {
|
|
150
|
+
initializeDaeryuntalk,
|
|
151
|
+
sendHeartbeat,
|
|
152
|
+
sendInquiryJoined,
|
|
153
|
+
sendInquiryLeft,
|
|
154
|
+
sendHistoryEntered,
|
|
155
|
+
sendHistoryLeft
|
|
156
|
+
} = useSocketEventHandler({
|
|
157
|
+
setIsConnected,
|
|
158
|
+
setIsLoading,
|
|
159
|
+
setMessages,
|
|
160
|
+
setInquiryMainData,
|
|
161
|
+
setWorkFlowStack,
|
|
162
|
+
setMessageObject,
|
|
163
|
+
socketRef: socketRef
|
|
164
|
+
});
|
|
130
165
|
|
|
131
166
|
// MSG15591497825895676
|
|
132
167
|
|
|
@@ -139,7 +174,8 @@ export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ childr
|
|
|
139
174
|
workFlowBack,
|
|
140
175
|
chatUserUpdate,
|
|
141
176
|
getNextMessageList,
|
|
142
|
-
getDownLoadUrl
|
|
177
|
+
getDownLoadUrl,
|
|
178
|
+
startSelectedChat
|
|
143
179
|
} = useChatHandler({
|
|
144
180
|
setIsLoading,
|
|
145
181
|
inquiryMainData,
|
|
@@ -150,15 +186,17 @@ export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ childr
|
|
|
150
186
|
chatInquiryNumber,
|
|
151
187
|
setIsNextPage,
|
|
152
188
|
setWorkFlowStack,
|
|
153
|
-
|
|
189
|
+
setInquiryMainData
|
|
154
190
|
});
|
|
155
191
|
|
|
156
192
|
// 이미지 뷰어용
|
|
157
193
|
const { isImageViewerOpen, selectedImageFile, imageViewerMessage, openImageViewer, closeImageViewer } =
|
|
158
194
|
useViewerHook();
|
|
159
195
|
|
|
160
|
-
|
|
161
|
-
|
|
196
|
+
const { goRequestPhone, goHistoryPhoneAuth, goGetHistoryList } = useHistoryHandler({
|
|
197
|
+
setIsAuthenticated,
|
|
198
|
+
setHistoryList
|
|
199
|
+
});
|
|
162
200
|
|
|
163
201
|
return (
|
|
164
202
|
<DaeryuntalkContext.Provider
|
|
@@ -167,7 +205,6 @@ export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ childr
|
|
|
167
205
|
isConnected,
|
|
168
206
|
isLoading,
|
|
169
207
|
sendMessage,
|
|
170
|
-
viewHistory,
|
|
171
208
|
initializeDaeryuntalk,
|
|
172
209
|
startChat,
|
|
173
210
|
inquiryMainData,
|
|
@@ -188,7 +225,16 @@ export const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps> = ({ childr
|
|
|
188
225
|
imageViewerMessage,
|
|
189
226
|
openImageViewer,
|
|
190
227
|
closeImageViewer,
|
|
191
|
-
tel: tel
|
|
228
|
+
tel: tel,
|
|
229
|
+
goRequestPhone,
|
|
230
|
+
goHistoryPhoneAuth,
|
|
231
|
+
goGetHistoryList,
|
|
232
|
+
isAuthenticated,
|
|
233
|
+
historyList,
|
|
234
|
+
sendHistoryEntered,
|
|
235
|
+
sendHistoryLeft,
|
|
236
|
+
startSelectedChat,
|
|
237
|
+
sendInquiryJoined
|
|
192
238
|
}}
|
|
193
239
|
>
|
|
194
240
|
{children}
|