@daeryun/dr_components 0.8.80 → 0.8.82

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.
Files changed (60) hide show
  1. package/dist/components/Daeryuntalk/ChatConversation.jsx +3 -3
  2. package/dist/components/Daeryuntalk/ChatConversation.tsx +3 -2
  3. package/dist/components/Daeryuntalk/ChatHomeView.jsx +15 -5
  4. package/dist/components/Daeryuntalk/ChatHomeView.tsx +24 -11
  5. package/dist/components/Daeryuntalk/ChatInput.jsx +15 -4
  6. package/dist/components/Daeryuntalk/ChatInput.tsx +17 -5
  7. package/dist/components/Daeryuntalk/ChatItem/ChatFile.jsx +1 -1
  8. package/dist/components/Daeryuntalk/ChatItem/ChatFile.tsx +1 -1
  9. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.d.ts +3 -1
  10. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.jsx +164 -3
  11. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.tsx +197 -4
  12. package/dist/components/Daeryuntalk/ChatMessage.d.ts +1 -0
  13. package/dist/components/Daeryuntalk/ChatMessage.jsx +3 -3
  14. package/dist/components/Daeryuntalk/ChatMessage.tsx +5 -3
  15. package/dist/components/Daeryuntalk/ChatObject/ObjectButton.jsx +4 -2
  16. package/dist/components/Daeryuntalk/ChatObject/ObjectButton.tsx +6 -4
  17. package/dist/components/Daeryuntalk/ChatWidget.d.ts +1 -0
  18. package/dist/components/Daeryuntalk/ChatWidget.jsx +1 -1
  19. package/dist/components/Daeryuntalk/ChatWidget.tsx +10 -2
  20. package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +1 -0
  21. package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +5 -3
  22. package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +7 -3
  23. package/dist/components/Daeryuntalk/HomeView.jsx +4 -9
  24. package/dist/components/Daeryuntalk/HomeView.tsx +9 -9
  25. package/dist/components/Daeryuntalk/NavigationFooter.jsx +1 -1
  26. package/dist/components/Daeryuntalk/NavigationFooter.tsx +1 -1
  27. package/dist/components/Daeryuntalk/Tiptap/Tiptap.d.ts +2 -1
  28. package/dist/components/Daeryuntalk/Tiptap/Tiptap.jsx +38 -5
  29. package/dist/components/Daeryuntalk/Tiptap/Tiptap.tsx +48 -9
  30. package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.d.ts +2 -1
  31. package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.jsx +18 -7
  32. package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.tsx +24 -8
  33. package/dist/components/Daeryuntalk/Toast/ToastRender.jsx +9 -3
  34. package/dist/components/Daeryuntalk/Toast/ToastRender.tsx +10 -6
  35. package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +6 -8
  36. package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +7 -10
  37. package/dist/components/Daeryuntalk/Viewer/MobileViewer.d.ts +2 -0
  38. package/dist/components/Daeryuntalk/Viewer/MobileViewer.jsx +52 -19
  39. package/dist/components/Daeryuntalk/Viewer/MobileViewer.tsx +89 -43
  40. package/dist/components/Daeryuntalk/Viewer/TbPcViewer.d.ts +2 -0
  41. package/dist/components/Daeryuntalk/Viewer/TbPcViewer.jsx +35 -5
  42. package/dist/components/Daeryuntalk/Viewer/TbPcViewer.tsx +57 -21
  43. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +1 -0
  44. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +14 -12
  45. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +9 -8
  46. package/dist/components/Daeryuntalk/_enums/error.js +119 -111
  47. package/dist/components/Daeryuntalk/_enums/error.ts +135 -127
  48. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +1 -0
  49. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +8 -2
  50. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +10 -2
  51. package/dist/components/Daeryuntalk/_hooks/view/useHomeView.js +1 -0
  52. package/dist/components/Daeryuntalk/_hooks/view/useHomeView.ts +1 -0
  53. package/dist/components/Daeryuntalk/_lib/utils.d.ts +2 -0
  54. package/dist/components/Daeryuntalk/_lib/utils.js +12 -0
  55. package/dist/components/Daeryuntalk/_lib/utils.ts +15 -0
  56. package/dist/components/Daeryuntalk/index.jsx +34 -5
  57. package/dist/components/Daeryuntalk/index.tsx +37 -6
  58. package/dist/styles/globals.css +30 -24
  59. package/dist/tsconfig.tsbuildinfo +1 -1
  60. package/package.json +1 -1
@@ -83,7 +83,7 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
83
83
  if (index === 0 || isNewDay(message.createdAt, messages[index - 1].createdAt)) {
84
84
  elements.push(<DateSeparator key={`date-${message.messageNumber}`} date={message.createdAt}/>);
85
85
  }
86
- elements.push(<ChatMessage inquiryStatus={inquiryStatus} key={message.messageNumber} message={message} object={findObject} handelObjectBack={workFlowBack} chatInquiryNumber={chatInquiryNumber || ''} workFlowStack={workFlowStack} isHovered={isHovered} scrollEnd={scrollEnd}/>);
86
+ elements.push(<ChatMessage isMobile={isMobile} inquiryStatus={inquiryStatus} key={message.messageNumber} message={message} object={findObject} handelObjectBack={workFlowBack} chatInquiryNumber={chatInquiryNumber || ''} workFlowStack={workFlowStack} isHovered={isHovered} scrollEnd={scrollEnd}/>);
87
87
  });
88
88
  return elements;
89
89
  };
@@ -104,7 +104,7 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
104
104
  {/* 메시지 노출 부분 -> 무한스크롤 변환 필요 */}
105
105
  {/* 여기서 isMpblie일때 위에 2개 헤더부분이랑 아래 메시지 입력이랑 높이를 빼서 넣어야한ㄷ */}
106
106
  <div className={`
107
- ${isMobile ? ' ' : 'flex- xs:pb-[100px]'} no-scrollbar mx-[20px] overflow-auto pt-[20px]
107
+ ${isMobile ? `${isLoading ? ' pb-[50px]' : ''} ` : 'flex- xs:pb-[100px]'} no-scrollbar mx-[20px] overflow-auto pt-[20px]
108
108
  `} style={{
109
109
  height: isMobile
110
110
  ? `calc(100vh - ${bottomHeight}px - ${((_a = headerRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0}px)`
@@ -125,7 +125,7 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
125
125
  </div>)}
126
126
  </div>
127
127
 
128
- <div ref={pcBottomRef} className={`w-full`}>
128
+ <div ref={pcBottomRef} className={`!z-[50] w-full`}>
129
129
  {/* 높이가 부모에 스크롤이 줄어도 해당 부분은 바텀에 고정 필요 */}
130
130
  {inquiryStatus === InquiryStatus.CLOSED ? (<div className="w-full border-t border-drTalkGrayscale4 px-[20px] py-[16px]">
131
131
  <div className="">
@@ -127,6 +127,7 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
127
127
  }
128
128
  elements.push(
129
129
  <ChatMessage
130
+ isMobile={isMobile}
130
131
  inquiryStatus={inquiryStatus}
131
132
  key={message.messageNumber}
132
133
  message={message}
@@ -172,7 +173,7 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
172
173
  {/* 여기서 isMpblie일때 위에 2개 헤더부분이랑 아래 메시지 입력이랑 높이를 빼서 넣어야한ㄷ */}
173
174
  <div
174
175
  className={`
175
- ${isMobile ? ' ' : 'flex- xs:pb-[100px]'} no-scrollbar mx-[20px] overflow-auto pt-[20px]
176
+ ${isMobile ? `${isLoading ? ' pb-[50px]' : ''} ` : 'flex- xs:pb-[100px]'} no-scrollbar mx-[20px] overflow-auto pt-[20px]
176
177
  `}
177
178
  style={{
178
179
  height: isMobile
@@ -205,7 +206,7 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
205
206
  )}
206
207
  </div>
207
208
 
208
- <div ref={pcBottomRef} className={`w-full`}>
209
+ <div ref={pcBottomRef} className={`!z-[50] w-full`}>
209
210
  {/* 높이가 부모에 스크롤이 줄어도 해당 부분은 바텀에 고정 필요 */}
210
211
  {inquiryStatus === InquiryStatus.CLOSED ? (
211
212
  <div className="w-full border-t border-drTalkGrayscale4 px-[20px] py-[16px]">
@@ -12,7 +12,7 @@ import FixedErrorBox from './FixedErrorBox';
12
12
  const ChatHomeView = ({ hashValue, onClose, isMobile, isHash }) => {
13
13
  const [viewState, setViewState] = useState(hashValue ? 'conversation' : 'home');
14
14
  const [isLoading, setIsLoading] = useState(false);
15
- const { isConnected, isAuthenticated, historyList, inquiryMainData, chatInquiryNumber, startChat } = useDaeryuntalk();
15
+ const { isConnected, isAuthenticated, historyList, inquiryMainData, chatInquiryNumber, startChat, retryInitData } = useDaeryuntalk();
16
16
  // 소켓 이벤트
17
17
  const { sendInquiryJoined, sendHeartbeat, sendInquiryWatching, sendInquiryLeft, sendHistoryEntered } = useDaeryuntalk();
18
18
  // 홈
@@ -52,6 +52,13 @@ const ChatHomeView = ({ hashValue, onClose, isMobile, isHash }) => {
52
52
  goGetHistoryList({});
53
53
  }
54
54
  }, [viewState, isAuthenticated]);
55
+ useEffect(() => {
56
+ if (inquiryMainData !== null) {
57
+ if (!(inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number)) {
58
+ retryInitData();
59
+ }
60
+ }
61
+ }, [inquiryMainData]);
55
62
  const renderWithNavigation = (content, activeView) => {
56
63
  return (
57
64
  //
@@ -62,7 +69,8 @@ const ChatHomeView = ({ hashValue, onClose, isMobile, isHash }) => {
62
69
  boxShadow: '0px 0px 20px 0px #00000040'
63
70
  }}>
64
71
  <div className={`
65
- relative overflow-hidden bg-white
72
+ relative overflow-hidden
73
+ bg-white
66
74
  ${isMobile
67
75
  ? `h-[100dvh] w-screen rounded-[0px]`
68
76
  : `
@@ -80,14 +88,16 @@ const ChatHomeView = ({ hashValue, onClose, isMobile, isHash }) => {
80
88
  `}
81
89
 
82
90
  `}>
83
- <div className="flex h-full flex-col justify-between border-[0px] border-solid xs:justify-start xs:rounded-[30px]">
91
+ <div className=" flex h-full flex-col justify-between border-[0px] border-solid xs:justify-start xs:rounded-[30px]">
84
92
  <div className={`
85
93
  no-scrollbar ${isMobile ? '' : ` overflow-hidden xs:overflow-auto ${viewState === 'conversation' ? ' ' : ' '} `}
86
94
  `}>
87
95
  {content}
88
96
  </div>
89
- {/* 얘는 아래 64px로 고정 */}
90
- <NavigationFooter activeView={activeView} onHomeClick={handleBackToHome} onHistoryClick={handleHistoryClick} historyList={historyList} isAuthenticated={isAuthenticated}/>
97
+ <div className={`!z-[50]`}>
98
+ {/* 얘는 아래 64px로 고정 */}
99
+ <NavigationFooter activeView={activeView} onHomeClick={handleBackToHome} onHistoryClick={handleHistoryClick} historyList={historyList} isAuthenticated={isAuthenticated}/>
100
+ </div>
91
101
  </div>
92
102
  </div>
93
103
  {/*얘는 abolute라서 고려 X*/}
@@ -32,8 +32,10 @@ type ChatHomeViewProps = {
32
32
  const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, onClose, isMobile, isHash }) => {
33
33
  const [viewState, setViewState] = useState<ViewState>(hashValue ? 'conversation' : 'home');
34
34
  const [isLoading, setIsLoading] = useState<boolean>(false);
35
- const { isConnected, isAuthenticated, historyList, inquiryMainData, chatInquiryNumber, startChat } =
35
+
36
+ const { isConnected, isAuthenticated, historyList, inquiryMainData, chatInquiryNumber, startChat, retryInitData } =
36
37
  useDaeryuntalk();
38
+
37
39
  // 소켓 이벤트
38
40
  const { sendInquiryJoined, sendHeartbeat, sendInquiryWatching, sendInquiryLeft, sendHistoryEntered } =
39
41
  useDaeryuntalk();
@@ -103,6 +105,14 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, onClose, isMobil
103
105
  }
104
106
  }, [viewState, isAuthenticated]);
105
107
 
108
+ useEffect(() => {
109
+ if (inquiryMainData !== null) {
110
+ if (!inquiryMainData?.channel_number) {
111
+ retryInitData();
112
+ }
113
+ }
114
+ }, [inquiryMainData]);
115
+
106
116
  const renderWithNavigation = (content: React.ReactNode, activeView: 'home' | 'history' | 'conversation') => {
107
117
  return (
108
118
  //
@@ -117,7 +127,8 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, onClose, isMobil
117
127
  >
118
128
  <div
119
129
  className={`
120
- relative overflow-hidden bg-white
130
+ relative overflow-hidden
131
+ bg-white
121
132
  ${
122
133
  isMobile
123
134
  ? `h-[100dvh] w-screen rounded-[0px]`
@@ -140,7 +151,7 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, onClose, isMobil
140
151
 
141
152
  `}
142
153
  >
143
- <div className="flex h-full flex-col justify-between border-[0px] border-solid xs:justify-start xs:rounded-[30px]">
154
+ <div className=" flex h-full flex-col justify-between border-[0px] border-solid xs:justify-start xs:rounded-[30px]">
144
155
  <div
145
156
  className={`
146
157
  no-scrollbar ${isMobile ? '' : ` overflow-hidden xs:overflow-auto ${viewState === 'conversation' ? ' ' : ' '} `}
@@ -148,14 +159,16 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, onClose, isMobil
148
159
  >
149
160
  {content}
150
161
  </div>
151
- {/* 얘는 아래 64px로 고정 */}
152
- <NavigationFooter
153
- activeView={activeView}
154
- onHomeClick={handleBackToHome}
155
- onHistoryClick={handleHistoryClick}
156
- historyList={historyList}
157
- isAuthenticated={isAuthenticated}
158
- />
162
+ <div className={`!z-[50]`}>
163
+ {/* 얘는 아래 64px로 고정 */}
164
+ <NavigationFooter
165
+ activeView={activeView}
166
+ onHomeClick={handleBackToHome}
167
+ onHistoryClick={handleHistoryClick}
168
+ historyList={historyList}
169
+ isAuthenticated={isAuthenticated}
170
+ />
171
+ </div>
159
172
  </div>
160
173
  </div>
161
174
  {/*얘는 abolute라서 고려 X*/}
@@ -1,11 +1,16 @@
1
- import React, { useRef, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import { useDaeryuntalk } from './DaeryuntalkContext';
3
3
  import SendIcon from '../../asset/images/daeryuntalk/send.svg';
4
4
  import Tiptap from './Tiptap/Tiptap';
5
+ import { stripHtmlTags } from './_lib/utils';
5
6
  const ChatInput = () => {
6
7
  const [message, setMessage] = useState('');
7
8
  const { sendMessage, isLoading } = useDaeryuntalk();
8
9
  const tiptapRef = useRef(null);
10
+ const [isEmpty, setIsEmpty] = useState(false);
11
+ useEffect(() => {
12
+ setIsEmpty(!stripHtmlTags(message));
13
+ }, [message]);
9
14
  const handleSubmit = (e) => {
10
15
  var _a, _b, _c;
11
16
  e.preventDefault();
@@ -28,14 +33,20 @@ const ChatInput = () => {
28
33
  }
29
34
  };
30
35
  return (<form onSubmit={handleSubmit} className="flex w-full items-center gap-2">
31
- <div className="flex flex-1 justify-center gap-[10px] rounded-[10px] border-[1px] border-solid border-grayScale6 p-[4px]">
36
+ <div className="flex flex-1 justify-center gap-[10px] rounded-[10px] border-[1px] border-solid border-grayScale6 bg-drTalkGrayscale5 p-[4px]">
32
37
  {/* 최초 높이 44 */}
33
38
  {/*내용이 2줄 이상되면 입력창 높이도 키워져야합니다. 최대한 4줄까지만 보이도록 해주시고, 그 이상은 스크롤 될 수 있도록 해주시는 게 좋을 것 같습니다. max height 값을 72로 지정 부탁드립니다*/}
39
+
34
40
  <Tiptap ref={tiptapRef}
35
41
  // value={message}
36
- onChange={setMessage} onEnterKeyPress={handleEnter} placeholder="메시지를 입력하세요..." contentClassName={`!outline-none !border-[0px] !pt-[4px] !pl-[4px]`}/>
42
+ onChange={setMessage} onEnterKeyPress={handleEnter} placeholder="메시지를 입력해 주세요." contentClassName={`!outline-none !border-[0px] !pt-[4px] !pl-[4px]`}/>
43
+
37
44
  <div className={`flex flex-col justify-end`}>
38
- <button type="submit" className={`flex h-10 w-10 items-center justify-center rounded-[8px] bg-drTalkBtnActive2 text-white ${isLoading || !message.trim() ? 'cursor-not-allowed opacity-50' : ' bg-drTalkCrimson '}`} disabled={isLoading || !message.trim()}>
45
+ <button type="submit" className={`flex h-10 w-10 items-center justify-center rounded-[8px] bg-drTalkBtnActive2 text-white ${isLoading
46
+ ? 'cursor-not-allowed opacity-50'
47
+ : isEmpty
48
+ ? ' bg-drTalkBtnActive2 '
49
+ : ' bg-drTalkCrimson '}`} disabled={isLoading}>
39
50
  <div className="flex h-9 w-9 items-center justify-center">
40
51
  <SendIcon width={24} height={24}/>
41
52
  </div>
@@ -2,12 +2,19 @@ import React, { useEffect, useRef, useState } from 'react';
2
2
  import { useDaeryuntalk } from './DaeryuntalkContext';
3
3
  import SendIcon from '../../asset/images/daeryuntalk/send.svg';
4
4
  import Tiptap, { TiptapEditorRef } from './Tiptap/Tiptap';
5
+ import { stripHtmlTags } from './_lib/utils';
6
+ import ShadowBox from './_ui/ShadowBox';
7
+ import { useScrollShadow } from './_hooks/useScrollShadow';
5
8
 
6
9
  const ChatInput: React.FC = () => {
7
10
  const [message, setMessage] = useState('');
8
11
  const { sendMessage, isLoading } = useDaeryuntalk();
9
12
  const tiptapRef = useRef<TiptapEditorRef | null>(null);
13
+ const [isEmpty, setIsEmpty] = useState<boolean>(false);
10
14
 
15
+ useEffect(() => {
16
+ setIsEmpty(!stripHtmlTags(message));
17
+ }, [message]);
11
18
  const handleSubmit = (e: React.FormEvent) => {
12
19
  e.preventDefault();
13
20
  if (message.trim() && !isLoading) {
@@ -28,27 +35,32 @@ const ChatInput: React.FC = () => {
28
35
  tiptapRef.current?.clearContent(); // 입력창 초기화
29
36
  }
30
37
  };
31
-
32
38
  return (
33
39
  <form onSubmit={handleSubmit} className="flex w-full items-center gap-2">
34
- <div className="flex flex-1 justify-center gap-[10px] rounded-[10px] border-[1px] border-solid border-grayScale6 p-[4px]">
40
+ <div className="flex flex-1 justify-center gap-[10px] rounded-[10px] border-[1px] border-solid border-grayScale6 bg-drTalkGrayscale5 p-[4px]">
35
41
  {/* 최초 높이 44 */}
36
42
  {/*내용이 2줄 이상되면 입력창 높이도 키워져야합니다. 최대한 4줄까지만 보이도록 해주시고, 그 이상은 스크롤 될 수 있도록 해주시는 게 좋을 것 같습니다. max height 값을 72로 지정 부탁드립니다*/}
43
+
37
44
  <Tiptap
38
45
  ref={tiptapRef}
39
46
  // value={message}
40
47
  onChange={setMessage}
41
48
  onEnterKeyPress={handleEnter}
42
- placeholder="메시지를 입력하세요..."
49
+ placeholder="메시지를 입력해 주세요."
43
50
  contentClassName={`!outline-none !border-[0px] !pt-[4px] !pl-[4px]`}
44
51
  />
52
+
45
53
  <div className={`flex flex-col justify-end`}>
46
54
  <button
47
55
  type="submit"
48
56
  className={`flex h-10 w-10 items-center justify-center rounded-[8px] bg-drTalkBtnActive2 text-white ${
49
- isLoading || !message.trim() ? 'cursor-not-allowed opacity-50' : ' bg-drTalkCrimson '
57
+ isLoading
58
+ ? 'cursor-not-allowed opacity-50'
59
+ : isEmpty
60
+ ? ' bg-drTalkBtnActive2 '
61
+ : ' bg-drTalkCrimson '
50
62
  }`}
51
- disabled={isLoading || !message.trim()}
63
+ disabled={isLoading}
52
64
  >
53
65
  <div className="flex h-9 w-9 items-center justify-center">
54
66
  <SendIcon width={24} height={24} />
@@ -44,7 +44,7 @@ const ChatFile = ({ message, isOperator, isHovered, time }) => {
44
44
  ? message.files.filter(file => file.type === 'image').sort((a, b) => a.sequence - b.sequence)
45
45
  : [];
46
46
  const files = message.files
47
- ? message.files.filter(file => file.type !== 'image').sort((a, b) => a.sequence - b.sequence)
47
+ ? message.files.filter(file => file.type === 'file').sort((a, b) => a.sequence - b.sequence)
48
48
  : [];
49
49
  return (<div className={`flex flex-col gap-[10px]`}>
50
50
  {images.length > 0 && renderMedia({ type: 'image', images })}
@@ -45,7 +45,7 @@ const ChatFile = ({ message, isOperator, isHovered, time }: props) => {
45
45
  ? message.files.filter(file => file.type === 'image').sort((a, b) => a.sequence - b.sequence)
46
46
  : [];
47
47
  const files = message.files
48
- ? message.files.filter(file => file.type !== 'image').sort((a, b) => a.sequence - b.sequence)
48
+ ? message.files.filter(file => file.type === 'file').sort((a, b) => a.sequence - b.sequence)
49
49
  : [];
50
50
 
51
51
  return (
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import { Message } from '../_types/message';
3
3
  interface props {
4
4
  message: Message;
5
+ isOperator: boolean;
6
+ isMobile: boolean;
5
7
  }
6
- declare const WorkFlowImg: ({ message }: props) => React.JSX.Element;
8
+ declare const WorkFlowImg: ({ message, isOperator, isMobile }: props) => React.JSX.Element;
7
9
  export default WorkFlowImg;
@@ -1,19 +1,180 @@
1
1
  import React from 'react';
2
2
  import Image from 'next/image';
3
3
  import { InquiryMessageTemplateType } from '../_enums/template';
4
- const WorkFlowImg = ({ message }) => {
4
+ import DOMPurify from 'dompurify';
5
+ import ChatWrapper from './ChatWrapper';
6
+ import { decodeDoubleEscapedHtml } from '../_lib/utils';
7
+ import { useWindowSize } from '../_hooks/useWindowSize';
8
+ const WorkFlowImg = ({ message, isOperator, isMobile }) => {
9
+ var _a, _b, _c;
5
10
  const workFlowItem = message.workFlow;
6
11
  const messageType = (message === null || message === void 0 ? void 0 : message.templateType) || '';
12
+ const windowSize = useWindowSize();
13
+ // 워크플로우 메시지 템플릿 1 : 텍스트
7
14
  if (messageType === InquiryMessageTemplateType.WORK_FLOW_TEMPLATE_1) {
15
+ return <ChatWrapper isOperator={isOperator}>{(_a = message === null || message === void 0 ? void 0 : message.blocks) === null || _a === void 0 ? void 0 : _a.map(item => item === null || item === void 0 ? void 0 : item.value)}</ChatWrapper>;
8
16
  }
17
+ // 워크플로우 메시지 템플릿 2 : 이미지 + 텍스트 (이미지)
9
18
  if (messageType === InquiryMessageTemplateType.WORK_FLOW_TEMPLATE_2) {
19
+ return (<>
20
+ {/*{message?.blocks && (*/}
21
+ {/* <ChatWrapper isOperator={isOperator}>{message?.blocks?.map(item => item?.value)}</ChatWrapper>*/}
22
+ {/*)}*/}
23
+ {(workFlowItem === null || workFlowItem === void 0 ? void 0 : workFlowItem.imageUrl) && (<div className={`flex h-auto flex-col overflow-hidden rounded-[10px] border-[1px] border-drTalkGrayscale4`}>
24
+ <Image src={(workFlowItem === null || workFlowItem === void 0 ? void 0 : workFlowItem.imageUrl) || ''} alt={''} width={500} height={300} className={`h-full w-full rounded-[10px] object-cover`} unoptimized={true}/>
25
+ {(message === null || message === void 0 ? void 0 : message.blocks) &&
26
+ ((_b = message === null || message === void 0 ? void 0 : message.blocks) === null || _b === void 0 ? void 0 : _b.map((item, index) => {
27
+ const decoded = decodeDoubleEscapedHtml(item.value);
28
+ const shouldRemoveBr = windowSize.width <= 480 || isMobile;
29
+ const cleaned = shouldRemoveBr ? decoded.replace(/<br\s*\/?>/gi, '') : decoded;
30
+ // // 여기서 ,
31
+ // windowSize.width<=480 || isMobile 일 경우 <br/>은 제거시켜버리고 싶다
32
+ const sanitizedHtml = DOMPurify.sanitize(cleaned);
33
+ return <div key={index} dangerouslySetInnerHTML={{ __html: sanitizedHtml }}/>;
34
+ }))}
35
+ </div>)}
36
+ </>);
10
37
  }
38
+ // 워크플로우 메시지 템플릿 3 : 아이콘 + 텍스트
11
39
  if (messageType === InquiryMessageTemplateType.WORK_FLOW_TEMPLATE_3) {
40
+ return (<>
41
+ {/*{message?.blocks && (*/}
42
+ {/* <ChatWrapper isOperator={isOperator}>{message?.blocks?.map(item => item?.value)}</ChatWrapper>*/}
43
+ {/*)}*/}
44
+ {(workFlowItem === null || workFlowItem === void 0 ? void 0 : workFlowItem.imageUrl) && (<div className={`flex h-auto flex-col overflow-hidden rounded-[10px] border-[1px] border-drTalkGrayscale4`}>
45
+ <Image src={(workFlowItem === null || workFlowItem === void 0 ? void 0 : workFlowItem.imageUrl) || ''} alt={''} width={500} height={300} className={`h-full w-full rounded-[10px] object-cover`} unoptimized={true}/>
46
+ {(message === null || message === void 0 ? void 0 : message.blocks) &&
47
+ ((_c = message === null || message === void 0 ? void 0 : message.blocks) === null || _c === void 0 ? void 0 : _c.map((item, index) => {
48
+ const decoded = decodeDoubleEscapedHtml(item.value);
49
+ const sanitizedHtml = DOMPurify.sanitize(decoded);
50
+ return <div key={index} dangerouslySetInnerHTML={{ __html: sanitizedHtml }}/>;
51
+ }))}
52
+ </div>)}
53
+ </>);
12
54
  }
55
+ // 워크플로우 메시지 템플릿 4 : 텍스트 + form
13
56
  if (messageType === InquiryMessageTemplateType.WORK_FLOW_TEMPLATE_4) {
14
57
  }
15
- return (<div className={`h-auto overflow-hidden rounded-[10px] border-[1px] border-drTalkGrayscale4`}>
16
- <Image src={(workFlowItem === null || workFlowItem === void 0 ? void 0 : workFlowItem.imageUrl) || ''} alt={''} width={1000} height={300} className={`h-full w-full rounded-[10px] object-cover`} unoptimized={true}/>
58
+ // const case1 = `
59
+ // <div style="display: flex; flex-direction: column; gap: 8px; padding: 20px 16px; color: #000;">
60
+ // <div style="display: flex; height: 30px; align-items: flex-start; justify-content: center; border-bottom: 1px solid #EDEDED; text-align: center; font-size: 16px; font-weight: 700; line-height: 140%; letter-spacing: -4%; color: #000;">
61
+ // 대륜의&nbsp;<span style="color: #AA1D36;">차별화</span>된
62
+ // <span style="color: #AA1D36;">조력 시스템</span>
63
+ // </div>
64
+ //
65
+ // <div style="display: flex; flex-direction: column; font-size: 16px; font-weight: 400; line-height: 100%; letter-spacing: -4%;">
66
+ // <div style="display: flex; flex-direction: row; align-items: center; height: 24px;">
67
+ // <div style="display: flex; height: 24px; width: 24px; align-items: center; justify-content: center;">
68
+ // <svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
69
+ // <path
70
+ // d="M9.5 1L4.5 7.5L1.5 4"
71
+ // stroke="#AA1D36"
72
+ // stroke-width="2"
73
+ // stroke-linecap="round"
74
+ // stroke-linejoin="round"
75
+ // />
76
+ // </svg>
77
+ // </div>
78
+ // 전문 변호사 직접 상담
79
+ // </div>
80
+ //
81
+ // <div style="display: flex; flex-direction: row; align-items: center; height: 24px;">
82
+ // <div style="display: flex; height: 24px; width: 24px; align-items: center; justify-content: center;">
83
+ // <svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
84
+ // <path
85
+ // d="M9.5 1L4.5 7.5L1.5 4"
86
+ // stroke="#AA1D36"
87
+ // stroke-width="2"
88
+ // stroke-linecap="round"
89
+ // stroke-linejoin="round"
90
+ // />
91
+ // </svg>
92
+ // </div>
93
+ // 분야별 해결사례 데이터베이스
94
+ // </div>
95
+ //
96
+ // <div style="display: flex; flex-direction: row; align-items: center; height: 24px;">
97
+ // <div style="display: flex; height: 24px; width: 24px; align-items: center; justify-content: center;">
98
+ // <svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
99
+ // <path
100
+ // d="M9.5 1L4.5 7.5L1.5 4"
101
+ // stroke="#AA1D36"
102
+ // stroke-width="2"
103
+ // stroke-linecap="round"
104
+ // stroke-linejoin="round"
105
+ // />
106
+ // </svg>
107
+ // </div>
108
+ // 전국 사무소 운영
109
+ // </div>
110
+ // </div>
111
+ // </div>
112
+ // `;
113
+ //
114
+ // const case2 = `
115
+ // <div style="display: flex; flex-direction: column; gap: 8px; padding: 20px 16px; font-size: 16px; line-height: 140%; letter-spacing: -4%; color: #000000;">
116
+ // <div style="font-weight: 400;">
117
+ // <span style="font-weight: 700; color: #AA1D36; line-height: 100%;">법무법인 대륜</span>은 다양한 분야의 법률<br/>
118
+ // 문제를 다루고 있습니다. 궁금하신 분<br/>야를 선택해 주세요.
119
+ // </div>
120
+ // </div>
121
+ // `;
122
+ //
123
+ // const case3 = `
124
+ // <div style="display: flex; flex-direction: column; gap: 8px; padding: 20px 16px; font-size: 16px; line-height: 140%; letter-spacing: -4%; color: #000000;">
125
+ // <div style="font-weight: 400;">
126
+ // 아래 버튼을 클릭하시면&nbsp;<span style="font-weight: 700; color: #AA1D36; line-height: 100%;">채팅 문의 외<br/>다른 방법</span>으로 빠르게 문의하실 수 있<br/>습니다.
127
+ // </div>
128
+ // </div>
129
+ // `;
130
+ //
131
+ // const case4 = `
132
+ // <div style="display: flex; flex-direction: column; gap: 8px; padding: 20px 16px; font-size: 16px; line-height: 140%; letter-spacing: -4%; color: #000000;">
133
+ // <div style="font-weight: 400;">
134
+ // 해당 사건에&nbsp;<span style="font-weight: 700; color: #AA1D36; line-height: 100%;">특화된 전문변호사</span>가<br/>토 후 신속한 대응 전략을 제시합니<br/>다.
135
+ // </div>
136
+ // </div>
137
+ // `;
138
+ //
139
+ // //
140
+ // const case5 = `
141
+ // <div style="display: flex; flex-direction: column; gap: 8px; padding: 20px 16px; font-size: 16px; font-weight: 400; line-height: 140%; letter-spacing: -4%; color: #000000;">
142
+ // <div>
143
+ // 전화 상담을 이용하시면 가장 빠르게<br />관련 상담을 진행하실 수 있습니다.
144
+ // </div>
145
+ // <div>
146
+ // <span style="font-weight: 700; color: #AA1D36; ">T.</span>&nbsp;<span style="font-weight: 700; ">1800-7905</span>
147
+ // </div>
148
+ // </div>
149
+ // `;
150
+ // const case6 = `
151
+ // <div style="display: flex; flex-direction: column; gap: 8px; padding: 20px 16px; font-size: 16px; line-height: 140%; letter-spacing: -4%; color: #000000;">
152
+ // <div style="font-weight: 400;">
153
+ // <span style="font-weight: 700; color: #AA1D36; line-height: 100%;">AI대륜</span>과 함께하면 법률상담이 더<br />쉬워집니다!
154
+ // </div>
155
+ // <div>
156
+ // <span style="font-weight: 700; color: #AA1D36; line-height: 100%;">24시간 신속</span>하고
157
+ // <span style="font-weight: 700; color: #AA1D36; line-height: 100%;">정확한 법률 정보</span>를<br />제공받고, 변호사 상담까지 빠르게 진<br />행하세요.
158
+ // </div>
159
+ // </div>
160
+ // `;
161
+ //
162
+ // const case7 = `
163
+ // <div style="display: flex; flex-direction: column; gap: 8px; padding: 20px 16px; font-size: 16px; font-weight: 400; line-height: 140%; letter-spacing: -4%; color: #000000;">
164
+ // <div>
165
+ // 많은 고객님들께서 실제로 궁금해하<br />
166
+ // 셨던 질문을 정리해 두었습니다.
167
+ // </div>
168
+ // <div>
169
+ // 문의 전 확인하시면 더욱 빠르고<br />
170
+ // 정확한 안내가 가능합니다.
171
+ // </div>
172
+ // </div>
173
+ // `;
174
+ // const sanitizedHtml = DOMPurify.sanitize(case1);
175
+ return (<div className={`flex h-auto flex-col overflow-hidden rounded-[10px] border-[1px] border-drTalkGrayscale4`}>
176
+ <Image src={(workFlowItem === null || workFlowItem === void 0 ? void 0 : workFlowItem.imageUrl) || ''} alt={''} width={500} height={300} className={`h-full w-full rounded-[10px] object-cover`} unoptimized={true}/>
177
+ {/*<div dangerouslySetInnerHTML={{ __html: sanitizedHtml }} />*/}
17
178
  </div>);
18
179
  };
19
180
  export default WorkFlowImg;