@daeryun/dr_components 0.7.94 → 0.7.96
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/components/Daeryuntalk/ChatButton.jsx +1 -1
- package/dist/components/Daeryuntalk/ChatButton.tsx +1 -1
- package/dist/components/Daeryuntalk/ChatConversation.jsx +1 -0
- package/dist/components/Daeryuntalk/ChatConversation.tsx +1 -0
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +14 -5
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +19 -6
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.jsx +3 -3
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.tsx +6 -3
- package/dist/components/Daeryuntalk/ChatWidget.jsx +21 -9
- package/dist/components/Daeryuntalk/ChatWidget.tsx +23 -10
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +1 -1
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +0 -1
- package/dist/components/Daeryuntalk/History/AuthForm.jsx +2 -2
- package/dist/components/Daeryuntalk/History/AuthForm.tsx +2 -4
- package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.d.ts +17 -7
- package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.jsx +14 -18
- package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.tsx +25 -38
- package/dist/components/Daeryuntalk/Toast/ToastRender.d.ts +1 -0
- package/dist/components/Daeryuntalk/Toast/ToastRender.jsx +17 -0
- package/dist/components/Daeryuntalk/Toast/ToastRender.tsx +27 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +0 -6
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +31 -22
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +27 -30
- package/dist/components/Daeryuntalk/_hooks/useScrollShadow.d.ts +6 -0
- package/dist/components/Daeryuntalk/_hooks/useScrollShadow.js +27 -0
- package/dist/components/Daeryuntalk/_hooks/useScrollShadow.ts +34 -0
- package/dist/components/Daeryuntalk/_ui/ShadowBox.d.ts +3 -0
- package/dist/components/Daeryuntalk/_ui/ShadowBox.jsx +5 -0
- package/dist/components/Daeryuntalk/_ui/ShadowBox.tsx +9 -0
- package/dist/components/Daeryuntalk/index.jsx +7 -4
- package/dist/components/Daeryuntalk/index.tsx +8 -4
- package/dist/styles/globals.css +255 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ const ChatButton = ({ isOpen, onClick, apiVersion }) => {
|
|
|
14
14
|
onClick();
|
|
15
15
|
}, [isOpen, onClick, initializeDaeryuntalk, apiVersion]);
|
|
16
16
|
return (<button aria-label="채팅 상담 열기" onClick={handleClick} className={`
|
|
17
|
-
fixed bottom-[
|
|
17
|
+
fixed bottom-[85px] right-[20px] h-[60px] w-[60px] rounded-[10px] border lg:bottom-[30px] lg:right-[30px]
|
|
18
18
|
${isOpen ? 'border-gray-200 bg-white' : 'border-[#AA1D36] bg-[#AA1D36]'}
|
|
19
19
|
z-[999999] flex transform cursor-pointer items-center justify-center
|
|
20
20
|
p-0 shadow-lg outline-none transition-all duration-300 ease-in-out
|
|
@@ -28,7 +28,7 @@ const ChatButton: React.FC<ChatButtonProps> = ({ isOpen, onClick, apiVersion })
|
|
|
28
28
|
aria-label="채팅 상담 열기"
|
|
29
29
|
onClick={handleClick}
|
|
30
30
|
className={`
|
|
31
|
-
fixed bottom-[
|
|
31
|
+
fixed bottom-[85px] right-[20px] h-[60px] w-[60px] rounded-[10px] border lg:bottom-[30px] lg:right-[30px]
|
|
32
32
|
${isOpen ? 'border-gray-200 bg-white' : 'border-[#AA1D36] bg-[#AA1D36]'}
|
|
33
33
|
z-[999999] flex transform cursor-pointer items-center justify-center
|
|
34
34
|
p-0 shadow-lg outline-none transition-all duration-300 ease-in-out
|
|
@@ -19,13 +19,19 @@ import InfoIcon from '../../asset/images/daeryuntalk/info.svg';
|
|
|
19
19
|
import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
20
20
|
import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk-intro.png';
|
|
21
21
|
import { useChatSocketState } from './_hooks/talkprovider/useChatSocketState';
|
|
22
|
-
import {
|
|
22
|
+
import { useScrollShadow } from './_hooks/useScrollShadow';
|
|
23
|
+
import ShadowBox from './_ui/ShadowBox';
|
|
24
|
+
import { useDaeryunTalkToast } from './Toast/DaeryuntalkToastProvider';
|
|
23
25
|
const ChatHomeView = () => {
|
|
24
26
|
const { isAuthenticated, historyList, inquiryMainData, startChat, createNewChat, chatInquiryNumber, sendHeartbeat, sendInquiryLeft, goGetHistoryList, sendHistoryEntered, sendHistoryLeft, startSelectedChat } = useDaeryuntalk();
|
|
25
27
|
const [viewState, setViewState] = useState('home');
|
|
26
28
|
const [mainData, setMainData] = useState(null);
|
|
27
29
|
const [isLoading, setIsLoading] = useState(false);
|
|
28
|
-
const
|
|
30
|
+
const { containerRef, isScroll, isBottom, checkScroll } = useScrollShadow();
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
checkScroll();
|
|
33
|
+
}, [mainData]);
|
|
34
|
+
const toast = useDaeryunTalkToast();
|
|
29
35
|
useEffect(() => {
|
|
30
36
|
if (viewState === 'history') {
|
|
31
37
|
goGetHistoryList({});
|
|
@@ -133,14 +139,15 @@ const ChatHomeView = () => {
|
|
|
133
139
|
<span>24시간 운영</span>
|
|
134
140
|
</header>
|
|
135
141
|
|
|
136
|
-
<section className="mx-auto mt-[150px] flex w-[320px] flex-col gap-5 rounded-[12px] bg-white px-4 py-6
|
|
142
|
+
<section className="mx-auto mt-[150px] flex w-[320px] flex-col gap-5 rounded-[12px] bg-white px-4 py-6 ">
|
|
137
143
|
<div className="flex items-center">
|
|
138
144
|
{(mainData === null || mainData === void 0 ? void 0 : mainData.channel_logo_image_url) ? (<Image src={mainData.channel_logo_image_url} alt="로고" width={24} height={24} className="mr-2"/>) : (<DaeryunLogoIcon width={24} height={24} className="mr-2"/>)}
|
|
139
145
|
<h1 className="font-medium">{(mainData === null || mainData === void 0 ? void 0 : mainData.channel_name) || '법무법인(유한)대륜'}</h1>
|
|
140
146
|
</div>
|
|
141
147
|
|
|
142
|
-
<div className=
|
|
143
|
-
{
|
|
148
|
+
<div className={`relative`}>
|
|
149
|
+
<div ref={containerRef} className="no-scrollbar relative mx-8 max-h-[162px] overflow-auto whitespace-pre-line text-sm font-normal leading-[130%]">
|
|
150
|
+
{(mainData === null || mainData === void 0 ? void 0 : mainData.salutation) ||
|
|
144
151
|
`안녕하세요.
|
|
145
152
|
법무법인(유한)대륜입니다.
|
|
146
153
|
방문해 주셔서 감사합니다.
|
|
@@ -148,6 +155,8 @@ const ChatHomeView = () => {
|
|
|
148
155
|
말씀해 주시면 도와드리겠습니다.
|
|
149
156
|
|
|
150
157
|
6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.`}
|
|
158
|
+
</div>
|
|
159
|
+
{!isScroll && !isBottom && <ShadowBox />}
|
|
151
160
|
</div>
|
|
152
161
|
|
|
153
162
|
<button className="mt-4 flex h-[48px] w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white" aria-label={`문의하기`} onClick={handleStartChat} disabled={isLoading}>
|
|
@@ -11,7 +11,9 @@ import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
|
11
11
|
import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk-intro.png';
|
|
12
12
|
import { IChatInquiryMainDataResponse } from './_api/daeryuntalk/type/response';
|
|
13
13
|
import { useChatSocketState } from './_hooks/talkprovider/useChatSocketState';
|
|
14
|
-
import {
|
|
14
|
+
import { useScrollShadow } from './_hooks/useScrollShadow';
|
|
15
|
+
import ShadowBox from './_ui/ShadowBox';
|
|
16
|
+
import { useDaeryunTalkToast } from './Toast/DaeryuntalkToastProvider';
|
|
15
17
|
|
|
16
18
|
type ViewState = 'home' | 'conversation' | 'history';
|
|
17
19
|
|
|
@@ -33,7 +35,12 @@ const ChatHomeView: React.FC = () => {
|
|
|
33
35
|
const [viewState, setViewState] = useState<ViewState>('home');
|
|
34
36
|
const [mainData, setMainData] = useState<IChatInquiryMainDataResponse | null>(null);
|
|
35
37
|
const [isLoading, setIsLoading] = useState(false);
|
|
36
|
-
const
|
|
38
|
+
const { containerRef, isScroll, isBottom, checkScroll } = useScrollShadow<HTMLDivElement>();
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
checkScroll();
|
|
41
|
+
}, [mainData]);
|
|
42
|
+
|
|
43
|
+
const toast = useDaeryunTalkToast();
|
|
37
44
|
|
|
38
45
|
useEffect(() => {
|
|
39
46
|
if (viewState === 'history') {
|
|
@@ -181,7 +188,7 @@ const ChatHomeView: React.FC = () => {
|
|
|
181
188
|
<span>24시간 운영</span>
|
|
182
189
|
</header>
|
|
183
190
|
|
|
184
|
-
<section className="mx-auto mt-[150px] flex w-[320px] flex-col gap-5 rounded-[12px] bg-white px-4 py-6
|
|
191
|
+
<section className="mx-auto mt-[150px] flex w-[320px] flex-col gap-5 rounded-[12px] bg-white px-4 py-6 ">
|
|
185
192
|
<div className="flex items-center">
|
|
186
193
|
{mainData?.channel_logo_image_url ? (
|
|
187
194
|
<Image
|
|
@@ -197,15 +204,21 @@ const ChatHomeView: React.FC = () => {
|
|
|
197
204
|
<h1 className="font-medium">{mainData?.channel_name || '법무법인(유한)대륜'}</h1>
|
|
198
205
|
</div>
|
|
199
206
|
|
|
200
|
-
<div className=
|
|
201
|
-
|
|
202
|
-
|
|
207
|
+
<div className={`relative`}>
|
|
208
|
+
<div
|
|
209
|
+
ref={containerRef}
|
|
210
|
+
className="no-scrollbar relative mx-8 max-h-[162px] overflow-auto whitespace-pre-line text-sm font-normal leading-[130%]"
|
|
211
|
+
>
|
|
212
|
+
{mainData?.salutation ||
|
|
213
|
+
`안녕하세요.
|
|
203
214
|
법무법인(유한)대륜입니다.
|
|
204
215
|
방문해 주셔서 감사합니다.
|
|
205
216
|
궁금한 점이나 도움이 필요하신 부분
|
|
206
217
|
말씀해 주시면 도와드리겠습니다.
|
|
207
218
|
|
|
208
219
|
6:00~24:00 외 시간에는 상담인력의 편성에 따라 순차적으로 응대를 도와드리고 있습니다.`}
|
|
220
|
+
</div>
|
|
221
|
+
{!isScroll && !isBottom && <ShadowBox />}
|
|
209
222
|
</div>
|
|
210
223
|
|
|
211
224
|
<button
|
|
@@ -117,14 +117,14 @@ const ChatFile = ({ message, isOperator, isHovered, time }) => {
|
|
|
117
117
|
</div>);
|
|
118
118
|
}
|
|
119
119
|
else if (media.type === 'file') {
|
|
120
|
-
return (<div className={`flex w-fit items-end gap-[4px]`}>
|
|
120
|
+
return (<div className={` flex w-fit items-end gap-[4px]`}>
|
|
121
121
|
<div className="flex w-full flex-col gap-[10px] ">
|
|
122
122
|
{media.files.map((file, index) => {
|
|
123
123
|
const fileExtension = file.name.split('.').pop() || '';
|
|
124
124
|
const baseName = file.name.replace(`.${fileExtension}`, '');
|
|
125
125
|
const truncatedName = baseName.length > 12 ? `${baseName.slice(0, 12)}…` : baseName;
|
|
126
126
|
const fileName = `${truncatedName}.${fileExtension}`;
|
|
127
|
-
return (<div key={index} className={`flex w-full items-end justify-start gap-[4px]`}>
|
|
127
|
+
return (<div key={index} className={`group relative flex w-full items-end justify-start gap-[4px]`}>
|
|
128
128
|
<div key={index} className={`
|
|
129
129
|
flex items-center justify-between gap-[16px]
|
|
130
130
|
rounded-[10px] border-[1px] border-[#EDEDED] p-[12px]
|
|
@@ -138,7 +138,7 @@ const ChatFile = ({ message, isOperator, isHovered, time }) => {
|
|
|
138
138
|
<button onClick={(e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
139
139
|
e.stopPropagation();
|
|
140
140
|
yield handleDownload(file);
|
|
141
|
-
})} className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full opacity-0 transition-opacity group-hover
|
|
141
|
+
})} className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full opacity-0 transition-opacity group-hover:opacity-100">
|
|
142
142
|
<FileDownLoadIcon className="h-[24px] w-[24px] rounded-full bg-white"/>
|
|
143
143
|
</button>
|
|
144
144
|
</div>
|
|
@@ -172,7 +172,7 @@ const ChatFile = ({ message, isOperator, isHovered, time }: props) => {
|
|
|
172
172
|
);
|
|
173
173
|
} else if (media.type === 'file') {
|
|
174
174
|
return (
|
|
175
|
-
<div className={`flex w-fit items-end gap-[4px]`}>
|
|
175
|
+
<div className={` flex w-fit items-end gap-[4px]`}>
|
|
176
176
|
<div className="flex w-full flex-col gap-[10px] ">
|
|
177
177
|
{media.files.map((file, index) => {
|
|
178
178
|
const fileExtension = file.name.split('.').pop() || '';
|
|
@@ -183,7 +183,10 @@ const ChatFile = ({ message, isOperator, isHovered, time }: props) => {
|
|
|
183
183
|
const fileName = `${truncatedName}.${fileExtension}`;
|
|
184
184
|
|
|
185
185
|
return (
|
|
186
|
-
<div
|
|
186
|
+
<div
|
|
187
|
+
key={index}
|
|
188
|
+
className={`group relative flex w-full items-end justify-start gap-[4px]`}
|
|
189
|
+
>
|
|
187
190
|
<div
|
|
188
191
|
key={index}
|
|
189
192
|
className={`
|
|
@@ -202,7 +205,7 @@ const ChatFile = ({ message, isOperator, isHovered, time }: props) => {
|
|
|
202
205
|
e.stopPropagation();
|
|
203
206
|
await handleDownload(file);
|
|
204
207
|
}}
|
|
205
|
-
className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full opacity-0 transition-opacity group-hover
|
|
208
|
+
className="absolute bottom-[10px] right-[10px] z-10 flex h-[24px] w-[24px] items-center justify-center rounded-full opacity-0 transition-opacity group-hover:opacity-100"
|
|
206
209
|
>
|
|
207
210
|
<FileDownLoadIcon className="h-[24px] w-[24px] rounded-full bg-white" />
|
|
208
211
|
</button>
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ChatHomeView from './ChatHomeView';
|
|
3
3
|
import ImageViewer from './Viewer/ImageViewer';
|
|
4
|
-
import {
|
|
4
|
+
import { useScrollShadow } from './_hooks/useScrollShadow';
|
|
5
|
+
import ShadowBox from './_ui/ShadowBox';
|
|
6
|
+
import ToastRenderer from './Toast/ToastRender';
|
|
5
7
|
const ChatWidget = ({ isOpen }) => {
|
|
8
|
+
const { containerRef, isScroll, isBottom } = useScrollShadow();
|
|
6
9
|
return (<>
|
|
7
10
|
<ImageViewer />
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
|
|
12
|
+
<div className="relative">
|
|
13
|
+
<div className={`fixed bottom-[110px] right-[30px] z-[999998]
|
|
14
|
+
h-[690px] max-h-[calc(100vh-120px)]
|
|
15
|
+
rounded-[30px] shadow-[0px_4px_10px_0px_#00000026]
|
|
16
|
+
transition-all duration-300 ease-out
|
|
17
|
+
${isOpen ? 'translate-y-0 scale-100 opacity-100' : 'pointer-events-none translate-y-6 opacity-0'}
|
|
18
|
+
`}>
|
|
19
|
+
{/* 실제로 스크롤되는 컨테이너에 ref 연결 */}
|
|
20
|
+
<div ref={containerRef} className="no-scrollbar h-full overflow-y-auto rounded-[30px] bg-white">
|
|
21
|
+
<ChatHomeView />
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
{/* 투명 그라데이션 그림자 표시 */}
|
|
25
|
+
{!isScroll && !isBottom && <ShadowBox />}
|
|
26
|
+
<ToastRenderer />
|
|
27
|
+
</div>
|
|
16
28
|
</div>
|
|
17
29
|
</>);
|
|
18
30
|
};
|
|
@@ -2,25 +2,38 @@ import React from 'react';
|
|
|
2
2
|
import ChatHomeView from './ChatHomeView';
|
|
3
3
|
import ImageViewer from './Viewer/ImageViewer';
|
|
4
4
|
import { DaeryuntalkToastProvider } from './Toast/DaeryuntalkToastProvider';
|
|
5
|
+
import { useScrollShadow } from './_hooks/useScrollShadow';
|
|
6
|
+
import ShadowBox from './_ui/ShadowBox';
|
|
7
|
+
import ToastRenderer from './Toast/ToastRender';
|
|
5
8
|
|
|
6
9
|
interface ChatWidgetProps {
|
|
7
10
|
isOpen: boolean;
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen }) => {
|
|
14
|
+
const { containerRef, isScroll, isBottom } = useScrollShadow<HTMLDivElement>();
|
|
11
15
|
return (
|
|
12
16
|
<>
|
|
13
17
|
<ImageViewer />
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
|
|
19
|
+
<div className="relative">
|
|
20
|
+
<div
|
|
21
|
+
className={`fixed bottom-[110px] right-[30px] z-[999998]
|
|
22
|
+
h-[690px] max-h-[calc(100vh-120px)]
|
|
23
|
+
rounded-[30px] shadow-[0px_4px_10px_0px_#00000026]
|
|
24
|
+
transition-all duration-300 ease-out
|
|
25
|
+
${isOpen ? 'translate-y-0 scale-100 opacity-100' : 'pointer-events-none translate-y-6 opacity-0'}
|
|
26
|
+
`}
|
|
27
|
+
>
|
|
28
|
+
{/* 실제로 스크롤되는 컨테이너에 ref 연결 */}
|
|
29
|
+
<div ref={containerRef} className="no-scrollbar h-full overflow-y-auto rounded-[30px] bg-white">
|
|
30
|
+
<ChatHomeView />
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
{/* 투명 그라데이션 그림자 표시 */}
|
|
34
|
+
{!isScroll && !isBottom && <ShadowBox />}
|
|
35
|
+
<ToastRenderer />
|
|
36
|
+
</div>
|
|
24
37
|
</div>
|
|
25
38
|
</>
|
|
26
39
|
);
|
|
@@ -83,7 +83,7 @@ export const DaeryuntalkProvider = ({ children, propsTel }) => {
|
|
|
83
83
|
});
|
|
84
84
|
// MSG15591497825895676
|
|
85
85
|
// 채팅 관련
|
|
86
|
-
const { startChat, sendMessage, createNewChat, startWorkFlow, workFlowBack, chatUserUpdate, getNextMessageList,
|
|
86
|
+
const { startChat, sendMessage, createNewChat, startWorkFlow, workFlowBack, chatUserUpdate, getNextMessageList, startSelectedChat } = useChatHandler({
|
|
87
87
|
setIsLoading,
|
|
88
88
|
inquiryMainData,
|
|
89
89
|
setChatInquiryNumber,
|
|
@@ -12,8 +12,8 @@ import Input2 from '../_ui/inputs/Input2';
|
|
|
12
12
|
import { formatSecondsToMMSS, nameFilter, onlyNumbers, phoneCheck } from '../_lib/utils';
|
|
13
13
|
import Button2 from '../_ui/buttons/Button2';
|
|
14
14
|
import { historyPhoneAuth, requestPhone } from '../_api';
|
|
15
|
-
import { useDearyunTalkToast } from '../Toast/DaeryuntalkToastProvider';
|
|
16
15
|
import { AuthErrorCode } from '../_enums/error_code';
|
|
16
|
+
import { useDaeryunTalkToast } from '../Toast/DaeryuntalkToastProvider';
|
|
17
17
|
const AuthForm = ({ goGetHistoryList }) => {
|
|
18
18
|
const [name, setName] = useState({ value: '', isValid: false });
|
|
19
19
|
const [phone, setPhone] = useState({ value: '', isValid: false });
|
|
@@ -22,7 +22,7 @@ const AuthForm = ({ goGetHistoryList }) => {
|
|
|
22
22
|
const [timer, setTimer] = useState(180); // 3분(180초)
|
|
23
23
|
const [timerId, setTimerId] = useState(null);
|
|
24
24
|
const [isLoading, setIsLoading] = useState(false);
|
|
25
|
-
const toast =
|
|
25
|
+
const toast = useDaeryunTalkToast();
|
|
26
26
|
const resetTimerAndState = () => {
|
|
27
27
|
if (timerId)
|
|
28
28
|
clearInterval(timerId);
|
|
@@ -3,9 +3,8 @@ import Input2 from '../_ui/inputs/Input2';
|
|
|
3
3
|
import { formatSecondsToMMSS, nameFilter, onlyNumbers, phoneCheck } from '../_lib/utils';
|
|
4
4
|
import Button2 from '../_ui/buttons/Button2';
|
|
5
5
|
import { historyPhoneAuth, requestPhone } from '../_api';
|
|
6
|
-
import { useDearyunTalkToast } from '../Toast/DaeryuntalkToastProvider';
|
|
7
|
-
import { isSetIterator } from 'util/types';
|
|
8
6
|
import { AuthErrorCode } from '../_enums/error_code';
|
|
7
|
+
import { useDaeryunTalkToast } from '../Toast/DaeryuntalkToastProvider';
|
|
9
8
|
|
|
10
9
|
interface IProps {
|
|
11
10
|
goGetHistoryList: (data: { version?: string }) => void;
|
|
@@ -19,8 +18,7 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
|
|
|
19
18
|
const [timerId, setTimerId] = useState<NodeJS.Timeout | null>(null);
|
|
20
19
|
const [isLoading, setIsLoading] = useState(false);
|
|
21
20
|
|
|
22
|
-
const toast =
|
|
23
|
-
|
|
21
|
+
const toast = useDaeryunTalkToast();
|
|
24
22
|
const resetTimerAndState = () => {
|
|
25
23
|
if (timerId) clearInterval(timerId);
|
|
26
24
|
setTimer(180);
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
export type ToastType = 'success' | 'warning' | 'error';
|
|
3
|
+
interface ToastItem {
|
|
4
|
+
type: ToastType;
|
|
5
|
+
title: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
duration?: number;
|
|
8
|
+
}
|
|
2
9
|
interface ToastContextProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
10
|
+
toast: ToastItem | null;
|
|
11
|
+
isVisible: boolean;
|
|
12
|
+
hideToast: () => void;
|
|
13
|
+
success: (title: string, desc?: string, duration?: number) => void;
|
|
14
|
+
warning: (title: string, desc?: string, duration?: number) => void;
|
|
15
|
+
error: (title: string, desc?: string, duration?: number) => void;
|
|
6
16
|
}
|
|
7
|
-
export declare const
|
|
8
|
-
|
|
17
|
+
export declare const ToastContext: import("react").Context<ToastContextProps | undefined>;
|
|
18
|
+
export declare const useDaeryunTalkToast: () => ToastContextProps;
|
|
19
|
+
export declare const DaeryuntalkToastProvider: ({ children }: {
|
|
9
20
|
children: ReactNode;
|
|
10
|
-
}
|
|
11
|
-
export declare const DaeryuntalkToastProvider: ({ children }: ToastProviderProps) => import("react").JSX.Element;
|
|
21
|
+
}) => import("react").JSX.Element;
|
|
12
22
|
export {};
|
|
@@ -1,33 +1,29 @@
|
|
|
1
|
+
// ./Toast/DaeryuntalkToastProvider.tsx
|
|
2
|
+
'use client';
|
|
1
3
|
import { createContext, useContext, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
export const
|
|
4
|
-
const
|
|
5
|
-
if (!
|
|
6
|
-
throw new Error('
|
|
7
|
-
|
|
8
|
-
return context;
|
|
4
|
+
export const ToastContext = createContext(undefined);
|
|
5
|
+
export const useDaeryunTalkToast = () => {
|
|
6
|
+
const ctx = useContext(ToastContext);
|
|
7
|
+
if (!ctx)
|
|
8
|
+
throw new Error('ToastContext가 없습니다.');
|
|
9
|
+
return ctx;
|
|
9
10
|
};
|
|
10
|
-
const ToastContext = createContext(undefined);
|
|
11
11
|
export const DaeryuntalkToastProvider = ({ children }) => {
|
|
12
12
|
const [toast, setToast] = useState(null);
|
|
13
13
|
const [isVisible, setIsVisible] = useState(false);
|
|
14
|
+
const hideToast = () => setIsVisible(false);
|
|
14
15
|
const showToast = (type, title, description, duration = 3000) => {
|
|
15
16
|
setToast({ type, title, description, duration });
|
|
16
17
|
setIsVisible(true);
|
|
17
18
|
setTimeout(() => {
|
|
18
19
|
setIsVisible(false);
|
|
19
|
-
setTimeout(() => setToast(null), 300);
|
|
20
|
+
setTimeout(() => setToast(null), 300);
|
|
20
21
|
}, duration);
|
|
21
22
|
};
|
|
22
|
-
const success = (title,
|
|
23
|
-
const warning = (title,
|
|
24
|
-
const error = (title,
|
|
25
|
-
return (<ToastContext.Provider value={{ success, warning, error }}>
|
|
23
|
+
const success = (title, d, t) => showToast('success', title, d, t);
|
|
24
|
+
const warning = (title, d, t) => showToast('warning', title, d, t);
|
|
25
|
+
const error = (title, d, t) => showToast('error', title, d, t);
|
|
26
|
+
return (<ToastContext.Provider value={{ toast, isVisible, hideToast, success, warning, error }}>
|
|
26
27
|
{children}
|
|
27
|
-
<div className="absolute bottom-0 left-1/2 z-50 w-[90%] -translate-x-1/2 rounded-[25px]">
|
|
28
|
-
<div className={`transition-all duration-300 ${isVisible ? '-translate-y-[96px] opacity-100' : 'pointer-events-none translate-y-0 opacity-0'}`}>
|
|
29
|
-
{toast && <DaeryunTalkToast {...toast} onClose={() => setIsVisible(false)}/>}
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
28
|
</ToastContext.Provider>);
|
|
33
29
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type ToastType = 'success' | 'warning' | 'error';
|
|
1
|
+
// ./Toast/DaeryuntalkToastProvider.tsx
|
|
2
|
+
'use client';
|
|
5
3
|
|
|
4
|
+
import { createContext, useContext, useState, ReactNode } from 'react';
|
|
5
|
+
export type ToastType = 'success' | 'warning' | 'error';
|
|
6
6
|
interface ToastItem {
|
|
7
7
|
type: ToastType;
|
|
8
8
|
title: string;
|
|
@@ -11,57 +11,44 @@ interface ToastItem {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
interface ToastContextProps {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
toast: ToastItem | null;
|
|
15
|
+
isVisible: boolean;
|
|
16
|
+
hideToast: () => void;
|
|
17
|
+
success: (title: string, desc?: string, duration?: number) => void;
|
|
18
|
+
warning: (title: string, desc?: string, duration?: number) => void;
|
|
19
|
+
error: (title: string, desc?: string, duration?: number) => void;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
export const
|
|
20
|
-
const context = useContext(ToastContext);
|
|
21
|
-
if (!context) {
|
|
22
|
-
throw new Error('토스트 프로바이더 설정이 필요합니다.');
|
|
23
|
-
}
|
|
24
|
-
return context;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const ToastContext = createContext<ToastContextProps | undefined>(undefined);
|
|
22
|
+
export const ToastContext = createContext<ToastContextProps | undefined>(undefined);
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
export const useDaeryunTalkToast = () => {
|
|
25
|
+
const ctx = useContext(ToastContext);
|
|
26
|
+
if (!ctx) throw new Error('ToastContext가 없습니다.');
|
|
27
|
+
return ctx;
|
|
28
|
+
};
|
|
32
29
|
|
|
33
|
-
export const DaeryuntalkToastProvider = ({ children }:
|
|
30
|
+
export const DaeryuntalkToastProvider = ({ children }: { children: ReactNode }) => {
|
|
34
31
|
const [toast, setToast] = useState<ToastItem | null>(null);
|
|
35
32
|
const [isVisible, setIsVisible] = useState(false);
|
|
36
33
|
|
|
37
|
-
const
|
|
34
|
+
const hideToast = () => setIsVisible(false);
|
|
35
|
+
|
|
36
|
+
const showToast = (type: ToastType, title: string, description?: string, duration = 3000) => {
|
|
38
37
|
setToast({ type, title, description, duration });
|
|
39
38
|
setIsVisible(true);
|
|
40
39
|
setTimeout(() => {
|
|
41
40
|
setIsVisible(false);
|
|
42
|
-
setTimeout(() => setToast(null), 300);
|
|
41
|
+
setTimeout(() => setToast(null), 300);
|
|
43
42
|
}, duration);
|
|
44
43
|
};
|
|
45
44
|
|
|
46
|
-
const success = (title: string,
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
showToast('warning', title, description, duration);
|
|
50
|
-
const error = (title: string, description?: string, duration?: number) =>
|
|
51
|
-
showToast('error', title, description, duration);
|
|
45
|
+
const success = (title: string, d?: string, t?: number) => showToast('success', title, d, t);
|
|
46
|
+
const warning = (title: string, d?: string, t?: number) => showToast('warning', title, d, t);
|
|
47
|
+
const error = (title: string, d?: string, t?: number) => showToast('error', title, d, t);
|
|
52
48
|
|
|
53
49
|
return (
|
|
54
|
-
<ToastContext.Provider value={{ success, warning, error }}>
|
|
50
|
+
<ToastContext.Provider value={{ toast, isVisible, hideToast, success, warning, error }}>
|
|
55
51
|
{children}
|
|
56
|
-
<div className="absolute bottom-0 left-1/2 z-50 w-[90%] -translate-x-1/2 rounded-[25px]">
|
|
57
|
-
<div
|
|
58
|
-
className={`transition-all duration-300 ${
|
|
59
|
-
isVisible ? '-translate-y-[96px] opacity-100' : 'pointer-events-none translate-y-0 opacity-0'
|
|
60
|
-
}`}
|
|
61
|
-
>
|
|
62
|
-
{toast && <DaeryunTalkToast {...toast} onClose={() => setIsVisible(false)} />}
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
52
|
</ToastContext.Provider>
|
|
66
53
|
);
|
|
67
54
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ToastRenderer(): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// ./Toast/ToastRenderer.tsx
|
|
2
|
+
'use client';
|
|
3
|
+
import { useContext } from 'react';
|
|
4
|
+
import { ToastContext } from './DaeryuntalkToastProvider';
|
|
5
|
+
import DaeryunTalkToast from './Toast';
|
|
6
|
+
export default function ToastRenderer() {
|
|
7
|
+
const context = useContext(ToastContext);
|
|
8
|
+
if (!context)
|
|
9
|
+
return null;
|
|
10
|
+
const { toast, isVisible, hideToast } = context;
|
|
11
|
+
console.log('isVisible', isVisible);
|
|
12
|
+
return (<div className="absolute bottom-0 left-1/2 z-[50] w-[90%] -translate-x-1/2">
|
|
13
|
+
<div className={`transition-all duration-300 ${isVisible ? '-translate-y-[96px] opacity-100' : 'pointer-events-none translate-y-0 opacity-0'}`}>
|
|
14
|
+
{toast && <DaeryunTalkToast {...toast} onClose={hideToast}/>}
|
|
15
|
+
</div>
|
|
16
|
+
</div>);
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// ./Toast/ToastRenderer.tsx
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { ToastContext } from './DaeryuntalkToastProvider';
|
|
6
|
+
import DaeryunTalkToast from './Toast';
|
|
7
|
+
|
|
8
|
+
export default function ToastRenderer() {
|
|
9
|
+
const context = useContext(ToastContext);
|
|
10
|
+
|
|
11
|
+
if (!context) return null;
|
|
12
|
+
|
|
13
|
+
const { toast, isVisible, hideToast } = context;
|
|
14
|
+
console.log('isVisible', isVisible);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className="absolute bottom-0 left-1/2 z-[50] w-[90%] -translate-x-1/2">
|
|
18
|
+
<div
|
|
19
|
+
className={`transition-all duration-300 ${
|
|
20
|
+
isVisible ? '-translate-y-[96px] opacity-100' : 'pointer-events-none translate-y-0 opacity-0'
|
|
21
|
+
}`}
|
|
22
|
+
>
|
|
23
|
+
{toast && <DaeryunTalkToast {...toast} onClose={hideToast} />}
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -36,12 +36,6 @@ export declare const useChatHandler: ({ setIsLoading, inquiryMainData, setChatIn
|
|
|
36
36
|
cellPhoneNumber: string;
|
|
37
37
|
}) => Promise<void>;
|
|
38
38
|
getNextMessageList: (chatInquiryNumber: string, standardDateTime: any) => Promise<void>;
|
|
39
|
-
getDownLoadUrl: ({ chatInquiryNumber, fileNumber }: {
|
|
40
|
-
chatInquiryNumber: string;
|
|
41
|
-
fileNumber: string;
|
|
42
|
-
}) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<{
|
|
43
|
-
url: string;
|
|
44
|
-
}>>;
|
|
45
39
|
startSelectedChat: (chatInquiryNumber: string) => Promise<string>;
|
|
46
40
|
};
|
|
47
41
|
export {};
|