@daeryun/dr_components 0.6.33 → 0.6.35
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/Daeryuntalk/ChatButton.d.ts +7 -0
- package/dist/Daeryuntalk/ChatButton.jsx +37 -0
- package/dist/Daeryuntalk/ChatButton.tsx +63 -0
- package/dist/Daeryuntalk/ChatConversation.d.ts +6 -0
- package/dist/Daeryuntalk/ChatConversation.jsx +74 -0
- package/dist/Daeryuntalk/ChatConversation.tsx +109 -0
- package/dist/Daeryuntalk/ChatHomeView.d.ts +3 -0
- package/dist/Daeryuntalk/ChatHomeView.jsx +93 -0
- package/dist/Daeryuntalk/ChatHomeView.tsx +158 -0
- package/dist/Daeryuntalk/ChatInput.d.ts +3 -0
- package/dist/Daeryuntalk/ChatInput.jsx +23 -0
- package/dist/Daeryuntalk/ChatInput.tsx +42 -0
- package/dist/Daeryuntalk/ChatMessage.d.ts +7 -0
- package/dist/Daeryuntalk/ChatMessage.jsx +88 -0
- package/dist/Daeryuntalk/ChatMessage.tsx +153 -0
- package/dist/Daeryuntalk/ChatWidget.d.ts +6 -0
- package/dist/Daeryuntalk/ChatWidget.jsx +12 -0
- package/dist/Daeryuntalk/ChatWidget.tsx +22 -0
- package/dist/Daeryuntalk/DaeryuntalkContext.d.ts +20 -0
- package/dist/Daeryuntalk/DaeryuntalkContext.jsx +455 -0
- package/dist/Daeryuntalk/DaeryuntalkContext.tsx +530 -0
- package/dist/Daeryuntalk/DateSeparator.d.ts +6 -0
- package/dist/Daeryuntalk/DateSeparator.jsx +13 -0
- package/dist/Daeryuntalk/DateSeparator.tsx +23 -0
- package/dist/Daeryuntalk/HistoryView.d.ts +8 -0
- package/dist/Daeryuntalk/HistoryView.jsx +68 -0
- package/dist/Daeryuntalk/HistoryView.tsx +98 -0
- package/dist/Daeryuntalk/NavigationFooter.d.ts +8 -0
- package/dist/Daeryuntalk/NavigationFooter.jsx +23 -0
- package/dist/Daeryuntalk/NavigationFooter.tsx +55 -0
- package/dist/Daeryuntalk/NoticeMessage.d.ts +6 -0
- package/dist/Daeryuntalk/NoticeMessage.jsx +23 -0
- package/dist/Daeryuntalk/NoticeMessage.tsx +45 -0
- package/dist/Daeryuntalk/index.jsx +25 -0
- package/dist/Daeryuntalk/index.tsx +33 -0
- package/dist/Daeryuntalk/message-components/FileContent.d.ts +8 -0
- package/dist/Daeryuntalk/message-components/FileContent.jsx +32 -0
- package/dist/Daeryuntalk/message-components/FileContent.tsx +43 -0
- package/dist/Daeryuntalk/message-components/FormContent.d.ts +8 -0
- package/dist/Daeryuntalk/message-components/FormContent.jsx +104 -0
- package/dist/Daeryuntalk/message-components/FormContent.tsx +184 -0
- package/dist/Daeryuntalk/socketManager.d.ts +22 -0
- package/dist/Daeryuntalk/socketManager.js +96 -0
- package/dist/Daeryuntalk/socketManager.ts +123 -0
- package/dist/Daeryuntalk/types.d.ts +75 -0
- package/dist/Daeryuntalk/types.js +80 -0
- package/dist/Daeryuntalk/types.ts +174 -0
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/components/page/Faq/Detail/FaqDetail.d.ts +2 -1
- package/dist/components/page/Faq/Detail/FaqDetail.jsx +2 -2
- package/dist/components/page/Faq/Detail/FaqDetail.tsx +4 -1
- package/dist/components/page/Faq/FaqList.d.ts +2 -1
- package/dist/components/page/Faq/FaqList.jsx +2 -2
- package/dist/components/page/Faq/FaqList.tsx +10 -1
- package/dist/styles/globals.css +639 -255
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
const ChatButton = ({ isOpen, onClick }) => {
|
|
3
|
+
return (<button aria-label="채팅 상담 열기" onClick={onClick} className={`
|
|
4
|
+
fixed bottom-[30px] right-[30px] h-[60px] w-[60px] rounded-[10px] border
|
|
5
|
+
${isOpen ? 'border-gray-200 bg-white' : 'border-[#AA1D36] bg-[#AA1D36]'}
|
|
6
|
+
z-[999999] flex transform cursor-pointer items-center justify-center
|
|
7
|
+
p-0 shadow-lg outline-none transition-all duration-300 ease-in-out
|
|
8
|
+
hover:${isOpen ? 'bg-gray-100' : 'bg-[#8A1729]'}
|
|
9
|
+
`}>
|
|
10
|
+
<div className={`
|
|
11
|
+
absolute inset-0 flex items-center justify-center
|
|
12
|
+
transition-opacity duration-300 ease-in-out
|
|
13
|
+
${isOpen ? 'opacity-0' : 'opacity-100'}
|
|
14
|
+
`}>
|
|
15
|
+
<svg width="34" height="32" viewBox="0 0 34 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
16
|
+
<path d="M24.9835 0.886475H3.69698C2.22812 0.886475 1.03467 2.07593 1.03467 3.54878V19.5147C1.03467 20.9835 2.22413 22.177 3.69698 22.177H4.51923V25.7893L9.96759 22.177H24.9835C26.4524 22.177 27.6458 20.9875 27.6458 19.5147V3.54878C27.6458 2.07992 26.4564 0.886475 24.9835 0.886475Z" fill="white"/>
|
|
17
|
+
<path d="M4.51861 26.6754C4.37492 26.6754 4.23123 26.6395 4.09951 26.5716C3.81212 26.416 3.63251 26.1166 3.63251 25.7893V23.0631C1.70462 23.0272 0.147949 21.4505 0.147949 19.5147V3.54877C0.147949 1.59295 1.74055 0.000366211 3.69637 0.000366211H24.9829C26.9387 0.000366211 28.5313 1.59295 28.5313 3.54877V19.5147C28.5313 21.4705 26.9387 23.0631 24.9829 23.0631H10.2384L5.01356 26.5277C4.86587 26.6235 4.69424 26.6754 4.52261 26.6754H4.51861ZM3.69637 1.77258C2.71846 1.77258 1.92416 2.56689 1.92416 3.5448V19.5107C1.92416 20.4886 2.71846 21.2829 3.69637 21.2829H4.51861C5.00957 21.2829 5.40472 21.6781 5.40472 22.169V24.1288L9.47603 21.4306C9.61972 21.3348 9.79135 21.2829 9.96698 21.2829H24.9829C25.9608 21.2829 26.7551 20.4886 26.7551 19.5107V3.5448C26.7551 2.56689 25.9608 1.77258 24.9829 1.77258H3.69637Z" fill="white"/>
|
|
18
|
+
<path d="M29.4813 31.996C29.3097 31.996 29.138 31.9441 28.9904 31.8483L23.7655 28.3837H14.3376C13.3597 28.3837 12.5654 27.5894 12.5654 26.6115V25.7254C12.5654 25.2345 12.9606 24.8393 13.4515 24.8393C13.9425 24.8393 14.3376 25.2345 14.3376 25.7254V26.6115H24.0329C24.2086 26.6115 24.3762 26.6634 24.5239 26.7592L28.5952 29.4575V27.4976C28.5952 27.0067 28.9904 26.6115 29.4813 26.6115H31.1936C31.6846 26.6115 32.0798 26.2124 32.0798 25.7254V10.6456H31.1936C30.7027 10.6456 30.3075 10.2505 30.3075 9.75951C30.3075 9.26856 30.7027 8.87341 31.1936 8.87341H32.0798C33.0577 8.87341 33.852 9.66772 33.852 10.6456V25.7254C33.852 27.1943 32.6585 28.3877 31.1897 28.3877H30.3634V31.1139C30.3634 31.4412 30.1838 31.7406 29.8964 31.8962C29.7647 31.9681 29.621 32 29.4773 32L29.4813 31.996Z" fill="white"/>
|
|
19
|
+
<circle cx="6.89941" cy="11.5537" r="1.5" fill="#AA1D36"/>
|
|
20
|
+
<circle cx="14.3271" cy="11.5537" r="1.5" fill="#AA1D36"/>
|
|
21
|
+
<circle cx="21.7549" cy="11.5537" r="1.5" fill="#AA1D36"/>
|
|
22
|
+
</svg>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div className={`
|
|
26
|
+
absolute inset-0 flex items-center justify-center
|
|
27
|
+
transition-opacity duration-300 ease-in-out
|
|
28
|
+
${!isOpen ? 'opacity-0' : 'opacity-100'}
|
|
29
|
+
`}>
|
|
30
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
31
|
+
<path d="M6 6L18 18" stroke="#777777" strokeWidth="2" strokeLinecap="round"/>
|
|
32
|
+
<path d="M18 6L6 18" stroke="#777777" strokeWidth="2" strokeLinecap="round"/>
|
|
33
|
+
</svg>
|
|
34
|
+
</div>
|
|
35
|
+
</button>);
|
|
36
|
+
};
|
|
37
|
+
export default ChatButton;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ChatButtonProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
onClick: () => void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const ChatButton: React.FC<ChatButtonProps> = ({ isOpen, onClick }) => {
|
|
9
|
+
return (
|
|
10
|
+
<button
|
|
11
|
+
aria-label="채팅 상담 열기"
|
|
12
|
+
onClick={onClick}
|
|
13
|
+
className={`
|
|
14
|
+
fixed bottom-[30px] right-[30px] h-[60px] w-[60px] rounded-[10px] border
|
|
15
|
+
${isOpen ? 'border-gray-200 bg-white' : 'border-[#AA1D36] bg-[#AA1D36]'}
|
|
16
|
+
z-[999999] flex transform cursor-pointer items-center justify-center
|
|
17
|
+
p-0 shadow-lg outline-none transition-all duration-300 ease-in-out
|
|
18
|
+
hover:${isOpen ? 'bg-gray-100' : 'bg-[#8A1729]'}
|
|
19
|
+
`}
|
|
20
|
+
>
|
|
21
|
+
<div
|
|
22
|
+
className={`
|
|
23
|
+
absolute inset-0 flex items-center justify-center
|
|
24
|
+
transition-opacity duration-300 ease-in-out
|
|
25
|
+
${isOpen ? 'opacity-0' : 'opacity-100'}
|
|
26
|
+
`}
|
|
27
|
+
>
|
|
28
|
+
<svg width="34" height="32" viewBox="0 0 34 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
29
|
+
<path
|
|
30
|
+
d="M24.9835 0.886475H3.69698C2.22812 0.886475 1.03467 2.07593 1.03467 3.54878V19.5147C1.03467 20.9835 2.22413 22.177 3.69698 22.177H4.51923V25.7893L9.96759 22.177H24.9835C26.4524 22.177 27.6458 20.9875 27.6458 19.5147V3.54878C27.6458 2.07992 26.4564 0.886475 24.9835 0.886475Z"
|
|
31
|
+
fill="white"
|
|
32
|
+
/>
|
|
33
|
+
<path
|
|
34
|
+
d="M4.51861 26.6754C4.37492 26.6754 4.23123 26.6395 4.09951 26.5716C3.81212 26.416 3.63251 26.1166 3.63251 25.7893V23.0631C1.70462 23.0272 0.147949 21.4505 0.147949 19.5147V3.54877C0.147949 1.59295 1.74055 0.000366211 3.69637 0.000366211H24.9829C26.9387 0.000366211 28.5313 1.59295 28.5313 3.54877V19.5147C28.5313 21.4705 26.9387 23.0631 24.9829 23.0631H10.2384L5.01356 26.5277C4.86587 26.6235 4.69424 26.6754 4.52261 26.6754H4.51861ZM3.69637 1.77258C2.71846 1.77258 1.92416 2.56689 1.92416 3.5448V19.5107C1.92416 20.4886 2.71846 21.2829 3.69637 21.2829H4.51861C5.00957 21.2829 5.40472 21.6781 5.40472 22.169V24.1288L9.47603 21.4306C9.61972 21.3348 9.79135 21.2829 9.96698 21.2829H24.9829C25.9608 21.2829 26.7551 20.4886 26.7551 19.5107V3.5448C26.7551 2.56689 25.9608 1.77258 24.9829 1.77258H3.69637Z"
|
|
35
|
+
fill="white"
|
|
36
|
+
/>
|
|
37
|
+
<path
|
|
38
|
+
d="M29.4813 31.996C29.3097 31.996 29.138 31.9441 28.9904 31.8483L23.7655 28.3837H14.3376C13.3597 28.3837 12.5654 27.5894 12.5654 26.6115V25.7254C12.5654 25.2345 12.9606 24.8393 13.4515 24.8393C13.9425 24.8393 14.3376 25.2345 14.3376 25.7254V26.6115H24.0329C24.2086 26.6115 24.3762 26.6634 24.5239 26.7592L28.5952 29.4575V27.4976C28.5952 27.0067 28.9904 26.6115 29.4813 26.6115H31.1936C31.6846 26.6115 32.0798 26.2124 32.0798 25.7254V10.6456H31.1936C30.7027 10.6456 30.3075 10.2505 30.3075 9.75951C30.3075 9.26856 30.7027 8.87341 31.1936 8.87341H32.0798C33.0577 8.87341 33.852 9.66772 33.852 10.6456V25.7254C33.852 27.1943 32.6585 28.3877 31.1897 28.3877H30.3634V31.1139C30.3634 31.4412 30.1838 31.7406 29.8964 31.8962C29.7647 31.9681 29.621 32 29.4773 32L29.4813 31.996Z"
|
|
39
|
+
fill="white"
|
|
40
|
+
/>
|
|
41
|
+
<circle cx="6.89941" cy="11.5537" r="1.5" fill="#AA1D36" />
|
|
42
|
+
<circle cx="14.3271" cy="11.5537" r="1.5" fill="#AA1D36" />
|
|
43
|
+
<circle cx="21.7549" cy="11.5537" r="1.5" fill="#AA1D36" />
|
|
44
|
+
</svg>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<div
|
|
48
|
+
className={`
|
|
49
|
+
absolute inset-0 flex items-center justify-center
|
|
50
|
+
transition-opacity duration-300 ease-in-out
|
|
51
|
+
${!isOpen ? 'opacity-0' : 'opacity-100'}
|
|
52
|
+
`}
|
|
53
|
+
>
|
|
54
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
55
|
+
<path d="M6 6L18 18" stroke="#777777" strokeWidth="2" strokeLinecap="round" />
|
|
56
|
+
<path d="M18 6L6 18" stroke="#777777" strokeWidth="2" strokeLinecap="round" />
|
|
57
|
+
</svg>
|
|
58
|
+
</div>
|
|
59
|
+
</button>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default ChatButton;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
3
|
+
import ChatMessage from './ChatMessage';
|
|
4
|
+
import ChatInput from './ChatInput';
|
|
5
|
+
import NoticeMessage from './NoticeMessage';
|
|
6
|
+
import DateSeparator from './DateSeparator';
|
|
7
|
+
import Image from 'next/image';
|
|
8
|
+
const ChatConversation = ({ onBackClick }) => {
|
|
9
|
+
const { messages, isLoading } = useDaeryuntalk();
|
|
10
|
+
const messagesEndRef = useRef(null);
|
|
11
|
+
const [showNotice] = useState(true);
|
|
12
|
+
const noticeContent = '본 채팅을 통해 제공되는 서비스는 일반적인 법률정보 제공 및 고객 편의 도모를 위한 것 입니다. 본 채팅을 통해 제공된 정보를 이용한 행위에 대해서는 당사는 어떠한 법적 책임을 지지 않으며 구체적인 사안에 대한 적용은 변호사와의 추가 상담을 통해 자문을 받으시기를 권해드립니다.';
|
|
13
|
+
// 새 메시지가 도착할 때 자동으로 스크롤 최하단으로 이동
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
var _a;
|
|
16
|
+
(_a = messagesEndRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: 'smooth' });
|
|
17
|
+
}, [messages]);
|
|
18
|
+
const isNewDay = (date1, date2) => {
|
|
19
|
+
return (date1.getFullYear() !== date2.getFullYear() ||
|
|
20
|
+
date1.getMonth() !== date2.getMonth() ||
|
|
21
|
+
date1.getDate() !== date2.getDate());
|
|
22
|
+
};
|
|
23
|
+
const renderMessagesWithDateSeparators = () => {
|
|
24
|
+
const elements = [];
|
|
25
|
+
messages.forEach((message, index) => {
|
|
26
|
+
if (index === 0 || isNewDay(message.createdAt, messages[index - 1].createdAt)) {
|
|
27
|
+
elements.push(<DateSeparator key={`date-${message.msgNo}`} date={message.createdAt}/>);
|
|
28
|
+
}
|
|
29
|
+
elements.push(<ChatMessage key={message.msgNo} message={message}/>);
|
|
30
|
+
});
|
|
31
|
+
return elements;
|
|
32
|
+
};
|
|
33
|
+
const handleBackClick = () => {
|
|
34
|
+
if (onBackClick) {
|
|
35
|
+
onBackClick();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return (<div className="flex h-full flex-col">
|
|
39
|
+
<div className="flex items-center justify-between border-b border-gray-200 p-4">
|
|
40
|
+
<button className="flex h-7 w-7 items-center justify-center" aria-label="이전" onClick={handleBackClick}>
|
|
41
|
+
<Image src="/images/daeryuntalk/prev.svg" alt="이전" width={28} height={28}/>
|
|
42
|
+
</button>
|
|
43
|
+
<div className="flex items-center">
|
|
44
|
+
<div className="relative mr-2 h-6 w-6">
|
|
45
|
+
<Image src="/images/daeryuntalk/daeryun-logo.svg" alt="대륜 로고" width={28} height={28}/>
|
|
46
|
+
</div>
|
|
47
|
+
<h2 className="font-bold leading-[140%] tracking-[-4%]">법무법인(유한)대륜</h2>
|
|
48
|
+
</div>
|
|
49
|
+
<div className="w-7"></div>
|
|
50
|
+
</div>
|
|
51
|
+
{showNotice && <NoticeMessage content={noticeContent}/>}
|
|
52
|
+
<div className="flex-1 overflow-y-auto p-4">
|
|
53
|
+
{messages.length === 0 ? (<div className="flex h-full flex-col items-center justify-center text-center text-gray-500">
|
|
54
|
+
<p>문의하실 내용을 입력해 주세요.</p>
|
|
55
|
+
<p className="mt-2 text-sm">24시간 운영하고 있습니다.</p>
|
|
56
|
+
</div>) : (<>
|
|
57
|
+
{renderMessagesWithDateSeparators()}
|
|
58
|
+
{isLoading && (<div className="flex justify-start">
|
|
59
|
+
<div className="flex h-8 animate-pulse space-x-2 rounded-full bg-gray-100 px-4 py-2">
|
|
60
|
+
<div className="h-1 w-1 animate-bounce rounded-full bg-gray-500"></div>
|
|
61
|
+
<div className="h-1 w-1 animate-bounce rounded-full bg-gray-500" style={{ animationDelay: '0.2s' }}></div>
|
|
62
|
+
<div className="h-1 w-1 animate-bounce rounded-full bg-gray-500" style={{ animationDelay: '0.4s' }}></div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>)}
|
|
65
|
+
<div ref={messagesEndRef}/>
|
|
66
|
+
</>)}
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<div className="border-t border-gray-200 p-4">
|
|
70
|
+
<ChatInput />
|
|
71
|
+
</div>
|
|
72
|
+
</div>);
|
|
73
|
+
};
|
|
74
|
+
export default ChatConversation;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
3
|
+
import ChatMessage from './ChatMessage';
|
|
4
|
+
import ChatInput from './ChatInput';
|
|
5
|
+
import NoticeMessage from './NoticeMessage';
|
|
6
|
+
import DateSeparator from './DateSeparator';
|
|
7
|
+
import Image from 'next/image';
|
|
8
|
+
|
|
9
|
+
type ChatConversationProps = {
|
|
10
|
+
onBackClick?: () => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick }) => {
|
|
14
|
+
const { messages, isLoading } = useDaeryuntalk();
|
|
15
|
+
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
16
|
+
const [showNotice] = useState(true);
|
|
17
|
+
|
|
18
|
+
const noticeContent =
|
|
19
|
+
'본 채팅을 통해 제공되는 서비스는 일반적인 법률정보 제공 및 고객 편의 도모를 위한 것 입니다. 본 채팅을 통해 제공된 정보를 이용한 행위에 대해서는 당사는 어떠한 법적 책임을 지지 않으며 구체적인 사안에 대한 적용은 변호사와의 추가 상담을 통해 자문을 받으시기를 권해드립니다.';
|
|
20
|
+
|
|
21
|
+
// 새 메시지가 도착할 때 자동으로 스크롤 최하단으로 이동
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
24
|
+
}, [messages]);
|
|
25
|
+
|
|
26
|
+
const isNewDay = (date1: Date, date2: Date): boolean => {
|
|
27
|
+
return (
|
|
28
|
+
date1.getFullYear() !== date2.getFullYear() ||
|
|
29
|
+
date1.getMonth() !== date2.getMonth() ||
|
|
30
|
+
date1.getDate() !== date2.getDate()
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const renderMessagesWithDateSeparators = () => {
|
|
35
|
+
const elements: JSX.Element[] = [];
|
|
36
|
+
|
|
37
|
+
messages.forEach((message, index) => {
|
|
38
|
+
if (index === 0 || isNewDay(message.createdAt, messages[index - 1].createdAt)) {
|
|
39
|
+
elements.push(<DateSeparator key={`date-${message.msgNo}`} date={message.createdAt} />);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
elements.push(<ChatMessage key={message.msgNo} message={message} />);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return elements;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const handleBackClick = () => {
|
|
49
|
+
if (onBackClick) {
|
|
50
|
+
onBackClick();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div className="flex h-full flex-col">
|
|
56
|
+
<div className="flex items-center justify-between border-b border-gray-200 p-4">
|
|
57
|
+
<button
|
|
58
|
+
className="flex h-7 w-7 items-center justify-center"
|
|
59
|
+
aria-label="이전"
|
|
60
|
+
onClick={handleBackClick}
|
|
61
|
+
>
|
|
62
|
+
<Image src="/images/daeryuntalk/prev.svg" alt="이전" width={28} height={28} />
|
|
63
|
+
</button>
|
|
64
|
+
<div className="flex items-center">
|
|
65
|
+
<div className="relative mr-2 h-6 w-6">
|
|
66
|
+
<Image src="/images/daeryuntalk/daeryun-logo.svg" alt="대륜 로고" width={28} height={28} />
|
|
67
|
+
</div>
|
|
68
|
+
<h2 className="font-bold leading-[140%] tracking-[-4%]">법무법인(유한)대륜</h2>
|
|
69
|
+
</div>
|
|
70
|
+
<div className="w-7"></div>
|
|
71
|
+
</div>
|
|
72
|
+
{showNotice && <NoticeMessage content={noticeContent} />}
|
|
73
|
+
<div className="flex-1 overflow-y-auto p-4">
|
|
74
|
+
{messages.length === 0 ? (
|
|
75
|
+
<div className="flex h-full flex-col items-center justify-center text-center text-gray-500">
|
|
76
|
+
<p>문의하실 내용을 입력해 주세요.</p>
|
|
77
|
+
<p className="mt-2 text-sm">24시간 운영하고 있습니다.</p>
|
|
78
|
+
</div>
|
|
79
|
+
) : (
|
|
80
|
+
<>
|
|
81
|
+
{renderMessagesWithDateSeparators()}
|
|
82
|
+
{isLoading && (
|
|
83
|
+
<div className="flex justify-start">
|
|
84
|
+
<div className="flex h-8 animate-pulse space-x-2 rounded-full bg-gray-100 px-4 py-2">
|
|
85
|
+
<div className="h-1 w-1 animate-bounce rounded-full bg-gray-500"></div>
|
|
86
|
+
<div
|
|
87
|
+
className="h-1 w-1 animate-bounce rounded-full bg-gray-500"
|
|
88
|
+
style={{ animationDelay: '0.2s' }}
|
|
89
|
+
></div>
|
|
90
|
+
<div
|
|
91
|
+
className="h-1 w-1 animate-bounce rounded-full bg-gray-500"
|
|
92
|
+
style={{ animationDelay: '0.4s' }}
|
|
93
|
+
></div>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
<div ref={messagesEndRef} />
|
|
98
|
+
</>
|
|
99
|
+
)}
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<div className="border-t border-gray-200 p-4">
|
|
103
|
+
<ChatInput />
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default ChatConversation;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
3
|
+
import ChatConversation from './ChatConversation';
|
|
4
|
+
import HistoryView from './HistoryView';
|
|
5
|
+
import NavigationFooter from './NavigationFooter';
|
|
6
|
+
import Image from 'next/image';
|
|
7
|
+
const ChatHomeView = () => {
|
|
8
|
+
const { sendMessage, viewHistory, messages } = useDaeryuntalk();
|
|
9
|
+
const [viewState, setViewState] = useState('home');
|
|
10
|
+
const [selectedHistoryId, setSelectedHistoryId] = useState(null);
|
|
11
|
+
const handleStartChat = () => {
|
|
12
|
+
sendMessage('상담 문의 드립니다.');
|
|
13
|
+
setViewState('conversation');
|
|
14
|
+
};
|
|
15
|
+
const handleHistoryClick = () => {
|
|
16
|
+
viewHistory();
|
|
17
|
+
setViewState('history');
|
|
18
|
+
};
|
|
19
|
+
const handleBackToHome = () => {
|
|
20
|
+
setViewState('home');
|
|
21
|
+
};
|
|
22
|
+
const handleChatHistoryClick = (historyId) => {
|
|
23
|
+
setSelectedHistoryId(historyId);
|
|
24
|
+
viewHistory();
|
|
25
|
+
setViewState('conversation');
|
|
26
|
+
};
|
|
27
|
+
if (viewState === 'conversation') {
|
|
28
|
+
return (<main className="flex h-[690px] w-[390px] items-center justify-center rounded-[30px]">
|
|
29
|
+
<div className="relative h-[690px] w-[390px] overflow-hidden rounded-[30px] bg-white shadow-[0px_12px_60px_5px_rgba(0,0,0,0.3)]">
|
|
30
|
+
<ChatConversation onBackClick={handleBackToHome}/>
|
|
31
|
+
</div>
|
|
32
|
+
</main>);
|
|
33
|
+
}
|
|
34
|
+
const renderWithNavigation = (content, activeView) => {
|
|
35
|
+
return (<main className="flex h-[690px] w-[390px] items-center justify-center rounded-[30px]">
|
|
36
|
+
<div className="relative h-[690px] w-[390px] overflow-hidden rounded-[30px] bg-white shadow-[0px_12px_60px_5px_rgba(0,0,0,0.3)]">
|
|
37
|
+
<div className="flex h-full flex-col">
|
|
38
|
+
<div className="flex-1 overflow-hidden">{content}</div>
|
|
39
|
+
|
|
40
|
+
<NavigationFooter activeView={activeView} onHomeClick={handleBackToHome} onHistoryClick={handleHistoryClick}/>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</main>);
|
|
44
|
+
};
|
|
45
|
+
if (viewState === 'history') {
|
|
46
|
+
return renderWithNavigation(<HistoryView onBackClick={handleBackToHome} onChatHistoryClick={handleChatHistoryClick} onNewChatClick={handleStartChat}/>, 'history');
|
|
47
|
+
}
|
|
48
|
+
return renderWithNavigation(<div className="relative h-full w-full">
|
|
49
|
+
<div className="absolute left-0 top-0 z-0 h-full w-full bg-contain bg-top bg-no-repeat will-change-transform" style={{
|
|
50
|
+
backgroundImage: "url('/images/daeryuntalk/daeryuntalk-intro.png')"
|
|
51
|
+
}}/>
|
|
52
|
+
|
|
53
|
+
<div className="relative z-10 flex h-full flex-col">
|
|
54
|
+
<header className="mt-2 flex items-center p-4 text-xs text-black">
|
|
55
|
+
<Image src="/images/daeryuntalk/time.svg" alt="24시간 운영" className="mr-1" width={16} height={16} priority={true}/>
|
|
56
|
+
<span>24시간 운영</span>
|
|
57
|
+
</header>
|
|
58
|
+
|
|
59
|
+
<section className="mx-auto mt-[150px] flex w-[320px] flex-col gap-5 rounded-[12px] bg-white px-4 py-6 shadow-[0px_4px_10px_0px_#00000026]">
|
|
60
|
+
<div className="flex items-center">
|
|
61
|
+
<Image src="/images/daeryuntalk/daeryun-logo.svg" alt="대륜 로고" className="mr-2" width={24} height={24} priority={true}/>
|
|
62
|
+
<h1 className="font-medium">법무법인(유한)대륜</h1>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<div className="mx-8 text-sm font-normal leading-[130%]">
|
|
66
|
+
안녕하세요.
|
|
67
|
+
<br />
|
|
68
|
+
법무법인(유한)대륜입니다.
|
|
69
|
+
<br />
|
|
70
|
+
방문해 주셔서 감사합니다.
|
|
71
|
+
<br />
|
|
72
|
+
궁금한 점이나 도움이 필요하신 부분
|
|
73
|
+
<br />
|
|
74
|
+
말씀해 주시면 도와드리겠습니다.
|
|
75
|
+
<br />
|
|
76
|
+
<br />
|
|
77
|
+
6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<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}>
|
|
81
|
+
문의하기
|
|
82
|
+
<Image src="/images/daeryuntalk/send.svg" alt="" width={24} height={24} aria-hidden="true" priority={true}/>
|
|
83
|
+
</button>
|
|
84
|
+
|
|
85
|
+
<div className="flex items-center justify-center gap-1">
|
|
86
|
+
<Image src="/images/daeryuntalk/info.svg" alt="" width={20} height={20} aria-hidden="true" priority={true}/>
|
|
87
|
+
<span className="text-xs font-normal text-gray-500">빠르게 답변 받으실 수 있어요</span>
|
|
88
|
+
</div>
|
|
89
|
+
</section>
|
|
90
|
+
</div>
|
|
91
|
+
</div>, 'home');
|
|
92
|
+
};
|
|
93
|
+
export default ChatHomeView;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
3
|
+
import ChatConversation from './ChatConversation';
|
|
4
|
+
import HistoryView from './HistoryView';
|
|
5
|
+
import NavigationFooter from './NavigationFooter';
|
|
6
|
+
import Image from 'next/image';
|
|
7
|
+
|
|
8
|
+
type ViewState = 'home' | 'conversation' | 'history' | 'historyDetail';
|
|
9
|
+
|
|
10
|
+
const ChatHomeView: React.FC = () => {
|
|
11
|
+
const { sendMessage, viewHistory, messages } = useDaeryuntalk();
|
|
12
|
+
const [viewState, setViewState] = useState<ViewState>('home');
|
|
13
|
+
const [selectedHistoryId, setSelectedHistoryId] = useState<string | null>(null);
|
|
14
|
+
|
|
15
|
+
const handleStartChat = () => {
|
|
16
|
+
sendMessage('상담 문의 드립니다.');
|
|
17
|
+
setViewState('conversation');
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const handleHistoryClick = () => {
|
|
21
|
+
viewHistory();
|
|
22
|
+
setViewState('history');
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const handleBackToHome = () => {
|
|
26
|
+
setViewState('home');
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const handleChatHistoryClick = (historyId: string) => {
|
|
30
|
+
setSelectedHistoryId(historyId);
|
|
31
|
+
viewHistory();
|
|
32
|
+
setViewState('conversation');
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
if (viewState === 'conversation') {
|
|
36
|
+
return (
|
|
37
|
+
<main className="flex h-[690px] w-[390px] items-center justify-center rounded-[30px]">
|
|
38
|
+
<div className="relative h-[690px] w-[390px] overflow-hidden rounded-[30px] bg-white shadow-[0px_12px_60px_5px_rgba(0,0,0,0.3)]">
|
|
39
|
+
<ChatConversation onBackClick={handleBackToHome} />
|
|
40
|
+
</div>
|
|
41
|
+
</main>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const renderWithNavigation = (content: React.ReactNode, activeView: 'home' | 'history') => {
|
|
46
|
+
return (
|
|
47
|
+
<main className="flex h-[690px] w-[390px] items-center justify-center rounded-[30px]">
|
|
48
|
+
<div className="relative h-[690px] w-[390px] overflow-hidden rounded-[30px] bg-white shadow-[0px_12px_60px_5px_rgba(0,0,0,0.3)]">
|
|
49
|
+
<div className="flex h-full flex-col">
|
|
50
|
+
<div className="flex-1 overflow-hidden">{content}</div>
|
|
51
|
+
|
|
52
|
+
<NavigationFooter
|
|
53
|
+
activeView={activeView}
|
|
54
|
+
onHomeClick={handleBackToHome}
|
|
55
|
+
onHistoryClick={handleHistoryClick}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</main>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
if (viewState === 'history') {
|
|
64
|
+
return renderWithNavigation(
|
|
65
|
+
<HistoryView
|
|
66
|
+
onBackClick={handleBackToHome}
|
|
67
|
+
onChatHistoryClick={handleChatHistoryClick}
|
|
68
|
+
onNewChatClick={handleStartChat}
|
|
69
|
+
/>,
|
|
70
|
+
'history'
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return renderWithNavigation(
|
|
75
|
+
<div className="relative h-full w-full">
|
|
76
|
+
<div
|
|
77
|
+
className="absolute left-0 top-0 z-0 h-full w-full bg-contain bg-top bg-no-repeat will-change-transform"
|
|
78
|
+
style={{
|
|
79
|
+
backgroundImage: "url('/images/daeryuntalk/daeryuntalk-intro.png')"
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
|
|
83
|
+
<div className="relative z-10 flex h-full flex-col">
|
|
84
|
+
<header className="mt-2 flex items-center p-4 text-xs text-black">
|
|
85
|
+
<Image
|
|
86
|
+
src="/images/daeryuntalk/time.svg"
|
|
87
|
+
alt="24시간 운영"
|
|
88
|
+
className="mr-1"
|
|
89
|
+
width={16}
|
|
90
|
+
height={16}
|
|
91
|
+
priority={true}
|
|
92
|
+
/>
|
|
93
|
+
<span>24시간 운영</span>
|
|
94
|
+
</header>
|
|
95
|
+
|
|
96
|
+
<section className="mx-auto mt-[150px] flex w-[320px] flex-col gap-5 rounded-[12px] bg-white px-4 py-6 shadow-[0px_4px_10px_0px_#00000026]">
|
|
97
|
+
<div className="flex items-center">
|
|
98
|
+
<Image
|
|
99
|
+
src="/images/daeryuntalk/daeryun-logo.svg"
|
|
100
|
+
alt="대륜 로고"
|
|
101
|
+
className="mr-2"
|
|
102
|
+
width={24}
|
|
103
|
+
height={24}
|
|
104
|
+
priority={true}
|
|
105
|
+
/>
|
|
106
|
+
<h1 className="font-medium">법무법인(유한)대륜</h1>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<div className="mx-8 text-sm font-normal leading-[130%]">
|
|
110
|
+
안녕하세요.
|
|
111
|
+
<br />
|
|
112
|
+
법무법인(유한)대륜입니다.
|
|
113
|
+
<br />
|
|
114
|
+
방문해 주셔서 감사합니다.
|
|
115
|
+
<br />
|
|
116
|
+
궁금한 점이나 도움이 필요하신 부분
|
|
117
|
+
<br />
|
|
118
|
+
말씀해 주시면 도와드리겠습니다.
|
|
119
|
+
<br />
|
|
120
|
+
<br />
|
|
121
|
+
6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
<button
|
|
125
|
+
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"
|
|
126
|
+
aria-label="문의하기"
|
|
127
|
+
onClick={handleStartChat}
|
|
128
|
+
>
|
|
129
|
+
문의하기
|
|
130
|
+
<Image
|
|
131
|
+
src="/images/daeryuntalk/send.svg"
|
|
132
|
+
alt=""
|
|
133
|
+
width={24}
|
|
134
|
+
height={24}
|
|
135
|
+
aria-hidden="true"
|
|
136
|
+
priority={true}
|
|
137
|
+
/>
|
|
138
|
+
</button>
|
|
139
|
+
|
|
140
|
+
<div className="flex items-center justify-center gap-1">
|
|
141
|
+
<Image
|
|
142
|
+
src="/images/daeryuntalk/info.svg"
|
|
143
|
+
alt=""
|
|
144
|
+
width={20}
|
|
145
|
+
height={20}
|
|
146
|
+
aria-hidden="true"
|
|
147
|
+
priority={true}
|
|
148
|
+
/>
|
|
149
|
+
<span className="text-xs font-normal text-gray-500">빠르게 답변 받으실 수 있어요</span>
|
|
150
|
+
</div>
|
|
151
|
+
</section>
|
|
152
|
+
</div>
|
|
153
|
+
</div>,
|
|
154
|
+
'home'
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export default ChatHomeView;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
3
|
+
import Image from 'next/image';
|
|
4
|
+
const ChatInput = () => {
|
|
5
|
+
const [message, setMessage] = useState('');
|
|
6
|
+
const { sendMessage, isLoading } = useDaeryuntalk();
|
|
7
|
+
const handleSubmit = (e) => {
|
|
8
|
+
e.preventDefault();
|
|
9
|
+
if (message.trim() && !isLoading) {
|
|
10
|
+
sendMessage(message);
|
|
11
|
+
setMessage('');
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
return (<form onSubmit={handleSubmit} className="flex w-full items-center gap-2">
|
|
15
|
+
<input type="text" value={message} onChange={e => setMessage(e.target.value)} placeholder="메시지를 입력하세요..." className="flex-1 rounded-[8px] border border-gray-300 px-4 py-2 focus:border-[#2E385B] focus:outline-none" disabled={isLoading}/>
|
|
16
|
+
<button type="submit" className={`flex h-10 w-10 items-center justify-center rounded-[8px] bg-[#2E385B] text-white ${isLoading || !message.trim() ? 'cursor-not-allowed opacity-50' : 'bg-[#AA1D36]'}`} disabled={isLoading || !message.trim()}>
|
|
17
|
+
<div className="flex h-9 w-9 items-center justify-center">
|
|
18
|
+
<Image src="/images/daeryuntalk/send.svg" alt="전송" width={24} height={24}/>
|
|
19
|
+
</div>
|
|
20
|
+
</button>
|
|
21
|
+
</form>);
|
|
22
|
+
};
|
|
23
|
+
export default ChatInput;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
3
|
+
import Image from 'next/image';
|
|
4
|
+
|
|
5
|
+
const ChatInput: React.FC = () => {
|
|
6
|
+
const [message, setMessage] = useState('');
|
|
7
|
+
const { sendMessage, isLoading } = useDaeryuntalk();
|
|
8
|
+
|
|
9
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
10
|
+
e.preventDefault();
|
|
11
|
+
if (message.trim() && !isLoading) {
|
|
12
|
+
sendMessage(message);
|
|
13
|
+
setMessage('');
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<form onSubmit={handleSubmit} className="flex w-full items-center gap-2">
|
|
19
|
+
<input
|
|
20
|
+
type="text"
|
|
21
|
+
value={message}
|
|
22
|
+
onChange={e => setMessage(e.target.value)}
|
|
23
|
+
placeholder="메시지를 입력하세요..."
|
|
24
|
+
className="flex-1 rounded-[8px] border border-gray-300 px-4 py-2 focus:border-[#2E385B] focus:outline-none"
|
|
25
|
+
disabled={isLoading}
|
|
26
|
+
/>
|
|
27
|
+
<button
|
|
28
|
+
type="submit"
|
|
29
|
+
className={`flex h-10 w-10 items-center justify-center rounded-[8px] bg-[#2E385B] text-white ${
|
|
30
|
+
isLoading || !message.trim() ? 'cursor-not-allowed opacity-50' : 'bg-[#AA1D36]'
|
|
31
|
+
}`}
|
|
32
|
+
disabled={isLoading || !message.trim()}
|
|
33
|
+
>
|
|
34
|
+
<div className="flex h-9 w-9 items-center justify-center">
|
|
35
|
+
<Image src="/images/daeryuntalk/send.svg" alt="전송" width={24} height={24} />
|
|
36
|
+
</div>
|
|
37
|
+
</button>
|
|
38
|
+
</form>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default ChatInput;
|