@daeryun/dr_components 0.8.47 → 0.8.49
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/asset/images/daeryuntalk/close.svg +2 -2
- package/dist/asset/images/daeryuntalk/time.svg +2 -2
- package/dist/asset/images/daeryuntalk/viewer/zoom-out.svg +2 -4
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/components/Daeryuntalk/ChatButton.jsx +5 -2
- package/dist/components/Daeryuntalk/ChatButton.tsx +5 -2
- package/dist/components/Daeryuntalk/ChatConversation.d.ts +2 -0
- package/dist/components/Daeryuntalk/ChatConversation.jsx +22 -63
- package/dist/components/Daeryuntalk/ChatConversation.tsx +42 -79
- package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.d.ts +11 -0
- package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.jsx +27 -0
- package/dist/components/Daeryuntalk/ChatConversationItem/ChatConversationHeader.tsx +57 -0
- package/dist/components/Daeryuntalk/ChatHomeView.d.ts +3 -2
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +61 -182
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +103 -206
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.jsx +15 -14
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.tsx +15 -14
- package/dist/components/Daeryuntalk/ChatItem/ChatLoading.d.ts +3 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatLoading.jsx +11 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatLoading.tsx +21 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.jsx +4 -4
- package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.tsx +4 -4
- package/dist/components/Daeryuntalk/ChatItem/RichText.jsx +2 -1
- package/dist/components/Daeryuntalk/ChatItem/RichText.tsx +2 -1
- package/dist/components/Daeryuntalk/ChatItem/TimeWrapper.d.ts +9 -0
- package/dist/components/Daeryuntalk/ChatItem/TimeWrapper.jsx +9 -0
- package/dist/components/Daeryuntalk/ChatItem/TimeWrapper.tsx +20 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.jsx +3 -3
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.tsx +3 -3
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.jsx +2 -2
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.tsx +2 -2
- package/dist/components/Daeryuntalk/ChatMessage.d.ts +1 -0
- package/dist/components/Daeryuntalk/ChatMessage.jsx +31 -36
- package/dist/components/Daeryuntalk/ChatMessage.tsx +34 -38
- package/dist/components/Daeryuntalk/ChatObject/FieldWorkObject.jsx +2 -2
- package/dist/components/Daeryuntalk/ChatObject/FieldWorkObject.tsx +2 -2
- package/dist/components/Daeryuntalk/ChatObject/ObjectBack.jsx +1 -1
- package/dist/components/Daeryuntalk/ChatObject/ObjectBack.tsx +1 -1
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.jsx +6 -23
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.tsx +6 -23
- package/dist/components/Daeryuntalk/ChatWidget.jsx +60 -23
- package/dist/components/Daeryuntalk/ChatWidget.tsx +72 -34
- package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +2 -2
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +3 -3
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +5 -5
- package/dist/components/Daeryuntalk/DateSeparator.jsx +2 -2
- package/dist/components/Daeryuntalk/DateSeparator.tsx +2 -2
- package/dist/components/Daeryuntalk/FixedErrorBox.d.ts +7 -0
- package/dist/components/Daeryuntalk/FixedErrorBox.jsx +33 -0
- package/dist/components/Daeryuntalk/FixedErrorBox.tsx +73 -0
- package/dist/components/Daeryuntalk/History/AuthForm.d.ts +3 -1
- package/dist/components/Daeryuntalk/History/AuthForm.jsx +15 -45
- package/dist/components/Daeryuntalk/History/AuthForm.tsx +21 -53
- package/dist/components/Daeryuntalk/HistoryView.d.ts +4 -0
- package/dist/components/Daeryuntalk/HistoryView.jsx +17 -40
- package/dist/components/Daeryuntalk/HistoryView.tsx +36 -48
- package/dist/components/Daeryuntalk/HomeView.d.ts +12 -0
- package/dist/components/Daeryuntalk/HomeView.jsx +102 -0
- package/dist/components/Daeryuntalk/HomeView.tsx +150 -0
- package/dist/components/Daeryuntalk/NavigationFooter.jsx +17 -10
- package/dist/components/Daeryuntalk/NavigationFooter.tsx +22 -12
- package/dist/components/Daeryuntalk/NoticeMessage.jsx +7 -7
- package/dist/components/Daeryuntalk/NoticeMessage.tsx +7 -7
- package/dist/components/Daeryuntalk/Toast/ToastRender.jsx +1 -1
- package/dist/components/Daeryuntalk/Toast/ToastRender.tsx +2 -2
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.d.ts +6 -0
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +18 -90
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +49 -135
- package/dist/components/Daeryuntalk/Viewer/MobileViewer.d.ts +16 -0
- package/dist/components/Daeryuntalk/Viewer/MobileViewer.jsx +66 -0
- package/dist/components/Daeryuntalk/Viewer/MobileViewer.tsx +121 -0
- package/dist/components/Daeryuntalk/Viewer/TbPcViewer.d.ts +22 -0
- package/dist/components/Daeryuntalk/Viewer/TbPcViewer.jsx +104 -0
- package/dist/components/Daeryuntalk/Viewer/TbPcViewer.tsx +195 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +4 -3
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +81 -105
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +105 -121
- package/dist/components/Daeryuntalk/_enums/ask-status.d.ts +7 -0
- package/dist/components/Daeryuntalk/_enums/ask-status.js +14 -0
- package/dist/components/Daeryuntalk/_enums/ask-status.ts +14 -0
- package/dist/components/Daeryuntalk/_enums/error.d.ts +3 -0
- package/dist/components/Daeryuntalk/_enums/error.js +125 -0
- package/dist/components/Daeryuntalk/_enums/error.ts +143 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +8 -8
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +227 -179
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +261 -185
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.d.ts +1 -1
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.js +54 -18
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.ts +68 -15
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +2 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +8 -7
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +13 -6
- package/dist/components/Daeryuntalk/_hooks/view/useChatSocketState.d.ts +2 -0
- package/dist/components/Daeryuntalk/_hooks/{talkprovider → view}/useChatSocketState.js +7 -1
- package/dist/components/Daeryuntalk/_hooks/{talkprovider → view}/useChatSocketState.ts +13 -1
- package/dist/components/Daeryuntalk/_hooks/view/useHistoryView.d.ts +26 -0
- package/dist/components/Daeryuntalk/_hooks/view/useHistoryView.js +72 -0
- package/dist/components/Daeryuntalk/_hooks/view/useHistoryView.ts +93 -0
- package/dist/components/Daeryuntalk/_hooks/view/useHomeView.d.ts +16 -0
- package/dist/components/Daeryuntalk/_hooks/view/useHomeView.js +61 -0
- package/dist/components/Daeryuntalk/_hooks/view/useHomeView.ts +64 -0
- package/dist/components/Daeryuntalk/_lib/utils.d.ts +1 -0
- package/dist/components/Daeryuntalk/_lib/utils.js +27 -0
- package/dist/components/Daeryuntalk/_lib/utils.ts +33 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button2.jsx +3 -3
- package/dist/components/Daeryuntalk/_ui/buttons/Button2.tsx +3 -3
- package/dist/components/Daeryuntalk/_ui/buttons/Button3.d.ts +10 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button3.jsx +12 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button3.tsx +29 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input2.jsx +2 -1
- package/dist/components/Daeryuntalk/_ui/inputs/Input2.tsx +2 -1
- package/dist/components/Daeryuntalk/index.jsx +1 -1
- package/dist/components/Daeryuntalk/index.tsx +12 -1
- package/dist/styles/globals.css +510 -168
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/components/Daeryuntalk/_enums/error_code.d.ts +0 -21
- package/dist/components/Daeryuntalk/_enums/error_code.js +0 -23
- package/dist/components/Daeryuntalk/_enums/error_code.ts +0 -22
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.d.ts +0 -1
|
@@ -7,19 +7,33 @@ import DateSeparator from './DateSeparator';
|
|
|
7
7
|
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
|
-
import { useChatSocketState } from './_hooks/
|
|
10
|
+
import { useChatSocketState } from './_hooks/view/useChatSocketState';
|
|
11
11
|
import { getMessageFileDownloadUrl } from './_api';
|
|
12
12
|
import { InquiryStatus } from './_enums/ask-status';
|
|
13
13
|
import SendIcon from '../../asset/images/daeryuntalk/send.svg';
|
|
14
|
+
import CloseSvgIcon from '../../asset/images/daeryuntalk/close.svg';
|
|
15
|
+
import Button3 from './_ui/buttons/Button3';
|
|
16
|
+
import ChatConversationHeader from './ChatConversationItem/ChatConversationHeader';
|
|
17
|
+
import { IChatInquiryMainDataResponse } from './_api/daeryuntalk/type/response';
|
|
18
|
+
import ChatLoading from './ChatItem/ChatLoading';
|
|
14
19
|
|
|
15
20
|
type ChatConversationProps = {
|
|
16
21
|
onBackClick?: () => void;
|
|
17
22
|
onChatNew?: () => void;
|
|
18
23
|
isActive: boolean;
|
|
19
24
|
isMobile: boolean;
|
|
25
|
+
onClose: () => void;
|
|
26
|
+
isHash: boolean;
|
|
20
27
|
};
|
|
21
28
|
|
|
22
|
-
const ChatConversation: React.FC<ChatConversationProps> = ({
|
|
29
|
+
const ChatConversation: React.FC<ChatConversationProps> = ({
|
|
30
|
+
onBackClick,
|
|
31
|
+
onChatNew,
|
|
32
|
+
isActive,
|
|
33
|
+
isMobile,
|
|
34
|
+
onClose,
|
|
35
|
+
isHash
|
|
36
|
+
}) => {
|
|
23
37
|
const {
|
|
24
38
|
inquiryStatus,
|
|
25
39
|
messages,
|
|
@@ -28,7 +42,7 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, onChat
|
|
|
28
42
|
messageObject,
|
|
29
43
|
workFlowBack,
|
|
30
44
|
workFlowStack,
|
|
31
|
-
chatInquiryNumber
|
|
45
|
+
chatInquiryNumber
|
|
32
46
|
} = useDaeryuntalk();
|
|
33
47
|
const [isHovered, setIsHovered] = useState<boolean>(false);
|
|
34
48
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
@@ -38,38 +52,16 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, onChat
|
|
|
38
52
|
'본 채팅을 통해 제공되는 서비스는 일반적인 법률정보 제공 및 고객 편의 도모를 위한 것 입니다. 본 채팅을 통해 제공된 정보를 이용한 행위에 대해서는 당사는 어떠한 법적 책임을 지지 않으며 구체적인 사안에 대한 적용은 변호사와의 추가 상담을 통해 자문을 받으시기를 권해드립니다.';
|
|
39
53
|
|
|
40
54
|
const noticeContent = defaultNoticeContent;
|
|
41
|
-
// useEffect(() => {
|
|
42
|
-
// // 컴포넌트 마운트 시: 입장 처리
|
|
43
|
-
// if (chatInquiryNumber) {
|
|
44
|
-
// sendInquiryJoined(chatInquiryNumber);
|
|
45
|
-
// }
|
|
46
|
-
//
|
|
47
|
-
// // 10초 간격으로 sendHeartbeat 호출
|
|
48
|
-
// let heartbeatInterval: ReturnType<typeof setInterval> | null = null;
|
|
49
|
-
// if (chatInquiryNumber) {
|
|
50
|
-
// heartbeatInterval = setInterval(() => {
|
|
51
|
-
// sendHeartbeat(chatInquiryNumber);
|
|
52
|
-
// }, 10000); // 10,000ms = 10초
|
|
53
|
-
// }
|
|
54
|
-
//
|
|
55
|
-
// // 언마운트 시: 퇴장 처리 및 인터벌 해제
|
|
56
|
-
// return () => {
|
|
57
|
-
// if (chatInquiryNumber) {
|
|
58
|
-
// sendInquiryLeft(chatInquiryNumber);
|
|
59
|
-
// }
|
|
60
|
-
// if (heartbeatInterval) {
|
|
61
|
-
// clearInterval(heartbeatInterval);
|
|
62
|
-
// }
|
|
63
|
-
// };
|
|
64
|
-
// }, [chatInquiryNumber]);
|
|
65
|
-
|
|
66
55
|
const scrollEnd = () => {
|
|
67
56
|
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
68
57
|
};
|
|
69
58
|
|
|
70
59
|
// 새 메시지가 도착할 때 자동으로 스크롤 최하단으로 이동
|
|
71
60
|
useEffect(() => {
|
|
72
|
-
|
|
61
|
+
const timeout = setTimeout(() => {
|
|
62
|
+
scrollEnd();
|
|
63
|
+
}, 100);
|
|
64
|
+
return () => clearTimeout(timeout); // cleanup
|
|
73
65
|
}, [messages, messageObject]);
|
|
74
66
|
|
|
75
67
|
const isNewDay = (date1: Date, date2: Date): boolean => {
|
|
@@ -99,6 +91,7 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, onChat
|
|
|
99
91
|
}
|
|
100
92
|
elements.push(
|
|
101
93
|
<ChatMessage
|
|
94
|
+
inquiryStatus={inquiryStatus}
|
|
102
95
|
key={message.messageNumber}
|
|
103
96
|
message={message}
|
|
104
97
|
object={findObject}
|
|
@@ -114,40 +107,24 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, onChat
|
|
|
114
107
|
return elements;
|
|
115
108
|
};
|
|
116
109
|
|
|
117
|
-
//
|
|
118
|
-
const handleBackClick = () => {
|
|
119
|
-
if (onBackClick) {
|
|
120
|
-
onBackClick();
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const channelName = inquiryMainData?.channel_name || '법무법인(유한)대륜';
|
|
125
|
-
const logoImageUrl = inquiryMainData?.channel_logo_image_url || '';
|
|
126
|
-
|
|
127
110
|
return (
|
|
128
111
|
<div className="flex h-full flex-col ">
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
{logoImageUrl ? (
|
|
139
|
-
<Image src={logoImageUrl} alt="로고" width={28} height={28} className="mr-2" />
|
|
140
|
-
) : (
|
|
141
|
-
<DaeryunLogoIcon width={28} height={28} className="mr-2" />
|
|
142
|
-
)}
|
|
143
|
-
<h2 className="font-bold leading-[140%] tracking-[-4%]">{channelName}</h2>
|
|
144
|
-
</div>
|
|
145
|
-
<div className="w-7"></div>
|
|
146
|
-
</div>
|
|
112
|
+
{/* 헤더 부분 */}
|
|
113
|
+
<ChatConversationHeader
|
|
114
|
+
inquiryMainData={inquiryMainData ?? null}
|
|
115
|
+
isMobile={isMobile}
|
|
116
|
+
onClose={onClose}
|
|
117
|
+
isHash={isHash}
|
|
118
|
+
onBackClick={onBackClick}
|
|
119
|
+
/>
|
|
120
|
+
{/* 주의내용 */}
|
|
147
121
|
<NoticeMessage content={noticeContent} />
|
|
148
|
-
|
|
122
|
+
{/* 메시지 노출 부분 -> 무한스크롤 변환 필요 */}
|
|
123
|
+
<div
|
|
124
|
+
className={`${isMobile ? 'h-auto' : 'flex-1'} no-scrollbar mx-[20px] overflow-y-auto pb-[100px] pt-[20px]`}
|
|
125
|
+
>
|
|
149
126
|
{messages.length === 0 ? (
|
|
150
|
-
<div className="flex h-full flex-col items-center justify-center text-center text-
|
|
127
|
+
<div className="dr_talk_body_medium2 flex h-full flex-col items-center justify-center text-center text-drTalkGrayscale1">
|
|
151
128
|
<p>문의하실 내용을 입력해 주세요.</p>
|
|
152
129
|
<p className="mt-2 text-sm">24시간 운영하고 있습니다.</p>
|
|
153
130
|
</div>
|
|
@@ -159,41 +136,27 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, onChat
|
|
|
159
136
|
>
|
|
160
137
|
{renderMessagesWithDateSeparators()}
|
|
161
138
|
{inquiryStatus === InquiryStatus.CLOSED && (
|
|
162
|
-
<div className={`text-center text-
|
|
139
|
+
<div className={` dr_talk_body_medium2 text-center text-drTalkGrayscale1 `}>
|
|
163
140
|
문의가 종료되었습니다.
|
|
164
141
|
</div>
|
|
165
142
|
)}
|
|
166
|
-
{isLoading &&
|
|
167
|
-
<div className="flex justify-start pl-8">
|
|
168
|
-
<div className="flex h-8 animate-pulse space-x-2 rounded-full ">
|
|
169
|
-
<div className="h-[8px] w-[8px] animate-bounce rounded-full bg-[#777777] "></div>
|
|
170
|
-
<div
|
|
171
|
-
className="h-[8px] w-[8px] animate-bounce rounded-full bg-[#C2C2C2]"
|
|
172
|
-
style={{ animationDelay: '0.2s' }}
|
|
173
|
-
></div>
|
|
174
|
-
<div
|
|
175
|
-
className="h-[8px] w-[8px] animate-bounce rounded-full bg-[#C2C2C2]"
|
|
176
|
-
style={{ animationDelay: '0.4s' }}
|
|
177
|
-
></div>
|
|
178
|
-
</div>
|
|
179
|
-
</div>
|
|
180
|
-
)}
|
|
143
|
+
{isLoading && <ChatLoading />}
|
|
181
144
|
<div ref={messagesEndRef} />
|
|
182
145
|
</div>
|
|
183
146
|
)}
|
|
184
147
|
</div>
|
|
185
148
|
|
|
186
|
-
<div className="border-t border-
|
|
149
|
+
<div className="border-t border-drTalkGrayscale4 px-[20px] py-[16px]">
|
|
187
150
|
{inquiryStatus === InquiryStatus.CLOSED ? (
|
|
188
151
|
<div className="">
|
|
189
|
-
<
|
|
190
|
-
className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white"
|
|
152
|
+
<Button3
|
|
191
153
|
onClick={() => {
|
|
192
154
|
onChatNew && onChatNew();
|
|
193
155
|
}}
|
|
156
|
+
className={`w-full`}
|
|
194
157
|
>
|
|
195
158
|
새 문의하기
|
|
196
|
-
</
|
|
159
|
+
</Button3>
|
|
197
160
|
</div>
|
|
198
161
|
) : (
|
|
199
162
|
<ChatInput />
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IChatInquiryMainDataResponse } from '../_api/daeryuntalk/type/response';
|
|
3
|
+
interface IChatConversationHeaderProps {
|
|
4
|
+
inquiryMainData: IChatInquiryMainDataResponse | null;
|
|
5
|
+
isMobile: boolean;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
isHash: boolean;
|
|
8
|
+
onBackClick?: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare const ChatConversationHeader: ({ inquiryMainData, isMobile, onClose, isHash, onBackClick }: IChatConversationHeaderProps) => React.JSX.Element;
|
|
11
|
+
export default ChatConversationHeader;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PrevIcon from '../../../asset/images/daeryuntalk/prev.svg';
|
|
3
|
+
import Image from 'next/image';
|
|
4
|
+
import DaeryunLogoIcon from '../../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
5
|
+
import CloseSvgIcon from '../../../asset/images/daeryuntalk/close.svg';
|
|
6
|
+
const ChatConversationHeader = ({ inquiryMainData, isMobile, onClose, isHash, onBackClick }) => {
|
|
7
|
+
const channelName = (inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_name) || '법무법인(유한)대륜';
|
|
8
|
+
const logoImageUrl = (inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_logo_image_url) || '';
|
|
9
|
+
const handleBackClick = () => {
|
|
10
|
+
if (onBackClick) {
|
|
11
|
+
onBackClick();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
return (<div className="flex items-center justify-between border-b border-gray-200 px-[24px] py-[14px]">
|
|
15
|
+
<button className="flex h-[28px] w-[28px] items-center justify-center" aria-label="이전" onClick={handleBackClick}>
|
|
16
|
+
<PrevIcon width={28} height={28}/>
|
|
17
|
+
</button>
|
|
18
|
+
<div className="flex items-center gap-[10px] ">
|
|
19
|
+
{logoImageUrl ? (<Image src={logoImageUrl} alt="로고" width={28} height={28} className="mr-2"/>) : (<DaeryunLogoIcon width={28} height={28}/>)}
|
|
20
|
+
<h2 className={`dr_talk_title_small text-drTalkBlack`}>{channelName}</h2>
|
|
21
|
+
</div>
|
|
22
|
+
<div className={`${isHash ? 'pointer-events-none !opacity-0' : ''} ${isMobile ? 'block' : ' xs:pointer-events-none xs:!opacity-0 '} py-[14px] text-drTalkGrayscale2 hover:cursor-pointer`} onClick={onClose}>
|
|
23
|
+
<CloseSvgIcon width={28} height={28}/>
|
|
24
|
+
</div>
|
|
25
|
+
</div>);
|
|
26
|
+
};
|
|
27
|
+
export default ChatConversationHeader;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PrevIcon from '../../../asset/images/daeryuntalk/prev.svg';
|
|
3
|
+
import Image from 'next/image';
|
|
4
|
+
import DaeryunLogoIcon from '../../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
5
|
+
import CloseSvgIcon from '../../../asset/images/daeryuntalk/close.svg';
|
|
6
|
+
import { IChatInquiryMainDataResponse } from '../_api/daeryuntalk/type/response';
|
|
7
|
+
|
|
8
|
+
interface IChatConversationHeaderProps {
|
|
9
|
+
inquiryMainData: IChatInquiryMainDataResponse | null;
|
|
10
|
+
isMobile: boolean;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
isHash: boolean;
|
|
13
|
+
onBackClick?: () => void;
|
|
14
|
+
}
|
|
15
|
+
const ChatConversationHeader = ({
|
|
16
|
+
inquiryMainData,
|
|
17
|
+
isMobile,
|
|
18
|
+
onClose,
|
|
19
|
+
isHash,
|
|
20
|
+
onBackClick
|
|
21
|
+
}: IChatConversationHeaderProps) => {
|
|
22
|
+
const channelName = inquiryMainData?.channel_name || '법무법인(유한)대륜';
|
|
23
|
+
const logoImageUrl = inquiryMainData?.channel_logo_image_url || '';
|
|
24
|
+
|
|
25
|
+
const handleBackClick = () => {
|
|
26
|
+
if (onBackClick) {
|
|
27
|
+
onBackClick();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return (
|
|
31
|
+
<div className="flex items-center justify-between border-b border-gray-200 px-[24px] py-[14px]">
|
|
32
|
+
<button
|
|
33
|
+
className="flex h-[28px] w-[28px] items-center justify-center"
|
|
34
|
+
aria-label="이전"
|
|
35
|
+
onClick={handleBackClick}
|
|
36
|
+
>
|
|
37
|
+
<PrevIcon width={28} height={28} />
|
|
38
|
+
</button>
|
|
39
|
+
<div className="flex items-center gap-[10px] ">
|
|
40
|
+
{logoImageUrl ? (
|
|
41
|
+
<Image src={logoImageUrl} alt="로고" width={28} height={28} className="mr-2" />
|
|
42
|
+
) : (
|
|
43
|
+
<DaeryunLogoIcon width={28} height={28} />
|
|
44
|
+
)}
|
|
45
|
+
<h2 className={`dr_talk_title_small text-drTalkBlack`}>{channelName}</h2>
|
|
46
|
+
</div>
|
|
47
|
+
<div
|
|
48
|
+
className={`${isHash ? 'pointer-events-none !opacity-0' : ''} ${isMobile ? 'block' : ' xs:pointer-events-none xs:!opacity-0 '} py-[14px] text-drTalkGrayscale2 hover:cursor-pointer`}
|
|
49
|
+
onClick={onClose}
|
|
50
|
+
>
|
|
51
|
+
<CloseSvgIcon width={28} height={28} />
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default ChatConversationHeader;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type ViewState = 'home' | 'conversation' | 'history';
|
|
2
3
|
type ChatHomeViewProps = {
|
|
3
4
|
hashValue: string | null;
|
|
4
|
-
setHashValue: Dispatch<SetStateAction<string | null>>;
|
|
5
5
|
isMobile: boolean;
|
|
6
6
|
isHash: boolean;
|
|
7
|
+
onClose: () => void;
|
|
7
8
|
};
|
|
8
9
|
declare const ChatHomeView: React.FC<ChatHomeViewProps>;
|
|
9
10
|
export default ChatHomeView;
|
|
@@ -1,221 +1,100 @@
|
|
|
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
1
|
import React, { useEffect, useState } from 'react';
|
|
11
2
|
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
12
3
|
import ChatConversation from './ChatConversation';
|
|
13
4
|
import HistoryView from './HistoryView';
|
|
14
5
|
import NavigationFooter from './NavigationFooter';
|
|
15
|
-
import
|
|
16
|
-
import SendIcon from '../../asset/images/daeryuntalk/send.svg';
|
|
17
|
-
import TimeIcon from '../../asset/images/daeryuntalk/time.svg';
|
|
18
|
-
import InfoIcon from '../../asset/images/daeryuntalk/info.svg';
|
|
19
|
-
import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
20
|
-
import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk-intro.png';
|
|
21
|
-
import { useChatSocketState } from './_hooks/talkprovider/useChatSocketState';
|
|
22
|
-
import { useScrollShadow } from './_hooks/useScrollShadow';
|
|
23
|
-
import ShadowBox from './_ui/ShadowBox';
|
|
24
|
-
import { useDaeryunTalkToast } from './Toast/DaeryuntalkToastProvider';
|
|
6
|
+
import { useChatSocketState } from './_hooks/view/useChatSocketState';
|
|
25
7
|
import ToastRenderer from './Toast/ToastRender';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
import HomeView from './HomeView';
|
|
9
|
+
import { useHistoryView } from './_hooks/view/useHistoryView';
|
|
10
|
+
import { useHomeView } from './_hooks/view/useHomeView';
|
|
11
|
+
import FixedErrorBox from './FixedErrorBox';
|
|
12
|
+
const ChatHomeView = ({ hashValue, onClose, isMobile, isHash }) => {
|
|
13
|
+
const [viewState, setViewState] = useState(hashValue ? 'conversation' : 'home');
|
|
30
14
|
const [isLoading, setIsLoading] = useState(false);
|
|
31
|
-
const {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
setViewState('conversation');
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
toast.error('문의 시작에 실패했습니다.');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
toast.error('채팅문의 시작에 실패했습니다.');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
console.error('채팅 시작 실패:', error);
|
|
59
|
-
}
|
|
60
|
-
finally {
|
|
61
|
-
setIsLoading(false);
|
|
62
|
-
}
|
|
15
|
+
const { isConnected, isAuthenticated, historyList, inquiryMainData, chatInquiryNumber, startChat } = useDaeryuntalk();
|
|
16
|
+
// 소켓 이벤트
|
|
17
|
+
const { sendInquiryJoined, sendHeartbeat, sendInquiryWatching, sendInquiryLeft, sendHistoryEntered } = useDaeryuntalk();
|
|
18
|
+
// 홈
|
|
19
|
+
const { retryInquiryMain } = useDaeryuntalk();
|
|
20
|
+
// 히스토리
|
|
21
|
+
const { startSelectedChat, attendRoomByHistory, createNewChat, goRequestPhone, goGetHistoryList, goHistoryPhoneAuth } = useDaeryuntalk();
|
|
22
|
+
// 소켓 클라 -> 서버 관리
|
|
23
|
+
useChatSocketState(chatInquiryNumber, viewState, sendInquiryWatching, sendInquiryJoined, sendHeartbeat, sendInquiryLeft, isConnected, isAuthenticated, sendHistoryEntered, historyList);
|
|
24
|
+
// 홈 뷰 훅스
|
|
25
|
+
const { handleStartChat, handleHashStartChat, handleBackToHome } = useHomeView({
|
|
26
|
+
setIsLoading,
|
|
27
|
+
setViewState,
|
|
28
|
+
retryInquiryMain,
|
|
29
|
+
inquiryMainData: inquiryMainData !== null && inquiryMainData !== void 0 ? inquiryMainData : null,
|
|
30
|
+
startChat
|
|
63
31
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
finally {
|
|
75
|
-
setIsLoading(false);
|
|
76
|
-
}
|
|
32
|
+
// 히스토리 뷰 hooks
|
|
33
|
+
const { handleChatHistoryClick, handleNewStartChat, handleHistoryClick, handleGoRequestPhone, handleGoHistoryPhoneAuth } = useHistoryView({
|
|
34
|
+
attendRoomByHistory,
|
|
35
|
+
startSelectedChat,
|
|
36
|
+
setViewState,
|
|
37
|
+
setIsLoading,
|
|
38
|
+
createNewChat,
|
|
39
|
+
goRequestPhone,
|
|
40
|
+
goHistoryPhoneAuth
|
|
77
41
|
});
|
|
78
42
|
useEffect(() => {
|
|
79
43
|
if (hashValue && isConnected && inquiryMainData && inquiryMainData.channel_number) {
|
|
80
|
-
console.log('해쉬 실행');
|
|
81
44
|
handleHashStartChat();
|
|
82
45
|
}
|
|
83
46
|
else {
|
|
84
|
-
console.log('해쉬 실행안함');
|
|
85
47
|
}
|
|
86
48
|
}, [hashValue, isConnected, inquiryMainData]);
|
|
87
|
-
//
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
checkScroll();
|
|
90
|
-
}, [mainData]);
|
|
91
|
-
//
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
if (inquiryMainData) {
|
|
94
|
-
setMainData(inquiryMainData);
|
|
95
|
-
}
|
|
96
|
-
}, [inquiryMainData]);
|
|
97
49
|
// 히스토리 진입 시
|
|
98
50
|
useEffect(() => {
|
|
99
51
|
if (isAuthenticated && viewState === 'history') {
|
|
100
52
|
goGetHistoryList({});
|
|
101
53
|
}
|
|
102
54
|
}, [viewState, isAuthenticated]);
|
|
103
|
-
|
|
104
|
-
useEffect(() => {
|
|
105
|
-
if (isConnected && isAuthenticated && viewState === 'history') {
|
|
106
|
-
sendHistoryEntered(historyList ? historyList.map(item => item.chat_inquiry_number) : []);
|
|
107
|
-
}
|
|
108
|
-
}, [isConnected, isAuthenticated, historyList, viewState]);
|
|
109
|
-
// 채팅창관리
|
|
110
|
-
useChatSocketState(chatInquiryNumber, viewState, sendInquiryWatching, sendInquiryJoined, sendHeartbeat, sendInquiryLeft);
|
|
111
|
-
// 히스토리에서 사용
|
|
112
|
-
const handleNewStartChat = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
-
try {
|
|
114
|
-
setIsLoading(true);
|
|
115
|
-
// 채팅 시작 - 새 문의 생성 또는 기존 문의 조회 처리
|
|
116
|
-
yield createNewChat();
|
|
117
|
-
// 대화 화면으로 전환
|
|
118
|
-
setViewState('conversation');
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
console.error('신규 채팅 실패:', error);
|
|
122
|
-
}
|
|
123
|
-
finally {
|
|
124
|
-
setIsLoading(false);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
const handleHistoryClick = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
-
setViewState('history');
|
|
129
|
-
});
|
|
130
|
-
const handleBackToHome = () => {
|
|
131
|
-
setViewState('home');
|
|
132
|
-
};
|
|
133
|
-
const handleChatHistoryClick = (chatNumber) => __awaiter(void 0, void 0, void 0, function* () {
|
|
134
|
-
var _a, _b;
|
|
135
|
-
try {
|
|
136
|
-
setIsLoading(true);
|
|
137
|
-
const response = yield attendRoomByHistory(chatNumber);
|
|
138
|
-
if (((_a = response === null || response === void 0 ? void 0 : response.result_info) === null || _a === void 0 ? void 0 : _a.result_cd) === 'OK' || ((_b = response === null || response === void 0 ? void 0 : response.result_info) === null || _b === void 0 ? void 0 : _b.result_type_cd) === 'OK') {
|
|
139
|
-
yield startSelectedChat(chatNumber);
|
|
140
|
-
setViewState('conversation');
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
toast.error('문의 참여에 실패했습니다.');
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch (e) {
|
|
147
|
-
console.error('e', e);
|
|
148
|
-
}
|
|
149
|
-
finally {
|
|
150
|
-
setIsLoading(false);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
55
|
+
console.log('isConnected', isConnected);
|
|
153
56
|
const renderWithNavigation = (content, activeView) => {
|
|
154
|
-
return (<main className={
|
|
155
|
-
|
|
57
|
+
return (<main className={`
|
|
58
|
+
relative flex justify-end
|
|
59
|
+
${isMobile ? 'h-[100dvh]' : 'h-[100dvh] xs:h-auto xs:rounded-[30px] '}
|
|
60
|
+
`}>
|
|
61
|
+
<div className={`
|
|
62
|
+
relative overflow-hidden bg-white
|
|
63
|
+
${isMobile
|
|
64
|
+
? `h-[100dvh] w-full rounded-[0px]`
|
|
65
|
+
: `
|
|
66
|
+
${isHash
|
|
67
|
+
? `
|
|
68
|
+
h-[100dvh] w-full rounded-[0px]
|
|
69
|
+
xs:max-h-[690px] xs:w-[390px] xs:rounded-[30px]
|
|
70
|
+
xs:shadow-[0px_12px_60px_5px_rgba(0,0,0,0.3)]
|
|
71
|
+
`
|
|
72
|
+
: `
|
|
73
|
+
h-[100dvh] w-full rounded-[0px]
|
|
74
|
+
xs:max-h-[690px] xs:w-[390px] xs:rounded-[30px]
|
|
75
|
+
`}
|
|
76
|
+
|
|
77
|
+
`}
|
|
78
|
+
|
|
79
|
+
`}>
|
|
156
80
|
<div className="flex h-full flex-col">
|
|
157
81
|
<div className="flex-1 overflow-hidden">{content}</div>
|
|
158
82
|
|
|
159
83
|
<NavigationFooter activeView={activeView} onHomeClick={handleBackToHome} onHistoryClick={handleHistoryClick} historyList={historyList} isAuthenticated={isAuthenticated}/>
|
|
160
84
|
</div>
|
|
161
85
|
</div>
|
|
162
|
-
|
|
86
|
+
<ToastRenderer />
|
|
87
|
+
<FixedErrorBox isError={isConnected === null ? false : !isConnected}/>
|
|
163
88
|
</main>);
|
|
164
89
|
};
|
|
165
90
|
// 채팅 문의 창
|
|
166
91
|
if (viewState === 'conversation') {
|
|
167
|
-
return renderWithNavigation(<ChatConversation onBackClick={handleBackToHome} isActive={viewState === 'conversation'} onChatNew={handleNewStartChat} isMobile={isMobile}/>, 'conversation');
|
|
92
|
+
return renderWithNavigation(<ChatConversation onBackClick={handleBackToHome} isActive={viewState === 'conversation'} onChatNew={handleNewStartChat} isMobile={isMobile} onClose={onClose} isHash={isHash}/>, 'conversation');
|
|
168
93
|
}
|
|
169
94
|
if (viewState === 'history') {
|
|
170
|
-
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} isMobile={isMobile}/>, 'history');
|
|
95
|
+
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} isMobile={isMobile} onClose={onClose} isHash={isHash} handleGoRequestPhone={handleGoRequestPhone} handleGoHistoryPhoneAuth={handleGoHistoryPhoneAuth}/>, 'history');
|
|
171
96
|
}
|
|
172
97
|
// 홈
|
|
173
|
-
return renderWithNavigation(<
|
|
174
|
-
<div className="absolute left-0 top-0 z-0 h-full w-full overflow-hidden">
|
|
175
|
-
<Image src={backgroundImage} alt="대화 배경" fill className="object-contain object-top will-change-transform"/>
|
|
176
|
-
</div>
|
|
177
|
-
|
|
178
|
-
<div className="relative z-10 flex h-full flex-col">
|
|
179
|
-
<header className="mt-2 flex items-center p-4 text-xs text-black">
|
|
180
|
-
<TimeIcon width={16} height={16}/>
|
|
181
|
-
<span>24시간 운영</span>
|
|
182
|
-
</header>
|
|
183
|
-
|
|
184
|
-
<section className=" mx-auto mt-[150px] flex w-[320px] flex-col gap-5 rounded-[12px] bg-white px-4 py-6 " style={{
|
|
185
|
-
boxShadow: '0px 4px 10px 0px #00000026'
|
|
186
|
-
}}>
|
|
187
|
-
<div className="flex items-center">
|
|
188
|
-
{(mainData === null || mainData === void 0 ? void 0 : mainData.channel_logo_image_url) ? (<Image src={mainData.channel_logo_image_url} alt="로고" width={24} height={24} className="mr-2"/>) : (<DaeryunLogoIcon width={24} height={24} className="mr-2"/>)}
|
|
189
|
-
<h1 className="font-medium">{(mainData === null || mainData === void 0 ? void 0 : mainData.channel_name) || '법무법인(유한)대륜'}</h1>
|
|
190
|
-
</div>
|
|
191
|
-
|
|
192
|
-
<div className={`relative`}>
|
|
193
|
-
<div ref={containerRef} className="no-scrollbar relative mx-8 max-h-[162px] overflow-auto whitespace-pre-line text-sm font-normal leading-[130%]">
|
|
194
|
-
{(mainData === null || mainData === void 0 ? void 0 : mainData.salutation) ||
|
|
195
|
-
`안녕하세요.
|
|
196
|
-
법무법인(유한)대륜입니다.
|
|
197
|
-
방문해 주셔서 감사합니다.
|
|
198
|
-
궁금한 점이나 도움이 필요하신 부분
|
|
199
|
-
말씀해 주시면 도와드리겠습니다.
|
|
200
|
-
|
|
201
|
-
6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.`}
|
|
202
|
-
</div>
|
|
203
|
-
{!isScroll && !isBottom && <ShadowBox />}
|
|
204
|
-
</div>
|
|
205
|
-
|
|
206
|
-
<button className="mt-4 flex h-[48px] w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white" aria-label={`문의하기`} onClick={handleStartChat} disabled={isLoading}>
|
|
207
|
-
{isLoading ? '로딩 중...' : '문의하기'}
|
|
208
|
-
{!isLoading && <SendIcon width={24} height={24}/>}
|
|
209
|
-
</button>
|
|
210
|
-
|
|
211
|
-
<div className="flex items-center justify-center gap-1">
|
|
212
|
-
<InfoIcon width={20} height={20}/>
|
|
213
|
-
<span className="text-xs font-normal text-gray-500">
|
|
214
|
-
{(mainData === null || mainData === void 0 ? void 0 : mainData.answer_speed_message) || '빠르게 답변 받으실 수 있어요'}
|
|
215
|
-
</span>
|
|
216
|
-
</div>
|
|
217
|
-
</section>
|
|
218
|
-
</div>
|
|
219
|
-
</div>, 'home');
|
|
98
|
+
return renderWithNavigation(<HomeView inquiryMainData={inquiryMainData !== null && inquiryMainData !== void 0 ? inquiryMainData : null} isLoading={isLoading} handleStartChat={handleStartChat} isMobile={isMobile} onClose={onClose} isHash={isHash}/>, 'home');
|
|
220
99
|
};
|
|
221
100
|
export default ChatHomeView;
|