@daeryun/dr_components 0.6.49 → 0.6.50

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 (42) hide show
  1. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  2. package/dist/components/Daeryuntalk/ChatConversation.jsx +11 -8
  3. package/dist/components/Daeryuntalk/ChatConversation.tsx +17 -9
  4. package/dist/components/Daeryuntalk/ChatHomeView.jsx +54 -26
  5. package/dist/components/Daeryuntalk/ChatHomeView.tsx +57 -26
  6. package/dist/components/Daeryuntalk/ChatMessage.jsx +3 -46
  7. package/dist/components/Daeryuntalk/ChatMessage.tsx +2 -81
  8. package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +3 -5
  9. package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +128 -501
  10. package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +149 -548
  11. package/dist/components/Daeryuntalk/index.jsx +1 -11
  12. package/dist/components/Daeryuntalk/index.tsx +1 -13
  13. package/dist/components/Daeryuntalk/socketManager.js +1 -9
  14. package/dist/components/Daeryuntalk/socketManager.ts +1 -9
  15. package/dist/components/Daeryuntalk/types.d.ts +14 -14
  16. package/dist/components/Daeryuntalk/types.js +0 -72
  17. package/dist/components/Daeryuntalk/types.ts +34 -104
  18. package/dist/components/common/integrate/index.d.ts +1 -1
  19. package/dist/lib/api/daeryuntalk/index.d.ts +64 -9
  20. package/dist/lib/api/daeryuntalk/index.js +79 -18
  21. package/dist/lib/api/daeryuntalk/index.ts +160 -31
  22. package/dist/lib/api/index.d.ts +0 -2
  23. package/dist/lib/api/index.js +0 -2
  24. package/dist/lib/api/index.ts +0 -2
  25. package/dist/styles/globals.css +0 -45
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +1 -1
  28. package/dist/components/Daeryuntalk/DaeryuntalkProvider.d.ts +0 -11
  29. package/dist/components/Daeryuntalk/DaeryuntalkProvider.jsx +0 -59
  30. package/dist/components/Daeryuntalk/DaeryuntalkProvider.tsx +0 -68
  31. package/dist/components/Daeryuntalk/message-components/FileContent.d.ts +0 -8
  32. package/dist/components/Daeryuntalk/message-components/FileContent.jsx +0 -32
  33. package/dist/components/Daeryuntalk/message-components/FileContent.tsx +0 -43
  34. package/dist/components/Daeryuntalk/message-components/FormContent.d.ts +0 -8
  35. package/dist/components/Daeryuntalk/message-components/FormContent.jsx +0 -104
  36. package/dist/components/Daeryuntalk/message-components/FormContent.tsx +0 -184
  37. package/dist/lib/api/daeryuntalk/chatInquiry.d.ts +0 -23
  38. package/dist/lib/api/daeryuntalk/chatInquiry.js +0 -78
  39. package/dist/lib/api/daeryuntalk/chatInquiry.ts +0 -80
  40. package/dist/lib/api/daeryuntalk/useDaeryuntalkApi.d.ts +0 -23
  41. package/dist/lib/api/daeryuntalk/useDaeryuntalkApi.js +0 -140
  42. 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' | 'historyDetail';
14
+ type ViewState = 'home' | 'conversation' | 'history';
14
15
 
15
16
  const ChatHomeView: React.FC = () => {
16
- const { sendMessage, viewHistory, messages } = useDaeryuntalk();
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 handleStartChat = () => {
21
- sendMessage('상담 문의 드립니다.');
22
- setViewState('conversation');
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,11 +94,15 @@ 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={DaeryuntalkIntro}
105
+ src={backgroundImage}
84
106
  alt="대화 배경"
85
107
  fill
86
108
  className="object-contain object-top will-change-transform"
@@ -96,37 +118,46 @@ const ChatHomeView: React.FC = () => {
96
118
 
97
119
  <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
120
  <div className="flex items-center">
99
- <DaeryunLogoIcon width={24} height={24} className="mr-2" />
100
- <h1 className="font-medium">법무법인(유한)대륜</h1>
121
+ {mainData?.channel_logo_image_url ? (
122
+ <Image
123
+ src={mainData.channel_logo_image_url}
124
+ alt="로고"
125
+ width={24}
126
+ height={24}
127
+ className="mr-2"
128
+ />
129
+ ) : (
130
+ <DaeryunLogoIcon width={24} height={24} className="mr-2" />
131
+ )}
132
+ <h1 className="font-medium">{mainData?.channel_name || '법무법인(유한)대륜'}</h1>
101
133
  </div>
102
134
 
103
- <div className="mx-8 text-sm font-normal leading-[130%]">
104
- 안녕하세요.
105
- <br />
106
- 법무법인(유한)대륜입니다.
107
- <br />
108
- 방문해 주셔서 감사합니다.
109
- <br />
110
- 궁금한 점이나 도움이 필요하신 부분
111
- <br />
112
- 말씀해 주시면 도와드리겠습니다.
113
- <br />
114
- <br />
115
- 6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.
135
+ <div className="mx-8 whitespace-pre-line text-sm font-normal leading-[130%]">
136
+ {mainData?.salutation ||
137
+ `안녕하세요.
138
+ 법무법인(유한)대륜입니다.
139
+ 방문해 주셔서 감사합니다.
140
+ 궁금한 점이나 도움이 필요하신 부분
141
+ 말씀해 주시면 도와드리겠습니다.
142
+
143
+ 6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.`}
116
144
  </div>
117
145
 
118
146
  <button
119
147
  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
148
  aria-label="문의하기"
121
149
  onClick={handleStartChat}
150
+ disabled={isLoading}
122
151
  >
123
- 문의하기
124
- <SendIcon width={24} height={24} />
152
+ {isLoading ? '로딩 중...' : '문의하기'}
153
+ {!isLoading && <SendIcon width={24} height={24} />}
125
154
  </button>
126
155
 
127
156
  <div className="flex items-center justify-center gap-1">
128
157
  <InfoIcon width={20} height={20} />
129
- <span className="text-xs font-normal text-gray-500">빠르게 답변 받으실 수 있어요</span>
158
+ <span className="text-xs font-normal text-gray-500">
159
+ {mainData?.answer_speed_message || '빠르게 답변 받으실 수 있어요'}
160
+ </span>
130
161
  </div>
131
162
  </section>
132
163
  </div>
@@ -1,12 +1,7 @@
1
1
  import React from 'react';
2
- import Image from 'next/image';
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, _b, _c, _d;
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 Image from 'next/image';
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;