@daeryun/dr_components 0.6.49 → 0.6.51
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/ChatConversation.jsx +11 -8
- package/dist/components/Daeryuntalk/ChatConversation.tsx +17 -9
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +54 -26
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +57 -27
- package/dist/components/Daeryuntalk/ChatMessage.jsx +3 -46
- package/dist/components/Daeryuntalk/ChatMessage.tsx +2 -81
- package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +3 -5
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +128 -501
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +149 -548
- package/dist/components/Daeryuntalk/index.jsx +1 -11
- package/dist/components/Daeryuntalk/index.tsx +1 -13
- package/dist/components/Daeryuntalk/socketManager.js +1 -9
- package/dist/components/Daeryuntalk/socketManager.ts +1 -9
- package/dist/components/Daeryuntalk/types.d.ts +14 -14
- package/dist/components/Daeryuntalk/types.js +0 -72
- package/dist/components/Daeryuntalk/types.ts +34 -104
- package/dist/components/common/integrate/index.d.ts +1 -1
- package/dist/lib/api/daeryuntalk/index.d.ts +64 -9
- package/dist/lib/api/daeryuntalk/index.js +79 -18
- package/dist/lib/api/daeryuntalk/index.ts +160 -31
- package/dist/lib/api/index.d.ts +0 -2
- package/dist/lib/api/index.js +0 -2
- package/dist/lib/api/index.ts +0 -2
- package/dist/styles/globals.css +0 -45
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/components/Daeryuntalk/DaeryuntalkProvider.d.ts +0 -11
- package/dist/components/Daeryuntalk/DaeryuntalkProvider.jsx +0 -59
- package/dist/components/Daeryuntalk/DaeryuntalkProvider.tsx +0 -68
- package/dist/components/Daeryuntalk/message-components/FileContent.d.ts +0 -8
- package/dist/components/Daeryuntalk/message-components/FileContent.jsx +0 -32
- package/dist/components/Daeryuntalk/message-components/FileContent.tsx +0 -43
- package/dist/components/Daeryuntalk/message-components/FormContent.d.ts +0 -8
- package/dist/components/Daeryuntalk/message-components/FormContent.jsx +0 -104
- package/dist/components/Daeryuntalk/message-components/FormContent.tsx +0 -184
- package/dist/lib/api/daeryuntalk/chatInquiry.d.ts +0 -23
- package/dist/lib/api/daeryuntalk/chatInquiry.js +0 -78
- package/dist/lib/api/daeryuntalk/chatInquiry.ts +0 -80
- package/dist/lib/api/daeryuntalk/useDaeryuntalkApi.d.ts +0 -23
- package/dist/lib/api/daeryuntalk/useDaeryuntalkApi.js +0 -140
- package/dist/lib/api/daeryuntalk/useDaeryuntalkApi.ts +0 -187
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
3
3
|
import ChatConversation from './ChatConversation';
|
|
4
4
|
import HistoryView from './HistoryView';
|
|
@@ -9,17 +9,35 @@ import TimeIcon from '../../asset/images/daeryuntalk/time.svg';
|
|
|
9
9
|
import InfoIcon from '../../asset/images/daeryuntalk/info.svg';
|
|
10
10
|
import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
11
11
|
import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk-intro.png';
|
|
12
|
+
import { ChatInquiryMainData } from '../../lib/api/daeryuntalk';
|
|
12
13
|
|
|
13
|
-
type ViewState = 'home' | 'conversation' | 'history'
|
|
14
|
+
type ViewState = 'home' | 'conversation' | 'history';
|
|
14
15
|
|
|
15
16
|
const ChatHomeView: React.FC = () => {
|
|
16
|
-
const {
|
|
17
|
+
const { viewHistory, inquiryMainData, startChat } = useDaeryuntalk();
|
|
17
18
|
const [viewState, setViewState] = useState<ViewState>('home');
|
|
18
19
|
const [selectedHistoryId, setSelectedHistoryId] = useState<string | null>(null);
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const [mainData, setMainData] = useState<ChatInquiryMainData | null>(null);
|
|
21
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (inquiryMainData?.data) {
|
|
25
|
+
setMainData(inquiryMainData.data);
|
|
26
|
+
}
|
|
27
|
+
}, [inquiryMainData]);
|
|
28
|
+
|
|
29
|
+
const handleStartChat = async () => {
|
|
30
|
+
try {
|
|
31
|
+
setIsLoading(true);
|
|
32
|
+
// 채팅 시작 - 새 문의 생성 또는 기존 문의 조회 처리
|
|
33
|
+
await startChat();
|
|
34
|
+
// 대화 화면으로 전환
|
|
35
|
+
setViewState('conversation');
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error('채팅 시작 실패:', error);
|
|
38
|
+
} finally {
|
|
39
|
+
setIsLoading(false);
|
|
40
|
+
}
|
|
23
41
|
};
|
|
24
42
|
|
|
25
43
|
const handleHistoryClick = () => {
|
|
@@ -76,15 +94,18 @@ const ChatHomeView: React.FC = () => {
|
|
|
76
94
|
);
|
|
77
95
|
}
|
|
78
96
|
|
|
97
|
+
// 아직 커버이미지 url이 안나옴
|
|
98
|
+
// const backgroundImage = mainData?.sleeve_image_url ? mainData.sleeve_image_url : DaeryuntalkIntro;
|
|
99
|
+
const backgroundImage = DaeryuntalkIntro;
|
|
100
|
+
|
|
79
101
|
return renderWithNavigation(
|
|
80
102
|
<div className="relative h-full w-full">
|
|
81
103
|
<div className="absolute left-0 top-0 z-0 h-full w-full overflow-hidden">
|
|
82
104
|
<Image
|
|
83
|
-
src={
|
|
105
|
+
src={backgroundImage}
|
|
84
106
|
alt="대화 배경"
|
|
85
107
|
fill
|
|
86
108
|
className="object-contain object-top will-change-transform"
|
|
87
|
-
priority
|
|
88
109
|
/>
|
|
89
110
|
</div>
|
|
90
111
|
|
|
@@ -96,37 +117,46 @@ const ChatHomeView: React.FC = () => {
|
|
|
96
117
|
|
|
97
118
|
<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]">
|
|
98
119
|
<div className="flex items-center">
|
|
99
|
-
|
|
100
|
-
|
|
120
|
+
{mainData?.channel_logo_image_url ? (
|
|
121
|
+
<Image
|
|
122
|
+
src={mainData.channel_logo_image_url}
|
|
123
|
+
alt="로고"
|
|
124
|
+
width={24}
|
|
125
|
+
height={24}
|
|
126
|
+
className="mr-2"
|
|
127
|
+
/>
|
|
128
|
+
) : (
|
|
129
|
+
<DaeryunLogoIcon width={24} height={24} className="mr-2" />
|
|
130
|
+
)}
|
|
131
|
+
<h1 className="font-medium">{mainData?.channel_name || '법무법인(유한)대륜'}</h1>
|
|
101
132
|
</div>
|
|
102
133
|
|
|
103
|
-
<div className="mx-8 text-sm font-normal leading-[130%]">
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
말씀해 주시면 도와드리겠습니다.
|
|
113
|
-
<br />
|
|
114
|
-
<br />
|
|
115
|
-
6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.
|
|
134
|
+
<div className="mx-8 whitespace-pre-line text-sm font-normal leading-[130%]">
|
|
135
|
+
{mainData?.salutation ||
|
|
136
|
+
`안녕하세요.
|
|
137
|
+
법무법인(유한)대륜입니다.
|
|
138
|
+
방문해 주셔서 감사합니다.
|
|
139
|
+
궁금한 점이나 도움이 필요하신 부분
|
|
140
|
+
말씀해 주시면 도와드리겠습니다.
|
|
141
|
+
|
|
142
|
+
6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.`}
|
|
116
143
|
</div>
|
|
117
144
|
|
|
118
145
|
<button
|
|
119
146
|
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"
|
|
120
147
|
aria-label="문의하기"
|
|
121
148
|
onClick={handleStartChat}
|
|
149
|
+
disabled={isLoading}
|
|
122
150
|
>
|
|
123
|
-
문의하기
|
|
124
|
-
<SendIcon width={24} height={24} />
|
|
151
|
+
{isLoading ? '로딩 중...' : '문의하기'}
|
|
152
|
+
{!isLoading && <SendIcon width={24} height={24} />}
|
|
125
153
|
</button>
|
|
126
154
|
|
|
127
155
|
<div className="flex items-center justify-center gap-1">
|
|
128
156
|
<InfoIcon width={20} height={20} />
|
|
129
|
-
<span className="text-xs font-normal text-gray-500"
|
|
157
|
+
<span className="text-xs font-normal text-gray-500">
|
|
158
|
+
{mainData?.answer_speed_message || '빠르게 답변 받으실 수 있어요'}
|
|
159
|
+
</span>
|
|
130
160
|
</div>
|
|
131
161
|
</section>
|
|
132
162
|
</div>
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import { hasBlocks, hasButtons, hasFiles, hasImages, hasForm } from './types';
|
|
4
|
-
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
5
|
-
import FormContent from './message-components/FormContent';
|
|
6
|
-
import FileContent from './message-components/FileContent';
|
|
2
|
+
import { hasBlocks } from './types';
|
|
7
3
|
import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
8
4
|
const ChatMessage = ({ message }) => {
|
|
9
|
-
const { sendQuickReply } = useDaeryuntalk();
|
|
10
5
|
const isUser = message.sender === 'user';
|
|
11
6
|
const formatTime = (date) => {
|
|
12
7
|
const hours = date.getHours().toString().padStart(2, '0');
|
|
@@ -18,49 +13,11 @@ const ChatMessage = ({ message }) => {
|
|
|
18
13
|
const renderTextBlock = (block, index) => (<div key={`text-${index}`} className={`mb-1 rounded-[10px] border p-2 ${isUser ? 'border-[#2E385B] text-[#2E385B]' : 'border-[#EDEDED] text-black'}`}>
|
|
19
14
|
<p className="text-sm leading-[130%] tracking-[-4%]">{block.value}</p>
|
|
20
15
|
</div>);
|
|
21
|
-
|
|
22
|
-
const renderButton = (button, index) => (<button key={`button-${index}`} className="rounded-[20px] border border-[#2E385B4D] px-2.5 py-1.5 text-xs font-medium leading-[140%] tracking-[-4%] text-[#2E385B] transition-colors hover:bg-[#2E385B]/10" onClick={() => {
|
|
23
|
-
// 버튼 클릭 시 sendQuickReply 함수 호출
|
|
24
|
-
if (button.action === 'send') {
|
|
25
|
-
sendQuickReply(button.id, button.value);
|
|
26
|
-
}
|
|
27
|
-
else if (button.action === 'url' && button.value) {
|
|
28
|
-
window.open(button.value, '_blank');
|
|
29
|
-
}
|
|
30
|
-
// form 액션은 추후 구현 예정
|
|
31
|
-
}}>
|
|
32
|
-
{button.text}
|
|
33
|
-
</button>);
|
|
34
|
-
// 이미지 렌더링
|
|
35
|
-
const renderImage = (image, index) => (<div key={`image-${index}`} className={`
|
|
36
|
-
mb-1 rounded-[10px] p-2
|
|
37
|
-
${isUser ? 'border border-[#EDEDED] text-[#2E385B]' : 'border border-[#EDEDED] bg-white text-[#2E385B]'}
|
|
38
|
-
`}>
|
|
39
|
-
<div className="relative w-full overflow-hidden rounded-lg">
|
|
40
|
-
<Image src={image.url} alt={image.alt || '이미지'} width={300} height={200} className="object-cover" style={{ maxWidth: '100%', height: 'auto' }}/>
|
|
41
|
-
</div>
|
|
42
|
-
{image.caption && <p className="mt-2 text-sm">{image.caption}</p>}
|
|
43
|
-
</div>);
|
|
16
|
+
/** todo: trophy198 메시지 내용 렌더링 추후 추가 될듯 */
|
|
44
17
|
const renderMessageContent = () => {
|
|
45
|
-
var _a
|
|
18
|
+
var _a;
|
|
46
19
|
return (<div className="message-content">
|
|
47
|
-
{/* 텍스트 블록 렌더링 */}
|
|
48
20
|
{hasBlocks(message) && ((_a = message.blocks) === null || _a === void 0 ? void 0 : _a.map((block, index) => renderTextBlock(block, index)))}
|
|
49
|
-
|
|
50
|
-
{/* 이미지 렌더링 */}
|
|
51
|
-
{hasImages(message) && ((_b = message.images) === null || _b === void 0 ? void 0 : _b.map((image, index) => renderImage(image, index)))}
|
|
52
|
-
|
|
53
|
-
{/* 버튼 렌더링 */}
|
|
54
|
-
{hasButtons(message) && (<div className="my-1 flex flex-wrap gap-2">
|
|
55
|
-
{(_c = message.buttons) === null || _c === void 0 ? void 0 : _c.map((button, index) => renderButton(button, index))}
|
|
56
|
-
</div>)}
|
|
57
|
-
|
|
58
|
-
{/* 폼 렌더링 */}
|
|
59
|
-
{hasForm(message) && message.form && <FormContent form={message.form} messageId={message.msgNo}/>}
|
|
60
|
-
|
|
61
|
-
{/* 파일 렌더링 */}
|
|
62
|
-
{hasFiles(message) &&
|
|
63
|
-
((_d = message.files) === null || _d === void 0 ? void 0 : _d.map((file, index) => (<FileContent key={`file-${index}`} file={file} isUser={isUser}/>)))}
|
|
64
21
|
</div>);
|
|
65
22
|
};
|
|
66
23
|
return (<div className={`mb-4 flex ${isUser ? 'justify-end' : 'justify-start'}`}>
|
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
Message,
|
|
5
|
-
TextBlock,
|
|
6
|
-
Button,
|
|
7
|
-
FileInfo,
|
|
8
|
-
ImageInfo,
|
|
9
|
-
hasBlocks,
|
|
10
|
-
hasButtons,
|
|
11
|
-
hasFiles,
|
|
12
|
-
hasImages,
|
|
13
|
-
hasForm,
|
|
14
|
-
hasWebPage
|
|
15
|
-
} from './types';
|
|
16
|
-
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
17
|
-
import FormContent from './message-components/FormContent';
|
|
18
|
-
import FileContent from './message-components/FileContent';
|
|
2
|
+
import { Message, TextBlock, hasBlocks } from './types';
|
|
19
3
|
import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
20
4
|
|
|
21
5
|
type ChatMessageProps = {
|
|
@@ -23,7 +7,6 @@ type ChatMessageProps = {
|
|
|
23
7
|
};
|
|
24
8
|
|
|
25
9
|
const ChatMessage: React.FC<ChatMessageProps> = ({ message }) => {
|
|
26
|
-
const { sendQuickReply } = useDaeryuntalk();
|
|
27
10
|
const isUser = message.sender === 'user';
|
|
28
11
|
|
|
29
12
|
const formatTime = (date: Date): string => {
|
|
@@ -45,73 +28,11 @@ const ChatMessage: React.FC<ChatMessageProps> = ({ message }) => {
|
|
|
45
28
|
<p className="text-sm leading-[130%] tracking-[-4%]">{block.value}</p>
|
|
46
29
|
</div>
|
|
47
30
|
);
|
|
48
|
-
|
|
49
|
-
// 버튼 렌더링
|
|
50
|
-
const renderButton = (button: Button, index: number) => (
|
|
51
|
-
<button
|
|
52
|
-
key={`button-${index}`}
|
|
53
|
-
className="rounded-[20px] border border-[#2E385B4D] px-2.5 py-1.5 text-xs font-medium leading-[140%] tracking-[-4%] text-[#2E385B] transition-colors hover:bg-[#2E385B]/10"
|
|
54
|
-
onClick={() => {
|
|
55
|
-
// 버튼 클릭 시 sendQuickReply 함수 호출
|
|
56
|
-
if (button.action === 'send') {
|
|
57
|
-
sendQuickReply(button.id, button.value);
|
|
58
|
-
} else if (button.action === 'url' && button.value) {
|
|
59
|
-
window.open(button.value, '_blank');
|
|
60
|
-
}
|
|
61
|
-
// form 액션은 추후 구현 예정
|
|
62
|
-
}}
|
|
63
|
-
>
|
|
64
|
-
{button.text}
|
|
65
|
-
</button>
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
// 이미지 렌더링
|
|
69
|
-
const renderImage = (image: ImageInfo, index: number) => (
|
|
70
|
-
<div
|
|
71
|
-
key={`image-${index}`}
|
|
72
|
-
className={`
|
|
73
|
-
mb-1 rounded-[10px] p-2
|
|
74
|
-
${isUser ? 'border border-[#EDEDED] text-[#2E385B]' : 'border border-[#EDEDED] bg-white text-[#2E385B]'}
|
|
75
|
-
`}
|
|
76
|
-
>
|
|
77
|
-
<div className="relative w-full overflow-hidden rounded-lg">
|
|
78
|
-
<Image
|
|
79
|
-
src={image.url}
|
|
80
|
-
alt={image.alt || '이미지'}
|
|
81
|
-
width={300}
|
|
82
|
-
height={200}
|
|
83
|
-
className="object-cover"
|
|
84
|
-
style={{ maxWidth: '100%', height: 'auto' }}
|
|
85
|
-
/>
|
|
86
|
-
</div>
|
|
87
|
-
{image.caption && <p className="mt-2 text-sm">{image.caption}</p>}
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
90
|
-
|
|
31
|
+
/** todo: trophy198 메시지 내용 렌더링 추후 추가 될듯 */
|
|
91
32
|
const renderMessageContent = () => {
|
|
92
33
|
return (
|
|
93
34
|
<div className="message-content">
|
|
94
|
-
{/* 텍스트 블록 렌더링 */}
|
|
95
35
|
{hasBlocks(message) && message.blocks?.map((block, index) => renderTextBlock(block, index))}
|
|
96
|
-
|
|
97
|
-
{/* 이미지 렌더링 */}
|
|
98
|
-
{hasImages(message) && message.images?.map((image, index) => renderImage(image, index))}
|
|
99
|
-
|
|
100
|
-
{/* 버튼 렌더링 */}
|
|
101
|
-
{hasButtons(message) && (
|
|
102
|
-
<div className="my-1 flex flex-wrap gap-2">
|
|
103
|
-
{message.buttons?.map((button, index) => renderButton(button, index))}
|
|
104
|
-
</div>
|
|
105
|
-
)}
|
|
106
|
-
|
|
107
|
-
{/* 폼 렌더링 */}
|
|
108
|
-
{hasForm(message) && message.form && <FormContent form={message.form} messageId={message.msgNo} />}
|
|
109
|
-
|
|
110
|
-
{/* 파일 렌더링 */}
|
|
111
|
-
{hasFiles(message) &&
|
|
112
|
-
message.files?.map((file, index) => (
|
|
113
|
-
<FileContent key={`file-${index}`} file={file} isUser={isUser} />
|
|
114
|
-
))}
|
|
115
36
|
</div>
|
|
116
37
|
);
|
|
117
38
|
};
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { Message } from './types';
|
|
3
|
-
import { ChatInquiryDetailData } from '../../lib/api/daeryuntalk';
|
|
3
|
+
import { ChatInquiryDetailData, ChatInquiryMainResponse } from '../../lib/api/daeryuntalk';
|
|
4
4
|
type DaeryuntalkContextType = {
|
|
5
5
|
messages: Message[];
|
|
6
6
|
isConnected: boolean;
|
|
7
7
|
isLoading: boolean;
|
|
8
8
|
sendMessage: (text: string) => void;
|
|
9
|
-
sendQuickReply: (replyId: string, text: string) => void;
|
|
10
|
-
submitForm: (formId: string, data: Record<string, string>) => void;
|
|
11
|
-
sendImage: (imageUrl: string, alt?: string, caption?: string) => void;
|
|
12
|
-
sendFile: (fileUrl: string, fileName: string, fileType?: string, fileSize?: number) => void;
|
|
13
9
|
viewHistory: () => void;
|
|
14
10
|
initializeDaeryuntalk: (version?: string) => void;
|
|
11
|
+
startChat: () => Promise<string | void>;
|
|
15
12
|
isOpen?: boolean;
|
|
16
13
|
chatData?: ChatInquiryDetailData | null;
|
|
14
|
+
inquiryMainData?: ChatInquiryMainResponse | null;
|
|
17
15
|
isAuthenticated?: boolean;
|
|
18
16
|
isSocketInitialized?: boolean;
|
|
19
17
|
isSocketConnected?: boolean;
|