@daeryun/dr_components 0.7.86 → 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/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- 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 +99 -8
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +137 -9
- 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/components/common/integrate/index.d.ts +1 -1
- package/dist/styles/globals.css +325 -298
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -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}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React, { useState } from 'react';
|
|
11
|
+
import Input2 from '../_ui/inputs/Input2';
|
|
12
|
+
import { formatSecondsToMMSS, nameFilter, onlyNumbers, phoneCheck } from '../_lib/utils';
|
|
13
|
+
import Button2 from '../_ui/buttons/Button2';
|
|
14
|
+
import { historyPhoneAuth, requestPhone } from '../_api';
|
|
15
|
+
const AuthForm = ({ goGetHistoryList }) => {
|
|
16
|
+
const [name, setName] = useState({ value: '', isValid: false });
|
|
17
|
+
const [phone, setPhone] = useState({ value: '', isValid: false });
|
|
18
|
+
const [authNumber, setAuthNumber] = useState('');
|
|
19
|
+
const [isConfirmState, setIsConfirmState] = useState(false);
|
|
20
|
+
const [timer, setTimer] = useState(180); // 3분(180초)
|
|
21
|
+
const [timerId, setTimerId] = useState(null);
|
|
22
|
+
// 3분 인증시간 start 필요
|
|
23
|
+
const handleInput = (e) => {
|
|
24
|
+
const { name: formName, value } = e.currentTarget;
|
|
25
|
+
if (formName === 'name') {
|
|
26
|
+
const { name: propsName, isValid } = nameFilter(value);
|
|
27
|
+
setName(prev => {
|
|
28
|
+
return {
|
|
29
|
+
value: propsName,
|
|
30
|
+
isValid: isValid
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (formName === 'phone') {
|
|
35
|
+
const { phoneNumber, isValid } = phoneCheck(value);
|
|
36
|
+
setPhone(prev => {
|
|
37
|
+
return {
|
|
38
|
+
value: phoneNumber,
|
|
39
|
+
isValid: isValid
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (formName === 'authNumber') {
|
|
44
|
+
setAuthNumber(onlyNumbers(value));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
// 인증번호 발송 클릭
|
|
48
|
+
const handleSendAuth = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
try {
|
|
50
|
+
const res = yield requestPhone({ name: name.value, cellPhoneNumber: phone.value });
|
|
51
|
+
if (res.result_info.result_type_cd === 'OK' || res.result_info.result_cd === 'OK') {
|
|
52
|
+
// 인증번호 발송 API 호출 등 처리
|
|
53
|
+
setIsConfirmState(true);
|
|
54
|
+
setAuthNumber('');
|
|
55
|
+
setTimer(180);
|
|
56
|
+
if (timerId)
|
|
57
|
+
clearInterval(timerId);
|
|
58
|
+
const id = setInterval(() => {
|
|
59
|
+
setTimer(prev => {
|
|
60
|
+
if (prev <= 1) {
|
|
61
|
+
clearInterval(id);
|
|
62
|
+
setIsConfirmState(false); // 타이머 종료시 인증상태 해제
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
return prev - 1;
|
|
66
|
+
});
|
|
67
|
+
}, 1000);
|
|
68
|
+
setTimerId(id);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
console.error('e', e);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
// 인증번호 확인
|
|
78
|
+
const handleSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
try {
|
|
80
|
+
const res = yield historyPhoneAuth({
|
|
81
|
+
name: name.value,
|
|
82
|
+
cellPhoneNumber: phone.value,
|
|
83
|
+
certificationNumber: authNumber
|
|
84
|
+
});
|
|
85
|
+
if (res.result_info.result_type_cd === 'OK' || res.result_info.result_cd === 'OK') {
|
|
86
|
+
yield goGetHistoryList({});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
console.error('e', e);
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return (<div className={`
|
|
96
|
+
mt-[24px] p-4
|
|
97
|
+
`}>
|
|
98
|
+
<div className={`p-[20px]`}>
|
|
99
|
+
<div className={`text-[16px] font-[700] leading-[140%] tracking-[-4%]`}>
|
|
100
|
+
문의 히스토리 확인을 위해 이전에 문의하실 때 입력하신 정보를 입력해 주세요.
|
|
101
|
+
</div>
|
|
102
|
+
<div className={`flex flex-col`}>
|
|
103
|
+
<div className={`mt-[40px] flex flex-col gap-[8px]`}>
|
|
104
|
+
<div className={`text-[14px] font-[700] leading-[100%] tracking-[-4%]`}>이름</div>
|
|
105
|
+
<Input2 onChange={handleInput} value={name.value} type="text" name="name" placeholder={'이름'} readOnly={isConfirmState}/>
|
|
106
|
+
</div>
|
|
107
|
+
<div className={`mt-[20px] flex flex-col gap-[8px]`}>
|
|
108
|
+
<div className={`text-[14px] font-[700] leading-[100%] tracking-[-4%]`}>휴대폰 번호</div>
|
|
109
|
+
<div className={`flex flex-row gap-[4px]`}>
|
|
110
|
+
<Input2 onChange={handleInput} value={phone.value} type="text" name="phone" className={`!py-[12.5px]`} readOnly={isConfirmState} maxLength={11} placeholder="숫자만 입력"/>
|
|
111
|
+
<Button2 isDisabled={isConfirmState || !name.isValid || !phone.isValid} onClick={handleSendAuth} type={'button'} className={`w-[120px]`}>
|
|
112
|
+
인증번호 발송
|
|
113
|
+
</Button2>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
{isConfirmState && (<div className={`mt-[4px] text-[12px] leading-[140%] tracking-[-4%] text-[#000] text-[#000]/80`}>
|
|
117
|
+
인증번호가 발송되었습니다.
|
|
118
|
+
</div>)}
|
|
119
|
+
|
|
120
|
+
{isConfirmState && (<div className={`relative mt-[10px]`}>
|
|
121
|
+
<Input2 onChange={handleInput} value={authNumber} type="text" name="authNumber" maxLength={6} placeholder={'인증 번호 입력'}/>
|
|
122
|
+
<div className={`absolute right-[8px] top-[15px] text-[12px] font-[400] leading-[100%] tracking-[-4%] text-[#AA1D36] `}>
|
|
123
|
+
{formatSecondsToMMSS(timer)}
|
|
124
|
+
</div>
|
|
125
|
+
</div>)}
|
|
126
|
+
|
|
127
|
+
{isConfirmState && (<div className={`mt-[20px] text-[12px] leading-[140%] tracking-[-4%] text-[#000] text-[#000]/80`}>
|
|
128
|
+
인증번호가 오지 않는 경우 휴대폰 번호 차단 여부를 확인해주세요.(대륜 고객센터 1800-7905)
|
|
129
|
+
</div>)}
|
|
130
|
+
|
|
131
|
+
{isConfirmState && (<div className="mt-[40px]">
|
|
132
|
+
<button disabled={authNumber.length < 5} className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white" onClick={handleSubmit}>
|
|
133
|
+
인증번호 확인
|
|
134
|
+
</button>
|
|
135
|
+
</div>)}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
</div>);
|
|
139
|
+
};
|
|
140
|
+
export default AuthForm;
|