@daeryun/dr_components 0.7.79 → 0.7.81
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/download.svg +5 -0
- package/dist/asset/images/daeryuntalk/firstGo.svg +5 -0
- package/dist/asset/images/daeryuntalk/objectBack.svg +4 -0
- package/dist/asset/images/daeryuntalk/viewer/close.svg +4 -0
- package/dist/asset/images/daeryuntalk/viewer/gray-download.svg +7 -0
- package/dist/asset/images/daeryuntalk/viewer/move-button.svg +4 -0
- package/dist/asset/images/daeryuntalk/viewer/rotate.svg +17 -0
- package/dist/asset/images/daeryuntalk/viewer/zoom-in.svg +5 -0
- package/dist/asset/images/daeryuntalk/viewer/zoom-out.svg +6 -0
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/components/Daeryuntalk/ChatButton.jsx +1 -0
- package/dist/components/Daeryuntalk/ChatButton.tsx +1 -0
- package/dist/components/Daeryuntalk/ChatConversation.d.ts +1 -0
- package/dist/components/Daeryuntalk/ChatConversation.jsx +19 -12
- package/dist/components/Daeryuntalk/ChatConversation.tsx +48 -11
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +27 -6
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +39 -8
- package/dist/components/Daeryuntalk/ChatInput.jsx +23 -3
- package/dist/components/Daeryuntalk/ChatInput.tsx +26 -10
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.d.ts +10 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.jsx +186 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.tsx +252 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatPrivacyAuth.d.ts +8 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatPrivacyAuth.jsx +87 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatPrivacyAuth.tsx +115 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.d.ts +8 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.jsx +13 -0
- package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.tsx +25 -0
- package/dist/components/Daeryuntalk/ChatItem/RichText.d.ts +7 -0
- package/dist/components/Daeryuntalk/ChatItem/RichText.jsx +25 -0
- package/dist/components/Daeryuntalk/ChatItem/RichText.tsx +32 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowAuthForm.d.ts +8 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowAuthForm.jsx +19 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowAuthForm.tsx +31 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.d.ts +7 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.jsx +20 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.tsx +36 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.d.ts +7 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.jsx +9 -0
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.tsx +16 -0
- package/dist/components/Daeryuntalk/ChatMessage.d.ts +11 -1
- package/dist/components/Daeryuntalk/ChatMessage.jsx +116 -14
- package/dist/components/Daeryuntalk/ChatMessage.tsx +175 -20
- package/dist/components/Daeryuntalk/ChatObject/ObjectBack.d.ts +7 -0
- package/dist/components/Daeryuntalk/ChatObject/ObjectBack.jsx +16 -0
- package/dist/components/Daeryuntalk/ChatObject/ObjectBack.tsx +28 -0
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.d.ts +10 -0
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.jsx +118 -0
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.tsx +162 -0
- package/dist/components/Daeryuntalk/ChatWidget.jsx +7 -3
- package/dist/components/Daeryuntalk/ChatWidget.tsx +9 -5
- package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +37 -5
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +71 -157
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +128 -189
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.d.ts +17 -0
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.jsx +57 -0
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.tsx +82 -0
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.d.ts +3 -0
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +172 -0
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +236 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +133 -0
- package/dist/{lib/api → components/Daeryuntalk/_api}/daeryuntalk/index.js +251 -46
- package/dist/{lib/api → components/Daeryuntalk/_api}/daeryuntalk/index.ts +353 -129
- package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.d.ts +115 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.js +1 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.ts +135 -0
- package/dist/components/Daeryuntalk/_enums/ask-status.d.ts +6 -0
- package/dist/components/Daeryuntalk/_enums/ask-status.js +11 -0
- package/dist/components/Daeryuntalk/_enums/ask-status.ts +11 -0
- package/dist/components/Daeryuntalk/_enums/message_type.d.ts +6 -0
- package/dist/components/Daeryuntalk/_enums/message_type.js +13 -0
- package/dist/components/Daeryuntalk/_enums/message_type.ts +13 -0
- package/dist/components/Daeryuntalk/_enums/sender_type.d.ts +8 -0
- package/dist/components/Daeryuntalk/_enums/sender_type.js +16 -0
- package/dist/components/Daeryuntalk/_enums/sender_type.ts +16 -0
- package/dist/components/Daeryuntalk/_enums/socket_type.d.ts +22 -0
- package/dist/components/Daeryuntalk/_enums/socket_type.js +23 -0
- package/dist/components/Daeryuntalk/_enums/socket_type.ts +31 -0
- package/dist/components/Daeryuntalk/_enums/template.d.ts +32 -0
- package/dist/components/Daeryuntalk/_enums/template.js +49 -0
- package/dist/components/Daeryuntalk/_enums/template.ts +53 -0
- package/dist/components/Daeryuntalk/_enums/work_flow_object_expose.d.ts +34 -0
- package/dist/components/Daeryuntalk/_enums/work_flow_object_expose.js +66 -0
- package/dist/components/Daeryuntalk/_enums/work_flow_object_expose.ts +69 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +46 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +296 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +364 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.d.ts +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.js +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.ts +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.d.ts +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.js +22 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.ts +30 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +21 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +205 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +240 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useViewerHook.d.ts +8 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useViewerHook.js +18 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useViewerHook.ts +23 -0
- package/dist/components/Daeryuntalk/_lib/index.d.ts +7 -0
- package/dist/components/Daeryuntalk/_lib/index.js +101 -0
- package/dist/components/Daeryuntalk/_lib/index.ts +137 -0
- package/dist/components/Daeryuntalk/_lib/utils.d.ts +2 -0
- package/dist/components/Daeryuntalk/_lib/utils.js +16 -0
- package/dist/components/Daeryuntalk/_lib/utils.ts +17 -0
- package/dist/components/Daeryuntalk/{types.d.ts → _types/message.d.ts} +33 -17
- package/dist/components/Daeryuntalk/_types/message.js +19 -0
- package/dist/components/Daeryuntalk/{types.ts → _types/message.ts} +64 -19
- package/dist/components/Daeryuntalk/_types/message_object.d.ts +16 -0
- package/dist/components/Daeryuntalk/_types/message_object.js +1 -0
- package/dist/components/Daeryuntalk/_types/message_object.ts +20 -0
- package/dist/components/Daeryuntalk/_types/socket/message.d.ts +0 -0
- package/dist/components/Daeryuntalk/_types/socket/message.js +1 -0
- package/dist/components/Daeryuntalk/_types/socket/message.ts +0 -0
- package/dist/components/Daeryuntalk/_types/socket/workflow.d.ts +15 -0
- package/dist/components/Daeryuntalk/_types/socket/workflow.js +1 -0
- package/dist/components/Daeryuntalk/_types/socket/workflow.ts +15 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button1.d.ts +10 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button1.jsx +11 -0
- package/dist/components/Daeryuntalk/_ui/buttons/Button1.tsx +28 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input1.d.ts +12 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input1.jsx +9 -0
- package/dist/components/Daeryuntalk/_ui/inputs/Input1.tsx +39 -0
- package/dist/components/Daeryuntalk/index.tsx +1 -0
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.ts +1 -1
- package/dist/styles/globals.css +161 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -2
- package/dist/components/Daeryuntalk/types.js +0 -8
- package/dist/lib/api/daeryuntalk/index.d.ts +0 -143
- /package/dist/{lib/api → components/Daeryuntalk/_api}/index.d.ts +0 -0
- /package/dist/{lib/api → components/Daeryuntalk/_api}/index.js +0 -0
- /package/dist/{lib/api → components/Daeryuntalk/_api}/index.ts +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React, { useState, useEffect } from 'react';
|
|
11
|
+
import Image from 'next/image';
|
|
12
|
+
import { getMessageFileDownloadUrl } from '../_api';
|
|
13
|
+
import { useDaeryuntalk } from '../DaeryuntalkContext';
|
|
14
|
+
import RotateCCWIcon from '../../../asset/images/daeryuntalk/viewer/rotate.svg';
|
|
15
|
+
import ZoomOutIcon from '../../../asset/images/daeryuntalk/viewer/zoom-out.svg';
|
|
16
|
+
import ZoomInIcon from '../../../asset/images/daeryuntalk/viewer/zoom-in.svg';
|
|
17
|
+
import DownloadIcon from '../../../asset/images/daeryuntalk/download.svg';
|
|
18
|
+
import CloseIcon from '../../../asset/images/daeryuntalk/viewer/close.svg';
|
|
19
|
+
import MoveSwipingIcon from '../../../asset/images/daeryuntalk/viewer/move-button.svg';
|
|
20
|
+
import DaeryunLogoIcon from '../../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
21
|
+
import { formatDateToKorean } from '../_lib/utils';
|
|
22
|
+
const ZOOM_LEVELS = [25, 50, 75, 100, 125, 150, 200];
|
|
23
|
+
const ImageViewer = () => {
|
|
24
|
+
var _a;
|
|
25
|
+
const { isImageViewerOpen, selectedImageFile, imageViewerMessage, closeImageViewer } = useDaeryuntalk();
|
|
26
|
+
const images = ((_a = imageViewerMessage === null || imageViewerMessage === void 0 ? void 0 : imageViewerMessage.files) === null || _a === void 0 ? void 0 : _a.filter(item => item.type === 'image')) || [];
|
|
27
|
+
const initialIndex = images.findIndex(img => img.fileNumber === (selectedImageFile === null || selectedImageFile === void 0 ? void 0 : selectedImageFile.fileNumber));
|
|
28
|
+
const [currentIndex, setCurrentIndex] = useState(initialIndex >= 0 ? initialIndex : 0);
|
|
29
|
+
const [rotation, setRotation] = useState(0);
|
|
30
|
+
const [zoomLevel, setZoomLevel] = useState(3);
|
|
31
|
+
const [previewImages, setPreviewImages] = useState([]);
|
|
32
|
+
const currentImage = previewImages[currentIndex];
|
|
33
|
+
const currentZoom = ZOOM_LEVELS[zoomLevel];
|
|
34
|
+
// 모든 이미지 URL 미리 생성
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!imageViewerMessage || images.length === 0)
|
|
37
|
+
return;
|
|
38
|
+
const fetchAllUrls = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
const results = yield Promise.all(images.map((file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const res = yield getMessageFileDownloadUrl({
|
|
41
|
+
chatInquiryNumber: imageViewerMessage.inquiryNumber || '',
|
|
42
|
+
fileNumber: file.fileNumber
|
|
43
|
+
});
|
|
44
|
+
return { file, url: res.data.url };
|
|
45
|
+
})));
|
|
46
|
+
setPreviewImages(results);
|
|
47
|
+
});
|
|
48
|
+
fetchAllUrls();
|
|
49
|
+
}, [imageViewerMessage, selectedImageFile]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
setCurrentIndex(initialIndex >= 0 ? initialIndex : 0);
|
|
52
|
+
setRotation(0);
|
|
53
|
+
setZoomLevel(3);
|
|
54
|
+
}, [selectedImageFile]);
|
|
55
|
+
const rotateImage = () => setRotation(prev => (prev + 90) % 360);
|
|
56
|
+
const zoomIn = () => setZoomLevel(prev => (prev < ZOOM_LEVELS.length - 1 ? prev + 1 : prev));
|
|
57
|
+
const zoomOut = () => setZoomLevel(prev => (prev > 0 ? prev - 1 : prev));
|
|
58
|
+
const handleDownload = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
var _a;
|
|
60
|
+
if (!currentImage || !imageViewerMessage)
|
|
61
|
+
return;
|
|
62
|
+
try {
|
|
63
|
+
const res = yield getMessageFileDownloadUrl({
|
|
64
|
+
chatInquiryNumber: imageViewerMessage.inquiryNumber || '',
|
|
65
|
+
fileNumber: currentImage.file.fileNumber
|
|
66
|
+
});
|
|
67
|
+
const filePath = res.data.url;
|
|
68
|
+
const response = yield fetch(filePath);
|
|
69
|
+
const blob = yield response.blob();
|
|
70
|
+
const url = window.URL.createObjectURL(blob);
|
|
71
|
+
const link = document.createElement('a');
|
|
72
|
+
link.href = url;
|
|
73
|
+
link.download = ((_a = currentImage.file) === null || _a === void 0 ? void 0 : _a.name) || '';
|
|
74
|
+
document.body.appendChild(link);
|
|
75
|
+
link.click();
|
|
76
|
+
window.URL.revokeObjectURL(url);
|
|
77
|
+
document.body.removeChild(link);
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
console.error('다운로드 URL 요청 실패:', err);
|
|
81
|
+
// 사용자에게 알림 또는 토스트 표시 등을 추가할 수 있습니다.
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const handleBackdropClick = (e) => {
|
|
85
|
+
if (e.target === e.currentTarget)
|
|
86
|
+
closeImageViewer === null || closeImageViewer === void 0 ? void 0 : closeImageViewer();
|
|
87
|
+
};
|
|
88
|
+
if (!isImageViewerOpen || !currentImage)
|
|
89
|
+
return null;
|
|
90
|
+
return (<div className="fixed inset-0 z-[999999] flex flex-col items-center justify-center bg-black/90" onClick={handleBackdropClick}>
|
|
91
|
+
<div className={`flex flex-col items-center justify-center gap-[60px]`}>
|
|
92
|
+
{/* Main Image + Toolbar */}
|
|
93
|
+
<div className="group relative flex max-h-[80vh] max-w-[90vw] items-center justify-center">
|
|
94
|
+
{currentIndex > 0 && (<button onClick={() => setCurrentIndex(prev => prev - 1)} className="absolute left-[-68px] rotate-180 text-3xl text-white">
|
|
95
|
+
<MoveSwipingIcon />
|
|
96
|
+
</button>)}
|
|
97
|
+
|
|
98
|
+
<div className="relative h-[500px] w-[800px]" // width 고정
|
|
99
|
+
style={{
|
|
100
|
+
transform: `rotate(${rotation}deg) scale(${currentZoom / 100})`,
|
|
101
|
+
transformOrigin: 'center center',
|
|
102
|
+
transition: 'transform 0.2s ease'
|
|
103
|
+
// maxWidth: '800px',
|
|
104
|
+
// maxHeight: '500px'
|
|
105
|
+
}}>
|
|
106
|
+
<Image src={currentImage.url} alt={currentImage.file.name} width={800} height={500} className="h-full w-full object-contain" unoptimized style={{
|
|
107
|
+
// maxWidth: '800px',
|
|
108
|
+
// maxHeight: '500px'
|
|
109
|
+
}}/>
|
|
110
|
+
{/* Close Button - Top Right */}
|
|
111
|
+
<button onClick={closeImageViewer} className="absolute right-[20px] top-[20px] z-10">
|
|
112
|
+
<CloseIcon className="h-6 w-6"/>
|
|
113
|
+
</button>
|
|
114
|
+
|
|
115
|
+
{/* Hover Toolbar */}
|
|
116
|
+
<div className="absolute bottom-0 left-1/2 w-full -translate-x-1/2 opacity-0 transition-opacity duration-300 group-hover:opacity-100">
|
|
117
|
+
<div className="mx-auto flex h-[68px] max-w-[800px] items-center justify-between bg-black/70 p-[20px] text-white">
|
|
118
|
+
<div className="flex items-center gap-[20px]">
|
|
119
|
+
<div className={`flex items-center gap-[10px]`}>
|
|
120
|
+
<div className="flex-shrink-0 rounded-full">
|
|
121
|
+
<div className="relative h-full w-full">
|
|
122
|
+
<DaeryunLogoIcon width={28} height={28}/>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
<div>법무법인(유한)대륜</div>
|
|
126
|
+
</div>
|
|
127
|
+
<div>|</div>
|
|
128
|
+
<span className="font-[700] leading-[100%] tracking-[-4%]">
|
|
129
|
+
{formatDateToKorean((imageViewerMessage === null || imageViewerMessage === void 0 ? void 0 : imageViewerMessage.createdAt.toString()) || '')}
|
|
130
|
+
</span>
|
|
131
|
+
</div>
|
|
132
|
+
<div className={`flex flex-row gap-[20px]`}>
|
|
133
|
+
<button onClick={rotateImage}>
|
|
134
|
+
<RotateCCWIcon />
|
|
135
|
+
</button>
|
|
136
|
+
<button onClick={zoomOut} disabled={zoomLevel === 0} className={`${zoomLevel === 0 ? 'cursor-not-allowed opacity-50' : 'hover:opacity-80'} transition`}>
|
|
137
|
+
<ZoomOutIcon />
|
|
138
|
+
</button>
|
|
139
|
+
<button onClick={zoomIn} disabled={zoomLevel === ZOOM_LEVELS.length - 1} className={`${zoomLevel === ZOOM_LEVELS.length - 1
|
|
140
|
+
? 'cursor-not-allowed opacity-50'
|
|
141
|
+
: 'hover:opacity-80'} transition`}>
|
|
142
|
+
<ZoomInIcon />
|
|
143
|
+
</button>
|
|
144
|
+
<button onClick={handleDownload}>
|
|
145
|
+
<DownloadIcon className="bg-transparent text-white"/>
|
|
146
|
+
</button>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
{currentIndex < previewImages.length - 1 && (<button onClick={() => setCurrentIndex(prev => prev + 1)} className="absolute right-[-68px] text-3xl text-white">
|
|
153
|
+
<MoveSwipingIcon />
|
|
154
|
+
</button>)}
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
{/* Thumbnail Preview */}
|
|
158
|
+
{previewImages.length > 1 && (<div className="flex flex-row gap-[10px]">
|
|
159
|
+
{previewImages.map((img, idx) => (<div key={img.file.fileNumber} onClick={() => {
|
|
160
|
+
setCurrentIndex(idx);
|
|
161
|
+
setRotation(0);
|
|
162
|
+
setZoomLevel(3);
|
|
163
|
+
}} className={`h-[60px] w-[96px] shrink-0 cursor-pointer overflow-hidden rounded-[10px] border-[1px]
|
|
164
|
+
|
|
165
|
+
${idx === currentIndex ? 'border-white' : 'border-transparent opacity-50 hover:opacity-100'}`}>
|
|
166
|
+
<Image src={img.file.thumbnailUrl} alt={img.file.name} width={96} height={60} className="h-full w-full object-cover" unoptimized/>
|
|
167
|
+
</div>))}
|
|
168
|
+
</div>)}
|
|
169
|
+
</div>
|
|
170
|
+
</div>);
|
|
171
|
+
};
|
|
172
|
+
export default ImageViewer;
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import Image from 'next/image';
|
|
3
|
+
import { getMessageFileDownloadUrl } from '../_api';
|
|
4
|
+
import { useDaeryuntalk } from '../DaeryuntalkContext';
|
|
5
|
+
import { FileInfo } from '../_types/message';
|
|
6
|
+
import RotateCCWIcon from '../../../asset/images/daeryuntalk/viewer/rotate.svg';
|
|
7
|
+
import ZoomOutIcon from '../../../asset/images/daeryuntalk/viewer/zoom-out.svg';
|
|
8
|
+
import ZoomInIcon from '../../../asset/images/daeryuntalk/viewer/zoom-in.svg';
|
|
9
|
+
import DownloadIcon from '../../../asset/images/daeryuntalk/download.svg';
|
|
10
|
+
import CloseIcon from '../../../asset/images/daeryuntalk/viewer/close.svg';
|
|
11
|
+
import MoveSwipingIcon from '../../../asset/images/daeryuntalk/viewer/move-button.svg';
|
|
12
|
+
import DaeryunLogoIcon from '../../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
13
|
+
import { formatDateToKorean } from '../_lib/utils';
|
|
14
|
+
|
|
15
|
+
const ZOOM_LEVELS = [25, 50, 75, 100, 125, 150, 200];
|
|
16
|
+
|
|
17
|
+
type PreviewImage = {
|
|
18
|
+
file: FileInfo;
|
|
19
|
+
url: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const ImageViewer = () => {
|
|
23
|
+
const { isImageViewerOpen, selectedImageFile, imageViewerMessage, closeImageViewer } = useDaeryuntalk();
|
|
24
|
+
|
|
25
|
+
const images = imageViewerMessage?.files?.filter(item => item.type === 'image') || [];
|
|
26
|
+
const initialIndex = images.findIndex(img => img.fileNumber === selectedImageFile?.fileNumber);
|
|
27
|
+
|
|
28
|
+
const [currentIndex, setCurrentIndex] = useState(initialIndex >= 0 ? initialIndex : 0);
|
|
29
|
+
const [rotation, setRotation] = useState(0);
|
|
30
|
+
const [zoomLevel, setZoomLevel] = useState(3);
|
|
31
|
+
const [previewImages, setPreviewImages] = useState<PreviewImage[]>([]);
|
|
32
|
+
|
|
33
|
+
const currentImage = previewImages[currentIndex];
|
|
34
|
+
const currentZoom = ZOOM_LEVELS[zoomLevel];
|
|
35
|
+
|
|
36
|
+
// 모든 이미지 URL 미리 생성
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!imageViewerMessage || images.length === 0) return;
|
|
39
|
+
|
|
40
|
+
const fetchAllUrls = async () => {
|
|
41
|
+
const results: PreviewImage[] = await Promise.all(
|
|
42
|
+
images.map(async file => {
|
|
43
|
+
const res = await getMessageFileDownloadUrl({
|
|
44
|
+
chatInquiryNumber: imageViewerMessage.inquiryNumber || '',
|
|
45
|
+
fileNumber: file.fileNumber
|
|
46
|
+
});
|
|
47
|
+
return { file, url: res.data.url };
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
setPreviewImages(results);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
fetchAllUrls();
|
|
54
|
+
}, [imageViewerMessage, selectedImageFile]);
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
setCurrentIndex(initialIndex >= 0 ? initialIndex : 0);
|
|
58
|
+
setRotation(0);
|
|
59
|
+
setZoomLevel(3);
|
|
60
|
+
}, [selectedImageFile]);
|
|
61
|
+
|
|
62
|
+
const rotateImage = () => setRotation(prev => (prev + 90) % 360);
|
|
63
|
+
const zoomIn = () => setZoomLevel(prev => (prev < ZOOM_LEVELS.length - 1 ? prev + 1 : prev));
|
|
64
|
+
const zoomOut = () => setZoomLevel(prev => (prev > 0 ? prev - 1 : prev));
|
|
65
|
+
|
|
66
|
+
const handleDownload = async () => {
|
|
67
|
+
if (!currentImage || !imageViewerMessage) return;
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
const res = await getMessageFileDownloadUrl({
|
|
71
|
+
chatInquiryNumber: imageViewerMessage.inquiryNumber || '',
|
|
72
|
+
fileNumber: currentImage.file.fileNumber
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const filePath = res.data.url;
|
|
76
|
+
const response = await fetch(filePath);
|
|
77
|
+
const blob = await response.blob();
|
|
78
|
+
|
|
79
|
+
const url = window.URL.createObjectURL(blob);
|
|
80
|
+
const link = document.createElement('a');
|
|
81
|
+
link.href = url;
|
|
82
|
+
link.download = currentImage.file?.name || '';
|
|
83
|
+
document.body.appendChild(link);
|
|
84
|
+
link.click();
|
|
85
|
+
window.URL.revokeObjectURL(url);
|
|
86
|
+
document.body.removeChild(link);
|
|
87
|
+
} catch (err) {
|
|
88
|
+
console.error('다운로드 URL 요청 실패:', err);
|
|
89
|
+
// 사용자에게 알림 또는 토스트 표시 등을 추가할 수 있습니다.
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const handleBackdropClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
94
|
+
if (e.target === e.currentTarget) closeImageViewer?.();
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
if (!isImageViewerOpen || !currentImage) return null;
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<div
|
|
101
|
+
className="fixed inset-0 z-[999999] flex flex-col items-center justify-center bg-black/90"
|
|
102
|
+
onClick={handleBackdropClick}
|
|
103
|
+
>
|
|
104
|
+
<div className={`flex flex-col items-center justify-center gap-[60px]`}>
|
|
105
|
+
{/* Main Image + Toolbar */}
|
|
106
|
+
<div className="group relative flex max-h-[80vh] max-w-[90vw] items-center justify-center">
|
|
107
|
+
{currentIndex > 0 && (
|
|
108
|
+
<button
|
|
109
|
+
onClick={() => setCurrentIndex(prev => prev - 1)}
|
|
110
|
+
className="absolute left-[-68px] rotate-180 text-3xl text-white"
|
|
111
|
+
>
|
|
112
|
+
<MoveSwipingIcon />
|
|
113
|
+
</button>
|
|
114
|
+
)}
|
|
115
|
+
|
|
116
|
+
<div
|
|
117
|
+
className="relative h-[500px] w-[800px]" // width 고정
|
|
118
|
+
style={{
|
|
119
|
+
transform: `rotate(${rotation}deg) scale(${currentZoom / 100})`,
|
|
120
|
+
transformOrigin: 'center center',
|
|
121
|
+
transition: 'transform 0.2s ease'
|
|
122
|
+
// maxWidth: '800px',
|
|
123
|
+
// maxHeight: '500px'
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
<Image
|
|
127
|
+
src={currentImage.url}
|
|
128
|
+
alt={currentImage.file.name}
|
|
129
|
+
width={800}
|
|
130
|
+
height={500}
|
|
131
|
+
className="h-full w-full object-contain"
|
|
132
|
+
unoptimized
|
|
133
|
+
style={
|
|
134
|
+
{
|
|
135
|
+
// maxWidth: '800px',
|
|
136
|
+
// maxHeight: '500px'
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/>
|
|
140
|
+
{/* Close Button - Top Right */}
|
|
141
|
+
<button onClick={closeImageViewer} className="absolute right-[20px] top-[20px] z-10">
|
|
142
|
+
<CloseIcon className="h-6 w-6" />
|
|
143
|
+
</button>
|
|
144
|
+
|
|
145
|
+
{/* Hover Toolbar */}
|
|
146
|
+
<div className="absolute bottom-0 left-1/2 w-full -translate-x-1/2 opacity-0 transition-opacity duration-300 group-hover:opacity-100">
|
|
147
|
+
<div className="mx-auto flex h-[68px] max-w-[800px] items-center justify-between bg-black/70 p-[20px] text-white">
|
|
148
|
+
<div className="flex items-center gap-[20px]">
|
|
149
|
+
<div className={`flex items-center gap-[10px]`}>
|
|
150
|
+
<div className="flex-shrink-0 rounded-full">
|
|
151
|
+
<div className="relative h-full w-full">
|
|
152
|
+
<DaeryunLogoIcon width={28} height={28} />
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
<div>법무법인(유한)대륜</div>
|
|
156
|
+
</div>
|
|
157
|
+
<div>|</div>
|
|
158
|
+
<span className="font-[700] leading-[100%] tracking-[-4%]">
|
|
159
|
+
{formatDateToKorean(imageViewerMessage?.createdAt.toString() || '')}
|
|
160
|
+
</span>
|
|
161
|
+
</div>
|
|
162
|
+
<div className={`flex flex-row gap-[20px]`}>
|
|
163
|
+
<button onClick={rotateImage}>
|
|
164
|
+
<RotateCCWIcon />
|
|
165
|
+
</button>
|
|
166
|
+
<button
|
|
167
|
+
onClick={zoomOut}
|
|
168
|
+
disabled={zoomLevel === 0}
|
|
169
|
+
className={`${
|
|
170
|
+
zoomLevel === 0 ? 'cursor-not-allowed opacity-50' : 'hover:opacity-80'
|
|
171
|
+
} transition`}
|
|
172
|
+
>
|
|
173
|
+
<ZoomOutIcon />
|
|
174
|
+
</button>
|
|
175
|
+
<button
|
|
176
|
+
onClick={zoomIn}
|
|
177
|
+
disabled={zoomLevel === ZOOM_LEVELS.length - 1}
|
|
178
|
+
className={`${
|
|
179
|
+
zoomLevel === ZOOM_LEVELS.length - 1
|
|
180
|
+
? 'cursor-not-allowed opacity-50'
|
|
181
|
+
: 'hover:opacity-80'
|
|
182
|
+
} transition`}
|
|
183
|
+
>
|
|
184
|
+
<ZoomInIcon />
|
|
185
|
+
</button>
|
|
186
|
+
<button onClick={handleDownload}>
|
|
187
|
+
<DownloadIcon className="bg-transparent text-white" />
|
|
188
|
+
</button>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
|
|
194
|
+
{currentIndex < previewImages.length - 1 && (
|
|
195
|
+
<button
|
|
196
|
+
onClick={() => setCurrentIndex(prev => prev + 1)}
|
|
197
|
+
className="absolute right-[-68px] text-3xl text-white"
|
|
198
|
+
>
|
|
199
|
+
<MoveSwipingIcon />
|
|
200
|
+
</button>
|
|
201
|
+
)}
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
{/* Thumbnail Preview */}
|
|
205
|
+
{previewImages.length > 1 && (
|
|
206
|
+
<div className="flex flex-row gap-[10px]">
|
|
207
|
+
{previewImages.map((img, idx) => (
|
|
208
|
+
<div
|
|
209
|
+
key={img.file.fileNumber}
|
|
210
|
+
onClick={() => {
|
|
211
|
+
setCurrentIndex(idx);
|
|
212
|
+
setRotation(0);
|
|
213
|
+
setZoomLevel(3);
|
|
214
|
+
}}
|
|
215
|
+
className={`h-[60px] w-[96px] shrink-0 cursor-pointer overflow-hidden rounded-[10px] border-[1px]
|
|
216
|
+
|
|
217
|
+
${idx === currentIndex ? 'border-white' : 'border-transparent opacity-50 hover:opacity-100'}`}
|
|
218
|
+
>
|
|
219
|
+
<Image
|
|
220
|
+
src={img.file.thumbnailUrl}
|
|
221
|
+
alt={img.file.name}
|
|
222
|
+
width={96}
|
|
223
|
+
height={60}
|
|
224
|
+
className="h-full w-full object-cover"
|
|
225
|
+
unoptimized
|
|
226
|
+
/>
|
|
227
|
+
</div>
|
|
228
|
+
))}
|
|
229
|
+
</div>
|
|
230
|
+
)}
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export default ImageViewer;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Daeryuntalk API 클라이언트 모듈 2025-04-23
|
|
3
|
+
*
|
|
4
|
+
* 이 모듈은 Daeryuntalk 채팅 API와 상호작용하기 위한 함수를 제공
|
|
5
|
+
* 1. 고객 인증
|
|
6
|
+
* 2. 웹소켓 연결 초기화
|
|
7
|
+
* 3. 웹소켓 연결
|
|
8
|
+
* 4. 채팅 문의 관리
|
|
9
|
+
*/
|
|
10
|
+
import { IDaeryunTalkResponseWrapper, WebSocketInitDataResponse, IChatInquiryMainDataResponse, ChatInquiryCreateDataResponse, ChatInquiryDetailDataResponse, SendMessageResponse, ChatInquiryMessageListDataResponse } from './type/response';
|
|
11
|
+
export declare const MESSAGE_TYPES: {
|
|
12
|
+
SYSTEM: string;
|
|
13
|
+
BOT: string;
|
|
14
|
+
CUSTOMER: string;
|
|
15
|
+
OPERATOR: string;
|
|
16
|
+
MACRO: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* 사용자 인증
|
|
20
|
+
* @param version API 버전 (기본값: 1.0.0)
|
|
21
|
+
* @returns 인증 응답
|
|
22
|
+
*/
|
|
23
|
+
export declare function authenticateUser(centerCode: string, version?: string): Promise<any>;
|
|
24
|
+
/**
|
|
25
|
+
* 웹소켓 연결 초기화
|
|
26
|
+
* @param version API 버전 (기본값: 1.0.0)
|
|
27
|
+
* @returns 연결 URL과 토큰이 포함된 웹소켓 초기화 데이터
|
|
28
|
+
*/
|
|
29
|
+
export declare function initializeWebSocket(version?: string): Promise<IDaeryunTalkResponseWrapper<WebSocketInitDataResponse>>;
|
|
30
|
+
/**
|
|
31
|
+
* 웹소켓 연결
|
|
32
|
+
* @param wsUrl 웹소켓 URL
|
|
33
|
+
* @param token 연결 토큰
|
|
34
|
+
* @param onMessage 메시지 핸들러
|
|
35
|
+
* @param onOpen 연결 열림 핸들러
|
|
36
|
+
* @param onClose 연결 닫힘 핸들러
|
|
37
|
+
* @param onError 오류 핸들러
|
|
38
|
+
* @returns 웹소켓 인스턴스
|
|
39
|
+
*/
|
|
40
|
+
export declare function connectWebSocket(wsUrl: string, token: string, onMessage?: (event: MessageEvent) => void, onOpen?: (event: Event) => void, onClose?: (event: CloseEvent) => void, onError?: (event: Event) => void): WebSocket;
|
|
41
|
+
/**
|
|
42
|
+
* 채팅 문의 메인 조회
|
|
43
|
+
* @param channelNumber 전달받은 채널
|
|
44
|
+
* @param version API 버전 (기본값: 1.0.0)
|
|
45
|
+
* @returns 채팅 문의 메인 데이터
|
|
46
|
+
*/
|
|
47
|
+
export declare function getChatInquiryMain(channelNumber: string, version?: string): Promise<IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse>>;
|
|
48
|
+
/**
|
|
49
|
+
* 새 채팅 문의 생성 (개선된 API)
|
|
50
|
+
* @param version API 버전 (기본값: 1.0.0)
|
|
51
|
+
* @returns 문의 번호가 포함된 생성된 채팅 문의 데이터
|
|
52
|
+
*/
|
|
53
|
+
export declare function generateChatInquiry(channelNumber: string, version?: string): Promise<IDaeryunTalkResponseWrapper<ChatInquiryCreateDataResponse>>;
|
|
54
|
+
/**
|
|
55
|
+
* 채팅 문의 상세 조회 (개선된 API)
|
|
56
|
+
* @param chatInquiryNumber 채팅 문의 번호
|
|
57
|
+
* @param version API 버전 (기본값: 1.0.0)
|
|
58
|
+
* @returns 채팅 문의 상세 정보
|
|
59
|
+
*/
|
|
60
|
+
export declare function getChatInquiryDetailNew(chat_inquiry_number: string, version?: string): Promise<IDaeryunTalkResponseWrapper<ChatInquiryDetailDataResponse>>;
|
|
61
|
+
/**
|
|
62
|
+
* 채팅 메세지 목록 조회
|
|
63
|
+
* @param chatInquiryNumber 채팅 문의 번호
|
|
64
|
+
* @param standard_date_time 기준 일시
|
|
65
|
+
* @param size 사이즈
|
|
66
|
+
* @param version API 버전 (기본값: 1.0.0)
|
|
67
|
+
* @returns 채팅 메세지 리스트
|
|
68
|
+
*/
|
|
69
|
+
export declare function getChatInquiryMessageList(chatInquiryNumber: string, standardDateTime?: any, size?: number, version?: string): Promise<IDaeryunTalkResponseWrapper<ChatInquiryMessageListDataResponse>>;
|
|
70
|
+
/**
|
|
71
|
+
* Daeryuntalk 초기화 완료 흐름
|
|
72
|
+
* 이 함수는 인증부터 웹소켓 연결까지 완전한 흐름을 처리
|
|
73
|
+
* @param onWebSocketConnected 웹소켓 연결 시 콜백
|
|
74
|
+
* @param onWebSocketMessage 메시지 핸들러
|
|
75
|
+
* @param version API 버전 (기본값: 1.0.0)
|
|
76
|
+
* @returns 웹소켓 인스턴스 및 문의 데이터
|
|
77
|
+
*/
|
|
78
|
+
export declare function initializeDaeryuntalk(onWebSocketConnected?: (socket: WebSocket) => void, onWebSocketMessage?: (event: MessageEvent) => void, version?: string): Promise<{
|
|
79
|
+
inquiryData?: IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse>;
|
|
80
|
+
socket: WebSocket;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* 채팅 워크플로우 진행 처리
|
|
84
|
+
*
|
|
85
|
+
* @param chatInquiryNumber 채팅 문의 번호 required
|
|
86
|
+
* @param messageNumber 메시지 번호 required
|
|
87
|
+
* @param workFlowNumber 워크플로우 번호 required
|
|
88
|
+
* @param objectNumber 오브젝트 번호 required
|
|
89
|
+
* @param version API 버전 (기본값: 1.0.0)
|
|
90
|
+
* @returns 전송된 메시지 데이터
|
|
91
|
+
*/
|
|
92
|
+
export declare function chatWorkFlow(chatInquiryNumber: string, messageNumber: string, workFlowNumber: string, objectNumber: string, version?: string): Promise<IDaeryunTalkResponseWrapper<SendMessageResponse>>;
|
|
93
|
+
/**
|
|
94
|
+
* 채팅 워크플로우 되돌리기
|
|
95
|
+
*
|
|
96
|
+
* @param chatInquiryNumber 채팅 문의 번호 required
|
|
97
|
+
* @param messageNumber 메시지 번호 required
|
|
98
|
+
* @param workFlowNavigationCode 워크플로우네비게이션코드 번호 required
|
|
99
|
+
* @param version API 버전 (기본값: 1.0.0)
|
|
100
|
+
* @returns 전송된 메시지 데이터
|
|
101
|
+
*/
|
|
102
|
+
export declare function chatWorkFlowBack(chatInquiryNumber: string, messageNumber: string, workFlowNavigationCode: string, version?: string): Promise<IDaeryunTalkResponseWrapper<null>>;
|
|
103
|
+
/**
|
|
104
|
+
* 채팅 메시지 전송
|
|
105
|
+
* @param chatInquiryNumber 채팅 문의 번호
|
|
106
|
+
* @param messageText 메시지 내용
|
|
107
|
+
* @param version API 버전 (기본값: 1.0.0)
|
|
108
|
+
* @returns 전송된 메시지 데이터
|
|
109
|
+
*/
|
|
110
|
+
export declare function sendChatMessage(chatInquiryNumber: string, htmlContent: string, jsonData: any, version?: string): Promise<IDaeryunTalkResponseWrapper<SendMessageResponse>>;
|
|
111
|
+
/**
|
|
112
|
+
* 채팅 개인 정보 업데이트
|
|
113
|
+
* @param chatInquiryNumber 채팅 문의 번호
|
|
114
|
+
* @param messageNumber 해당 채팅 번호
|
|
115
|
+
* @param name 이름
|
|
116
|
+
* @param cellPhoneNumber 전화번호
|
|
117
|
+
* @param version API 버전 (기본값: 1.0.0)
|
|
118
|
+
* @returns 전송된 메시지 데이터
|
|
119
|
+
*/
|
|
120
|
+
export declare function chatUserUpdate(chatInquiryNumber: string, messageNumber: string, name: string, cellPhoneNumber: string, version?: string): Promise<IDaeryunTalkResponseWrapper<any>>;
|
|
121
|
+
/**
|
|
122
|
+
* 채팅문의 메시지 파일 다운로드 URL 생성
|
|
123
|
+
* @param chatInquiryNumber 채팅문의번호
|
|
124
|
+
* @param fileNumber 파일번호
|
|
125
|
+
* @param version
|
|
126
|
+
*/
|
|
127
|
+
export declare const getMessageFileDownloadUrl: ({ chatInquiryNumber, fileNumber, version }: {
|
|
128
|
+
chatInquiryNumber: string;
|
|
129
|
+
fileNumber: string;
|
|
130
|
+
version?: string;
|
|
131
|
+
}) => Promise<IDaeryunTalkResponseWrapper<{
|
|
132
|
+
url: string;
|
|
133
|
+
}>>;
|