@daeryun/dr_components 0.7.83 → 0.7.85
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/minus.svg +4 -0
- package/dist/asset/images/daeryuntalk/plus.svg +4 -0
- package/dist/components/Daeryuntalk/ChatConversation.jsx +19 -11
- package/dist/components/Daeryuntalk/ChatConversation.tsx +43 -34
- package/dist/components/Daeryuntalk/ChatInput.jsx +2 -0
- package/dist/components/Daeryuntalk/ChatInput.tsx +2 -0
- package/dist/components/Daeryuntalk/ChatMessage.d.ts +1 -0
- package/dist/components/Daeryuntalk/ChatMessage.jsx +25 -8
- package/dist/components/Daeryuntalk/ChatMessage.tsx +45 -15
- package/dist/components/Daeryuntalk/ChatObject/FieldWorkObject.d.ts +9 -0
- package/dist/components/Daeryuntalk/ChatObject/FieldWorkObject.jsx +33 -0
- package/dist/components/Daeryuntalk/ChatObject/FieldWorkObject.tsx +65 -0
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.jsx +10 -3
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.tsx +12 -4
- package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +2 -0
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +6 -3
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +8 -3
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.jsx +15 -12
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.tsx +15 -11
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +1 -1
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +1 -1
- package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.d.ts +1 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.ts +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +3 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +6 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useWorkFlow.d.ts +9 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useWorkFlow.js +109 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useWorkFlow.ts +122 -0
- package/dist/components/Daeryuntalk/_lib/index.js +5 -2
- package/dist/components/Daeryuntalk/_lib/index.ts +5 -2
- package/dist/components/Daeryuntalk/_types/message_object.d.ts +1 -0
- package/dist/components/Daeryuntalk/_types/message_object.ts +1 -0
- package/dist/components/Daeryuntalk/index.d.ts +4 -1
- package/dist/components/Daeryuntalk/index.jsx +2 -2
- package/dist/components/Daeryuntalk/index.tsx +6 -2
- package/dist/components/common/strength/index.js +15 -11
- package/dist/components/common/strength/index.ts +15 -11
- package/dist/components/page/Strength/StrengthList.jsx +17 -0
- package/dist/components/page/Strength/StrengthList.tsx +31 -0
- package/dist/styles/globals.css +39 -9
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="13" height="12" viewBox="0 0 13 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect x="0.875" y="4.875" width="11.25" height="2.25" rx="1.125" fill="#777777"/>
|
|
3
|
+
<rect x="7.625" y="0.375" width="11.25" height="2.25" rx="1.125" transform="rotate(90 7.625 0.375)" fill="#777777"/>
|
|
4
|
+
</svg>
|
|
@@ -13,12 +13,18 @@ const ChatConversation = ({ onBackClick, isActive }) => {
|
|
|
13
13
|
const messagesEndRef = useRef(null);
|
|
14
14
|
const defaultNoticeContent = '본 채팅을 통해 제공되는 서비스는 일반적인 법률정보 제공 및 고객 편의 도모를 위한 것 입니다. 본 채팅을 통해 제공된 정보를 이용한 행위에 대해서는 당사는 어떠한 법적 책임을 지지 않으며 구체적인 사안에 대한 적용은 변호사와의 추가 상담을 통해 자문을 받으시기를 권해드립니다.';
|
|
15
15
|
const noticeContent = defaultNoticeContent;
|
|
16
|
-
//
|
|
17
|
-
|
|
16
|
+
// const sortedMessages = useMemo(() => {
|
|
17
|
+
// return [...messages].sort((a, b) => a.timestamp - b.timestamp); // timestamp 오름차순 (최신이 마지막에)
|
|
18
|
+
// }, [messages]);
|
|
19
|
+
// console.log('messages', messages);
|
|
20
|
+
const scrollEnd = () => {
|
|
18
21
|
var _a;
|
|
19
22
|
(_a = messagesEndRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: 'smooth' });
|
|
23
|
+
};
|
|
24
|
+
// 새 메시지가 도착할 때 자동으로 스크롤 최하단으로 이동
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
scrollEnd();
|
|
20
27
|
}, [messages, messageObject]);
|
|
21
|
-
console.log('messages', messages);
|
|
22
28
|
const isNewDay = (date1, date2) => {
|
|
23
29
|
return (date1.getFullYear() !== date2.getFullYear() ||
|
|
24
30
|
date1.getMonth() !== date2.getMonth() ||
|
|
@@ -26,7 +32,9 @@ const ChatConversation = ({ onBackClick, isActive }) => {
|
|
|
26
32
|
};
|
|
27
33
|
const renderMessagesWithDateSeparators = () => {
|
|
28
34
|
const elements = [];
|
|
29
|
-
messages
|
|
35
|
+
messages
|
|
36
|
+
.sort((a, b) => a.timestamp - b.timestamp)
|
|
37
|
+
.forEach((message, index) => {
|
|
30
38
|
// 오브젝트 워크플로우 있는경우는 넣어주기
|
|
31
39
|
const findObject = message.workFlow &&
|
|
32
40
|
(messageObject === null || messageObject === void 0 ? void 0 : messageObject.exposeObjectListYn) &&
|
|
@@ -36,7 +44,7 @@ const ChatConversation = ({ onBackClick, isActive }) => {
|
|
|
36
44
|
if (index === 0 || isNewDay(message.createdAt, messages[index - 1].createdAt)) {
|
|
37
45
|
elements.push(<DateSeparator key={`date-${message.messageNumber}`} date={message.createdAt}/>);
|
|
38
46
|
}
|
|
39
|
-
elements.push(<ChatMessage key={message.messageNumber} message={message} object={findObject} handelObjectBack={workFlowBack} chatInquiryNumber={chatInquiryNumber || ''} workFlowStack={workFlowStack} isHovered={isHovered}/>);
|
|
47
|
+
elements.push(<ChatMessage key={message.messageNumber} message={message} object={findObject} handelObjectBack={workFlowBack} chatInquiryNumber={chatInquiryNumber || ''} workFlowStack={workFlowStack} isHovered={isHovered} scrollEnd={scrollEnd}/>);
|
|
40
48
|
});
|
|
41
49
|
return elements;
|
|
42
50
|
};
|
|
@@ -59,17 +67,17 @@ const ChatConversation = ({ onBackClick, isActive }) => {
|
|
|
59
67
|
<div className="w-7"></div>
|
|
60
68
|
</div>
|
|
61
69
|
<NoticeMessage content={noticeContent}/>
|
|
62
|
-
<div className="flex-1 overflow-y-auto p-4">
|
|
70
|
+
<div className="flex-1 overflow-y-auto p-4 pb-[100px]">
|
|
63
71
|
{messages.length === 0 ? (<div className="flex h-full flex-col items-center justify-center text-center text-gray-500">
|
|
64
72
|
<p>문의하실 내용을 입력해 주세요.</p>
|
|
65
73
|
<p className="mt-2 text-sm">24시간 운영하고 있습니다.</p>
|
|
66
74
|
</div>) : (<div className={``} onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}>
|
|
67
75
|
{renderMessagesWithDateSeparators()}
|
|
68
|
-
{isLoading && (<div className="flex justify-start">
|
|
69
|
-
<div className="flex h-8 animate-pulse space-x-2 rounded-full
|
|
70
|
-
<div className="h-
|
|
71
|
-
<div className="h-
|
|
72
|
-
<div className="h-
|
|
76
|
+
{isLoading && (<div className="flex justify-start pl-8">
|
|
77
|
+
<div className="flex h-8 animate-pulse space-x-2 rounded-full ">
|
|
78
|
+
<div className="h-[8px] w-[8px] animate-bounce rounded-full bg-[#777777] "></div>
|
|
79
|
+
<div className="h-[8px] w-[8px] animate-bounce rounded-full bg-[#C2C2C2]" style={{ animationDelay: '0.2s' }}></div>
|
|
80
|
+
<div className="h-[8px] w-[8px] animate-bounce rounded-full bg-[#C2C2C2]" style={{ animationDelay: '0.4s' }}></div>
|
|
73
81
|
</div>
|
|
74
82
|
</div>)}
|
|
75
83
|
<div ref={messagesEndRef}/>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
3
3
|
import ChatMessage from './ChatMessage';
|
|
4
4
|
import ChatInput from './ChatInput';
|
|
@@ -33,14 +33,20 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, isActi
|
|
|
33
33
|
'본 채팅을 통해 제공되는 서비스는 일반적인 법률정보 제공 및 고객 편의 도모를 위한 것 입니다. 본 채팅을 통해 제공된 정보를 이용한 행위에 대해서는 당사는 어떠한 법적 책임을 지지 않으며 구체적인 사안에 대한 적용은 변호사와의 추가 상담을 통해 자문을 받으시기를 권해드립니다.';
|
|
34
34
|
|
|
35
35
|
const noticeContent = defaultNoticeContent;
|
|
36
|
+
// const sortedMessages = useMemo(() => {
|
|
37
|
+
// return [...messages].sort((a, b) => a.timestamp - b.timestamp); // timestamp 오름차순 (최신이 마지막에)
|
|
38
|
+
// }, [messages]);
|
|
39
|
+
// console.log('messages', messages);
|
|
40
|
+
|
|
41
|
+
const scrollEnd = () => {
|
|
42
|
+
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
43
|
+
};
|
|
36
44
|
|
|
37
45
|
// 새 메시지가 도착할 때 자동으로 스크롤 최하단으로 이동
|
|
38
46
|
useEffect(() => {
|
|
39
|
-
|
|
47
|
+
scrollEnd();
|
|
40
48
|
}, [messages, messageObject]);
|
|
41
49
|
|
|
42
|
-
console.log('messages', messages);
|
|
43
|
-
|
|
44
50
|
const isNewDay = (date1: Date, date2: Date): boolean => {
|
|
45
51
|
return (
|
|
46
52
|
date1.getFullYear() !== date2.getFullYear() ||
|
|
@@ -52,30 +58,33 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, isActi
|
|
|
52
58
|
const renderMessagesWithDateSeparators = () => {
|
|
53
59
|
const elements: React.ReactNode[] = [];
|
|
54
60
|
|
|
55
|
-
messages
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
61
|
+
messages
|
|
62
|
+
.sort((a, b) => a.timestamp - b.timestamp)
|
|
63
|
+
.forEach((message, index) => {
|
|
64
|
+
// 오브젝트 워크플로우 있는경우는 넣어주기
|
|
65
|
+
const findObject =
|
|
66
|
+
message.workFlow &&
|
|
67
|
+
messageObject?.exposeObjectListYn &&
|
|
68
|
+
messageObject?.messageNumber === message.messageNumber
|
|
69
|
+
? messageObject
|
|
70
|
+
: null;
|
|
71
|
+
|
|
72
|
+
if (index === 0 || isNewDay(message.createdAt, messages[index - 1].createdAt)) {
|
|
73
|
+
elements.push(<DateSeparator key={`date-${message.messageNumber}`} date={message.createdAt} />);
|
|
74
|
+
}
|
|
75
|
+
elements.push(
|
|
76
|
+
<ChatMessage
|
|
77
|
+
key={message.messageNumber}
|
|
78
|
+
message={message}
|
|
79
|
+
object={findObject}
|
|
80
|
+
handelObjectBack={workFlowBack}
|
|
81
|
+
chatInquiryNumber={chatInquiryNumber || ''}
|
|
82
|
+
workFlowStack={workFlowStack}
|
|
83
|
+
isHovered={isHovered}
|
|
84
|
+
scrollEnd={scrollEnd}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
});
|
|
79
88
|
|
|
80
89
|
return elements;
|
|
81
90
|
};
|
|
@@ -110,7 +119,7 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, isActi
|
|
|
110
119
|
<div className="w-7"></div>
|
|
111
120
|
</div>
|
|
112
121
|
<NoticeMessage content={noticeContent} />
|
|
113
|
-
<div className="flex-1 overflow-y-auto p-4">
|
|
122
|
+
<div className="flex-1 overflow-y-auto p-4 pb-[100px]">
|
|
114
123
|
{messages.length === 0 ? (
|
|
115
124
|
<div className="flex h-full flex-col items-center justify-center text-center text-gray-500">
|
|
116
125
|
<p>문의하실 내용을 입력해 주세요.</p>
|
|
@@ -124,15 +133,15 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, isActi
|
|
|
124
133
|
>
|
|
125
134
|
{renderMessagesWithDateSeparators()}
|
|
126
135
|
{isLoading && (
|
|
127
|
-
<div className="flex justify-start">
|
|
128
|
-
<div className="flex h-8 animate-pulse space-x-2 rounded-full
|
|
129
|
-
<div className="h-
|
|
136
|
+
<div className="flex justify-start pl-8">
|
|
137
|
+
<div className="flex h-8 animate-pulse space-x-2 rounded-full ">
|
|
138
|
+
<div className="h-[8px] w-[8px] animate-bounce rounded-full bg-[#777777] "></div>
|
|
130
139
|
<div
|
|
131
|
-
className="h-
|
|
140
|
+
className="h-[8px] w-[8px] animate-bounce rounded-full bg-[#C2C2C2]"
|
|
132
141
|
style={{ animationDelay: '0.2s' }}
|
|
133
142
|
></div>
|
|
134
143
|
<div
|
|
135
|
-
className="h-
|
|
144
|
+
className="h-[8px] w-[8px] animate-bounce rounded-full bg-[#C2C2C2]"
|
|
136
145
|
style={{ animationDelay: '0.4s' }}
|
|
137
146
|
></div>
|
|
138
147
|
</div>
|
|
@@ -29,6 +29,8 @@ const ChatInput = () => {
|
|
|
29
29
|
};
|
|
30
30
|
return (<form onSubmit={handleSubmit} className="flex w-full items-center gap-2">
|
|
31
31
|
<div className="flex-1">
|
|
32
|
+
{/* 최초 높이 44 */}
|
|
33
|
+
{/*내용이 2줄 이상되면 입력창 높이도 키워져야합니다. 최대한 4줄까지만 보이도록 해주시고, 그 이상은 스크롤 될 수 있도록 해주시는 게 좋을 것 같습니다. max height 값을 72로 지정 부탁드립니다*/}
|
|
32
34
|
<Tiptap ref={tiptapRef}
|
|
33
35
|
// value={message}
|
|
34
36
|
onChange={setMessage} onEnterKeyPress={handleEnter} placeholder="메시지를 입력하세요..."/>
|
|
@@ -32,6 +32,8 @@ const ChatInput: React.FC = () => {
|
|
|
32
32
|
return (
|
|
33
33
|
<form onSubmit={handleSubmit} className="flex w-full items-center gap-2">
|
|
34
34
|
<div className="flex-1">
|
|
35
|
+
{/* 최초 높이 44 */}
|
|
36
|
+
{/*내용이 2줄 이상되면 입력창 높이도 키워져야합니다. 최대한 4줄까지만 보이도록 해주시고, 그 이상은 스크롤 될 수 있도록 해주시는 게 좋을 것 같습니다. max height 값을 72로 지정 부탁드립니다*/}
|
|
35
37
|
<Tiptap
|
|
36
38
|
ref={tiptapRef}
|
|
37
39
|
// value={message}
|
|
@@ -20,8 +20,8 @@ import WorkFlowAuthForm from './ChatItem/WorkFlowAuthForm';
|
|
|
20
20
|
import ChatWrapper from './ChatItem/ChatWrapper';
|
|
21
21
|
import RichText from './ChatItem/RichText';
|
|
22
22
|
import ChatFile from './ChatItem/ChatFile';
|
|
23
|
-
import
|
|
24
|
-
const ChatMessage = ({ message, object, handelObjectBack, chatInquiryNumber, workFlowStack, isHovered }) => {
|
|
23
|
+
import FieldWorkObject from './ChatObject/FieldWorkObject';
|
|
24
|
+
const ChatMessage = ({ message, object, handelObjectBack, chatInquiryNumber, workFlowStack, isHovered, scrollEnd }) => {
|
|
25
25
|
// 고객 , 오퍼레이터 분리
|
|
26
26
|
const isOperator = message.senderType !== MessageSenderType.CUSTOMER;
|
|
27
27
|
const formatTime = (date) => {
|
|
@@ -30,7 +30,6 @@ const ChatMessage = ({ message, object, handelObjectBack, chatInquiryNumber, wor
|
|
|
30
30
|
return `${hours}:${minutes}`;
|
|
31
31
|
};
|
|
32
32
|
const time = formatTime(message.createdAt);
|
|
33
|
-
getMessageFileDownloadUrl;
|
|
34
33
|
// 텍스트 블록 렌더링
|
|
35
34
|
const renderText = (message) => {
|
|
36
35
|
/**
|
|
@@ -82,11 +81,25 @@ const ChatMessage = ({ message, object, handelObjectBack, chatInquiryNumber, wor
|
|
|
82
81
|
};
|
|
83
82
|
/** todo 메시지 내용 렌더링 추후 추가 될듯 */
|
|
84
83
|
const renderMessageContent = () => {
|
|
85
|
-
var _a;
|
|
84
|
+
var _a, _b, _c;
|
|
86
85
|
const objectFirstQuestionCheck = Array.isArray(object === null || object === void 0 ? void 0 : object.objectList)
|
|
87
86
|
? Object.values(ObjectNumber).every(enumValue => { var _a; return (_a = object === null || object === void 0 ? void 0 : object.objectList) === null || _a === void 0 ? void 0 : _a.some(obj => (obj === null || obj === void 0 ? void 0 : obj.objectNumber) === enumValue); })
|
|
88
87
|
: false;
|
|
89
88
|
const objectIsBack = workFlowStack.length >= 3;
|
|
89
|
+
// // PK없어서 이렇게
|
|
90
|
+
// const fieldKeywords = [
|
|
91
|
+
// '기업법무',
|
|
92
|
+
// '지식재산권',
|
|
93
|
+
// '공정거래',
|
|
94
|
+
// '건설',
|
|
95
|
+
// '이혼',
|
|
96
|
+
// '상속',
|
|
97
|
+
// '조세',
|
|
98
|
+
// '형사',
|
|
99
|
+
// '노동',
|
|
100
|
+
// '금융'
|
|
101
|
+
// ];
|
|
102
|
+
const isAllFieldOfWork = !!(object === null || object === void 0 ? void 0 : object.objectList) && ((_a = object === null || object === void 0 ? void 0 : object.objectList) === null || _a === void 0 ? void 0 : _a.length) > 20;
|
|
90
103
|
return (<div className={`
|
|
91
104
|
message-content
|
|
92
105
|
`}>
|
|
@@ -100,10 +113,14 @@ const ChatMessage = ({ message, object, handelObjectBack, chatInquiryNumber, wor
|
|
|
100
113
|
: 'flex flex-col gap-[8px]'}
|
|
101
114
|
|
|
102
115
|
`}>
|
|
103
|
-
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
116
|
+
{/* 업무분야 리스트면 따로 빼자 */}
|
|
117
|
+
{!isAllFieldOfWork
|
|
118
|
+
? (_c = (_b = object.objectList) === null || _b === void 0 ? void 0 : _b.sort((a, b) => a.sequence - b.sequence)) === null || _c === void 0 ? void 0 : _c.map((item, index) => {
|
|
119
|
+
var _a;
|
|
120
|
+
return (<ObjectButton key={`object-expose-${index}`} object={item} messageNumber={(object === null || object === void 0 ? void 0 : object.messageNumber) || ''} workFlowNumber={((_a = message === null || message === void 0 ? void 0 : message.workFlow) === null || _a === void 0 ? void 0 : _a.workFlowNumber) || ''} isFirstObject={objectFirstQuestionCheck} objectGroupUiCode={(object === null || object === void 0 ? void 0 : object.objectGroupUiCode) || ''}/>);
|
|
121
|
+
})
|
|
122
|
+
: null}
|
|
123
|
+
{isAllFieldOfWork && (<FieldWorkObject object={object} message={message} isFirstObject={objectFirstQuestionCheck} scrollEnd={scrollEnd}/>)}
|
|
107
124
|
</div>
|
|
108
125
|
{!objectFirstQuestionCheck && (<ObjectBack isBack={objectIsBack} handleBtn={() => __awaiter(void 0, void 0, void 0, function* () {
|
|
109
126
|
if (handelObjectBack) {
|
|
@@ -26,6 +26,7 @@ import ChatWrapper from './ChatItem/ChatWrapper';
|
|
|
26
26
|
import RichText from './ChatItem/RichText';
|
|
27
27
|
import ChatFile from './ChatItem/ChatFile';
|
|
28
28
|
import { getMessageFileDownloadUrl } from './_api';
|
|
29
|
+
import FieldWorkObject from './ChatObject/FieldWorkObject';
|
|
29
30
|
|
|
30
31
|
type ChatMessageProps = {
|
|
31
32
|
message: Message;
|
|
@@ -38,6 +39,7 @@ type ChatMessageProps = {
|
|
|
38
39
|
chatInquiryNumber: string;
|
|
39
40
|
workFlowStack: string[];
|
|
40
41
|
isHovered: boolean;
|
|
42
|
+
scrollEnd: () => void;
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
const ChatMessage: React.FC<ChatMessageProps> = ({
|
|
@@ -46,7 +48,8 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
|
|
|
46
48
|
handelObjectBack,
|
|
47
49
|
chatInquiryNumber,
|
|
48
50
|
workFlowStack,
|
|
49
|
-
isHovered
|
|
51
|
+
isHovered,
|
|
52
|
+
scrollEnd
|
|
50
53
|
}) => {
|
|
51
54
|
// 고객 , 오퍼레이터 분리
|
|
52
55
|
const isOperator = message.senderType !== MessageSenderType.CUSTOMER;
|
|
@@ -59,8 +62,6 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
|
|
|
59
62
|
|
|
60
63
|
const time = formatTime(message.createdAt);
|
|
61
64
|
|
|
62
|
-
getMessageFileDownloadUrl;
|
|
63
|
-
|
|
64
65
|
// 텍스트 블록 렌더링
|
|
65
66
|
const renderText = (message: Message) => {
|
|
66
67
|
/**
|
|
@@ -134,6 +135,22 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
|
|
|
134
135
|
|
|
135
136
|
const objectIsBack = workFlowStack.length >= 3;
|
|
136
137
|
|
|
138
|
+
// // PK없어서 이렇게
|
|
139
|
+
// const fieldKeywords = [
|
|
140
|
+
// '기업법무',
|
|
141
|
+
// '지식재산권',
|
|
142
|
+
// '공정거래',
|
|
143
|
+
// '건설',
|
|
144
|
+
// '이혼',
|
|
145
|
+
// '상속',
|
|
146
|
+
// '조세',
|
|
147
|
+
// '형사',
|
|
148
|
+
// '노동',
|
|
149
|
+
// '금융'
|
|
150
|
+
// ];
|
|
151
|
+
|
|
152
|
+
const isAllFieldOfWork = !!object?.objectList && object?.objectList?.length > 20;
|
|
153
|
+
|
|
137
154
|
return (
|
|
138
155
|
<div
|
|
139
156
|
className={`
|
|
@@ -155,18 +172,31 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
|
|
|
155
172
|
|
|
156
173
|
`}
|
|
157
174
|
>
|
|
158
|
-
{
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
175
|
+
{/* 업무분야 리스트면 따로 빼자 */}
|
|
176
|
+
{!isAllFieldOfWork
|
|
177
|
+
? object.objectList
|
|
178
|
+
?.sort((a, b) => a.sequence - b.sequence)
|
|
179
|
+
?.map((item, index) => {
|
|
180
|
+
return (
|
|
181
|
+
<ObjectButton
|
|
182
|
+
key={`object-expose-${index}`}
|
|
183
|
+
object={item}
|
|
184
|
+
messageNumber={object?.messageNumber || ''}
|
|
185
|
+
workFlowNumber={message?.workFlow?.workFlowNumber || ''}
|
|
186
|
+
isFirstObject={objectFirstQuestionCheck}
|
|
187
|
+
objectGroupUiCode={object?.objectGroupUiCode || ''}
|
|
188
|
+
/>
|
|
189
|
+
);
|
|
190
|
+
})
|
|
191
|
+
: null}
|
|
192
|
+
{isAllFieldOfWork && (
|
|
193
|
+
<FieldWorkObject
|
|
194
|
+
object={object}
|
|
195
|
+
message={message}
|
|
196
|
+
isFirstObject={objectFirstQuestionCheck}
|
|
197
|
+
scrollEnd={scrollEnd}
|
|
198
|
+
/>
|
|
199
|
+
)}
|
|
170
200
|
</div>
|
|
171
201
|
{!objectFirstQuestionCheck && (
|
|
172
202
|
<ObjectBack
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MessageObject } from '../_types/message_object';
|
|
2
|
+
import { Message } from '../_types/message';
|
|
3
|
+
declare const FieldWorkObject: ({ object, message, isFirstObject, scrollEnd }: {
|
|
4
|
+
object: MessageObject;
|
|
5
|
+
message: Message;
|
|
6
|
+
isFirstObject: boolean;
|
|
7
|
+
scrollEnd: () => void;
|
|
8
|
+
}) => import("react").JSX.Element;
|
|
9
|
+
export default FieldWorkObject;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import ObjectButton from './ObjectButton';
|
|
3
|
+
import PlusIcon from '../../../asset/images/daeryuntalk/plus.svg';
|
|
4
|
+
import MinusIcon from '../../../asset/images/daeryuntalk/minus.svg';
|
|
5
|
+
const FieldWorkObject = ({ object, message, isFirstObject, scrollEnd }) => {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
8
|
+
const objectList = (_b = (_a = object === null || object === void 0 ? void 0 : object.objectList) === null || _a === void 0 ? void 0 : _a.sort((a, b) => a.sequence - b.sequence)) !== null && _b !== void 0 ? _b : [];
|
|
9
|
+
const MAX_VISIBLE = 10;
|
|
10
|
+
const hasMoreThanMax = objectList.length > MAX_VISIBLE;
|
|
11
|
+
const visibleList = isExpanded ? objectList : objectList.slice(0, MAX_VISIBLE);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (isExpanded) {
|
|
14
|
+
scrollEnd();
|
|
15
|
+
}
|
|
16
|
+
}, [isExpanded]);
|
|
17
|
+
return (<>
|
|
18
|
+
{visibleList.map((item, index) => {
|
|
19
|
+
var _a;
|
|
20
|
+
return (<ObjectButton key={`object-expose-${index}`} object={item} messageNumber={(object === null || object === void 0 ? void 0 : object.messageNumber) || ''} workFlowNumber={((_a = message === null || message === void 0 ? void 0 : message.workFlow) === null || _a === void 0 ? void 0 : _a.workFlowNumber) || ''} isFirstObject={isFirstObject} objectGroupUiCode={(object === null || object === void 0 ? void 0 : object.objectGroupUiCode) || ''}/>);
|
|
21
|
+
})}
|
|
22
|
+
|
|
23
|
+
{hasMoreThanMax && (<button type="button" onClick={() => {
|
|
24
|
+
setIsExpanded(prev => !prev);
|
|
25
|
+
}} className={`flex h-[36px] w-full items-center justify-center gap-[4px] rounded-[250px] bg-[#F7F7F7] py-[9px]`}>
|
|
26
|
+
{isExpanded ? <MinusIcon /> : <PlusIcon />}
|
|
27
|
+
<span className={`text-[14px] font-[700] leading-[100%] tracking-[-4%] text-[#777777] `}>
|
|
28
|
+
{isExpanded ? '접기' : '더보기'}
|
|
29
|
+
</span>
|
|
30
|
+
</button>)}
|
|
31
|
+
</>);
|
|
32
|
+
};
|
|
33
|
+
export default FieldWorkObject;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import ObjectButton from './ObjectButton';
|
|
3
|
+
import { MessageObject, MessageObjectExpose } from '../_types/message_object';
|
|
4
|
+
import { Message } from '../_types/message'; // 실제 경로에 맞게 수정하세요
|
|
5
|
+
import PlusIcon from '../../../asset/images/daeryuntalk/plus.svg';
|
|
6
|
+
import MinusIcon from '../../../asset/images/daeryuntalk/minus.svg';
|
|
7
|
+
|
|
8
|
+
const FieldWorkObject = ({
|
|
9
|
+
object,
|
|
10
|
+
message,
|
|
11
|
+
isFirstObject,
|
|
12
|
+
scrollEnd
|
|
13
|
+
}: {
|
|
14
|
+
object: MessageObject;
|
|
15
|
+
message: Message;
|
|
16
|
+
isFirstObject: boolean;
|
|
17
|
+
scrollEnd: () => void;
|
|
18
|
+
}) => {
|
|
19
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
20
|
+
|
|
21
|
+
const objectList: MessageObjectExpose[] = object?.objectList?.sort((a, b) => a.sequence - b.sequence) ?? [];
|
|
22
|
+
|
|
23
|
+
const MAX_VISIBLE = 10;
|
|
24
|
+
const hasMoreThanMax = objectList.length > MAX_VISIBLE;
|
|
25
|
+
|
|
26
|
+
const visibleList = isExpanded ? objectList : objectList.slice(0, MAX_VISIBLE);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (isExpanded) {
|
|
30
|
+
scrollEnd();
|
|
31
|
+
}
|
|
32
|
+
}, [isExpanded]);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<>
|
|
36
|
+
{visibleList.map((item, index) => (
|
|
37
|
+
<ObjectButton
|
|
38
|
+
key={`object-expose-${index}`}
|
|
39
|
+
object={item}
|
|
40
|
+
messageNumber={object?.messageNumber || ''}
|
|
41
|
+
workFlowNumber={message?.workFlow?.workFlowNumber || ''}
|
|
42
|
+
isFirstObject={isFirstObject}
|
|
43
|
+
objectGroupUiCode={object?.objectGroupUiCode || ''}
|
|
44
|
+
/>
|
|
45
|
+
))}
|
|
46
|
+
|
|
47
|
+
{hasMoreThanMax && (
|
|
48
|
+
<button
|
|
49
|
+
type="button"
|
|
50
|
+
onClick={() => {
|
|
51
|
+
setIsExpanded(prev => !prev);
|
|
52
|
+
}}
|
|
53
|
+
className={`flex h-[36px] w-full items-center justify-center gap-[4px] rounded-[250px] bg-[#F7F7F7] py-[9px]`}
|
|
54
|
+
>
|
|
55
|
+
{isExpanded ? <MinusIcon /> : <PlusIcon />}
|
|
56
|
+
<span className={`text-[14px] font-[700] leading-[100%] tracking-[-4%] text-[#777777] `}>
|
|
57
|
+
{isExpanded ? '접기' : '더보기'}
|
|
58
|
+
</span>
|
|
59
|
+
</button>
|
|
60
|
+
)}
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default FieldWorkObject;
|
|
@@ -11,12 +11,17 @@ import React from 'react';
|
|
|
11
11
|
import Image from 'next/image';
|
|
12
12
|
import { ObjectNumber, WorkFlowButtonActionType, WorkFlowButtonUiCode } from '../_enums/work_flow_object_expose';
|
|
13
13
|
import { useDaeryuntalk } from '../DaeryuntalkContext';
|
|
14
|
+
import { useWorkFlow } from '../_hooks/talkprovider/useWorkFlow';
|
|
14
15
|
// 길이 fit 형
|
|
15
16
|
// 길이 full 형
|
|
16
17
|
// 업무 그룹형
|
|
18
|
+
// link_url
|
|
17
19
|
const ObjectButton = ({ object, messageNumber, workFlowNumber, isFirstObject = false, objectGroupUiCode }) => {
|
|
18
|
-
const { startWorkFlow, chatInquiryNumber, workFlowStack, workFlowBack } = useDaeryuntalk();
|
|
19
|
-
|
|
20
|
+
const { startWorkFlow, chatInquiryNumber, workFlowStack, workFlowBack, tel } = useDaeryuntalk();
|
|
21
|
+
const { onClickKakao, onClickTel } = useWorkFlow({ tel: tel });
|
|
22
|
+
const openExternalLink = (url) => {
|
|
23
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
24
|
+
};
|
|
20
25
|
const fitClassName = `
|
|
21
26
|
flex w-fit flex-row items-center gap-[6px] rounded-[4px] border-[1px]
|
|
22
27
|
border-solid border-[#EDEDED] bg-[#F7F7F780] px-[10px] py-[12.5px]
|
|
@@ -33,13 +38,13 @@ const ObjectButton = ({ object, messageNumber, workFlowNumber, isFirstObject = f
|
|
|
33
38
|
text-[14px] font-[400] leading-[110%] tracking-[-4%]
|
|
34
39
|
`;
|
|
35
40
|
const handleButton = (object) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
console.log('object', object);
|
|
37
41
|
const actionType = (object === null || object === void 0 ? void 0 : object.actionCode) || '';
|
|
38
42
|
// 내부링크
|
|
39
43
|
if (actionType === WorkFlowButtonActionType.INTERNAL_LINK) {
|
|
40
44
|
}
|
|
41
45
|
// 외부링크
|
|
42
46
|
else if (actionType === WorkFlowButtonActionType.EXTERNAL_LINK) {
|
|
47
|
+
openExternalLink(object.linkUrl);
|
|
43
48
|
}
|
|
44
49
|
// 입력
|
|
45
50
|
else if (actionType === WorkFlowButtonActionType.INPUT) {
|
|
@@ -55,9 +60,11 @@ const ObjectButton = ({ object, messageNumber, workFlowNumber, isFirstObject = f
|
|
|
55
60
|
}
|
|
56
61
|
// 전화연결
|
|
57
62
|
else if (actionType === WorkFlowButtonActionType.PHONE_CALL) {
|
|
63
|
+
onClickTel();
|
|
58
64
|
}
|
|
59
65
|
// 카카오연동
|
|
60
66
|
else if (actionType === WorkFlowButtonActionType.KAKAO_CONNECT) {
|
|
67
|
+
onClickKakao();
|
|
61
68
|
}
|
|
62
69
|
});
|
|
63
70
|
const renderButton = (className) => {
|
|
@@ -8,11 +8,14 @@ import {
|
|
|
8
8
|
} from '../_enums/work_flow_object_expose';
|
|
9
9
|
import { MessageObjectExpose } from '../_types/message_object';
|
|
10
10
|
import { useDaeryuntalk } from '../DaeryuntalkContext';
|
|
11
|
+
import { useRouter } from 'next/router';
|
|
12
|
+
import { useWorkFlow } from '../_hooks/talkprovider/useWorkFlow';
|
|
11
13
|
|
|
12
14
|
// 길이 fit 형
|
|
13
15
|
// 길이 full 형
|
|
14
16
|
// 업무 그룹형
|
|
15
17
|
|
|
18
|
+
// link_url
|
|
16
19
|
const ObjectButton = ({
|
|
17
20
|
object,
|
|
18
21
|
messageNumber,
|
|
@@ -26,10 +29,12 @@ const ObjectButton = ({
|
|
|
26
29
|
isFirstObject: boolean;
|
|
27
30
|
objectGroupUiCode: string;
|
|
28
31
|
}) => {
|
|
29
|
-
const { startWorkFlow, chatInquiryNumber, workFlowStack, workFlowBack } = useDaeryuntalk();
|
|
30
|
-
|
|
31
|
-
// fit 용
|
|
32
|
+
const { startWorkFlow, chatInquiryNumber, workFlowStack, workFlowBack, tel } = useDaeryuntalk();
|
|
33
|
+
const { onClickKakao, onClickTel } = useWorkFlow({ tel: tel });
|
|
32
34
|
|
|
35
|
+
const openExternalLink = (url: string) => {
|
|
36
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
37
|
+
};
|
|
33
38
|
const fitClassName = `
|
|
34
39
|
flex w-fit flex-row items-center gap-[6px] rounded-[4px] border-[1px]
|
|
35
40
|
border-solid border-[#EDEDED] bg-[#F7F7F780] px-[10px] py-[12.5px]
|
|
@@ -49,13 +54,14 @@ const ObjectButton = ({
|
|
|
49
54
|
`;
|
|
50
55
|
|
|
51
56
|
const handleButton = async (object: MessageObjectExpose) => {
|
|
52
|
-
console.log('object', object);
|
|
53
57
|
const actionType = object?.actionCode || '';
|
|
58
|
+
|
|
54
59
|
// 내부링크
|
|
55
60
|
if (actionType === WorkFlowButtonActionType.INTERNAL_LINK) {
|
|
56
61
|
}
|
|
57
62
|
// 외부링크
|
|
58
63
|
else if (actionType === WorkFlowButtonActionType.EXTERNAL_LINK) {
|
|
64
|
+
openExternalLink(object.linkUrl);
|
|
59
65
|
}
|
|
60
66
|
// 입력
|
|
61
67
|
else if (actionType === WorkFlowButtonActionType.INPUT) {
|
|
@@ -71,9 +77,11 @@ const ObjectButton = ({
|
|
|
71
77
|
}
|
|
72
78
|
// 전화연결
|
|
73
79
|
else if (actionType === WorkFlowButtonActionType.PHONE_CALL) {
|
|
80
|
+
onClickTel();
|
|
74
81
|
}
|
|
75
82
|
// 카카오연동
|
|
76
83
|
else if (actionType === WorkFlowButtonActionType.KAKAO_CONNECT) {
|
|
84
|
+
onClickKakao();
|
|
77
85
|
}
|
|
78
86
|
};
|
|
79
87
|
|
|
@@ -49,10 +49,12 @@ type DaeryuntalkContextType = {
|
|
|
49
49
|
imageViewerMessage?: Message | null;
|
|
50
50
|
openImageViewer?: (file: FileInfo, message: Message) => void;
|
|
51
51
|
closeImageViewer?: () => void;
|
|
52
|
+
tel: string;
|
|
52
53
|
};
|
|
53
54
|
declare const DaeryuntalkContext: React.Context<DaeryuntalkContextType>;
|
|
54
55
|
type DaeryuntalkProviderProps = {
|
|
55
56
|
children: ReactNode;
|
|
57
|
+
propsTel: string;
|
|
56
58
|
};
|
|
57
59
|
export declare const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps>;
|
|
58
60
|
export declare const useDaeryuntalk: () => DaeryuntalkContextType;
|