@daeryun/dr_components 1.1.4 → 1.1.6
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/Fix/Fix.stories.d.ts +1 -0
- package/dist/components/Fix/index.d.ts +1 -0
- package/dist/components/Fix/index.jsx +2 -2
- package/dist/components/Fix/index.tsx +4 -0
- package/dist/components/page/MyCase/[id]/_component/_document/DocumentLine.jsx +1 -1
- package/dist/components/page/MyCase/[id]/_component/_document/DocumentLine.tsx +1 -1
- package/dist/components/page/MyCase/[id]/_component/_document/FileDropZone.jsx +1 -1
- package/dist/components/page/MyCase/[id]/_component/_document/FileDropZone.tsx +1 -1
- package/dist/components/page/MyCase/_actions/action.d.ts +6 -1
- package/dist/components/page/MyCase/_actions/action.ts +5 -1
- package/dist/components/page/MyCase/_fetchers/addMyFileUpload.d.ts +6 -1
- package/dist/components/page/MyCase/_fetchers/addMyFileUpload.js +53 -12
- package/dist/components/page/MyCase/_fetchers/addMyFileUpload.ts +59 -12
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -390,13 +390,13 @@ const OnlineBox = (props) => {
|
|
|
390
390
|
</span>
|
|
391
391
|
<Link className={'mb-[4px] mt-[32px] flex h-[60px] w-[240px] items-center justify-between rounded-[5px] bg-[#285EA7] px-[20px] py-[16px] text-[22px] font-bold text-white ' +
|
|
392
392
|
' max-5xl:mt-[13px] max-5xl:h-[45px] max-5xl:w-[190px] max-5xl:text-[18px] ' +
|
|
393
|
-
' max-lg:mt-[17px] max-lg:h-[40px] max-lg:w-[200px] max-lg:py-[10px] max-lg:text-[16px] '} href={props.centerConsultUrl ? props.centerConsultUrl + '/consulting' : '/consulting'} aria-label={'기업 온라인 상담'} onClick={props.onConsultCompClick}>
|
|
393
|
+
' max-lg:mt-[17px] max-lg:h-[40px] max-lg:w-[200px] max-lg:py-[10px] max-lg:text-[16px] '} href={props.centerConsultUrl ? props.centerConsultUrl + '/consulting' : '/consulting'} aria-label={'기업 온라인 상담'} target={props.target ? '_blank' : undefined} onClick={props.onConsultCompClick}>
|
|
394
394
|
{props.companyTxt}
|
|
395
395
|
<Image src={ArrowIcon} width={22} height={18} alt={''} className={'h-auto w-[22px] max-5xl:w-[20px] max-lg:w-[17px]'}/>
|
|
396
396
|
</Link>
|
|
397
397
|
<Link className={'flex h-[60px] w-[240px] items-center justify-between rounded-[5px] bg-[#0A96AF] px-[20px] py-[16px] text-[22px] font-bold text-white' +
|
|
398
398
|
' max-5xl:h-[45px] max-5xl:w-[190px] max-5xl:text-[18px] ' +
|
|
399
|
-
' max-lg:h-[40px] max-lg:w-[200px] max-lg:py-[10px] max-lg:text-[16px] '} href={props.centerConsultUrl ? props.centerConsultUrl + '/consult' : '/consult'} aria-label={'개인 온라인 상담'} onClick={props.onConsultPersonalClick} onKeyDown={e => {
|
|
399
|
+
' max-lg:h-[40px] max-lg:w-[200px] max-lg:py-[10px] max-lg:text-[16px] '} href={props.centerConsultUrl ? props.centerConsultUrl + '/consult' : '/consult'} aria-label={'개인 온라인 상담'} target={props.target ? '_blank' : undefined} onClick={props.onConsultPersonalClick} onKeyDown={e => {
|
|
400
400
|
var _a;
|
|
401
401
|
if (e.key === 'Tab') {
|
|
402
402
|
e.preventDefault();
|
|
@@ -26,6 +26,7 @@ const Fix = (props: {
|
|
|
26
26
|
centerConsultUrl?: string;
|
|
27
27
|
customFont?: string;
|
|
28
28
|
bannerHeight?: number;
|
|
29
|
+
target?: boolean;
|
|
29
30
|
}) => {
|
|
30
31
|
const mobile = require('is-mobile');
|
|
31
32
|
const pathname = usePathname();
|
|
@@ -583,6 +584,7 @@ const OnlineBox = (props: {
|
|
|
583
584
|
onlineRef: any;
|
|
584
585
|
onConsultCompClick: () => void;
|
|
585
586
|
onConsultPersonalClick: () => void;
|
|
587
|
+
target?: boolean;
|
|
586
588
|
}) => {
|
|
587
589
|
const closeRef = useRef<HTMLButtonElement>(null);
|
|
588
590
|
return (
|
|
@@ -622,6 +624,7 @@ const OnlineBox = (props: {
|
|
|
622
624
|
}
|
|
623
625
|
href={props.centerConsultUrl ? props.centerConsultUrl + '/consulting' : '/consulting'}
|
|
624
626
|
aria-label={'기업 온라인 상담'}
|
|
627
|
+
target={props.target ? '_blank' : undefined}
|
|
625
628
|
onClick={props.onConsultCompClick}
|
|
626
629
|
>
|
|
627
630
|
{props.companyTxt}
|
|
@@ -641,6 +644,7 @@ const OnlineBox = (props: {
|
|
|
641
644
|
}
|
|
642
645
|
href={props.centerConsultUrl ? props.centerConsultUrl + '/consult' : '/consult'}
|
|
643
646
|
aria-label={'개인 온라인 상담'}
|
|
647
|
+
target={props.target ? '_blank' : undefined}
|
|
644
648
|
onClick={props.onConsultPersonalClick}
|
|
645
649
|
onKeyDown={e => {
|
|
646
650
|
if (e.key === 'Tab') {
|
|
@@ -65,7 +65,7 @@ const DocumentLine = ({ item, index }) => {
|
|
|
65
65
|
{item.name}
|
|
66
66
|
</p>
|
|
67
67
|
<p className="body_small1_mo sm-top:body_small2_tb lg:body_small2 mt-[4px] text-grayScale2 sm-top:mt-[8px]">
|
|
68
|
-
{dayjs(item.created_at).format('YYYY.MM.DD HH:mm')} - {item.size}MB
|
|
68
|
+
{dayjs(item.created_at).format('YYYY.MM.DD HH:mm')} - {Math.round(Number(item.size) / 1024)}MB
|
|
69
69
|
</p>
|
|
70
70
|
</div>
|
|
71
71
|
{downloadUrl && (<a href={downloadUrl} download={item.name} className="flex-shrink-0">
|
|
@@ -74,7 +74,7 @@ const DocumentLine = ({ item, index }: { item: FileList; index: number }) => {
|
|
|
74
74
|
{item.name}
|
|
75
75
|
</p>
|
|
76
76
|
<p className="body_small1_mo sm-top:body_small2_tb lg:body_small2 mt-[4px] text-grayScale2 sm-top:mt-[8px]">
|
|
77
|
-
{dayjs(item.created_at).format('YYYY.MM.DD HH:mm')} - {item.size}MB
|
|
77
|
+
{dayjs(item.created_at).format('YYYY.MM.DD HH:mm')} - {Math.round(Number(item.size) / 1024)}MB
|
|
78
78
|
</p>
|
|
79
79
|
</div>
|
|
80
80
|
{downloadUrl && (
|
|
@@ -10,7 +10,7 @@ const FileDropZone = ({ id, refetch }) => {
|
|
|
10
10
|
const { getRootProps, getInputProps, isSuccess, setIsSuccess } = FileUpload({ id, refetch });
|
|
11
11
|
return (<div className="mb-[80px] mt-[60px] flex w-full items-end justify-end">
|
|
12
12
|
{/* saved가 true일 때만 Dropzone 적용 */}
|
|
13
|
-
{saved ? (<div {...getRootProps()}
|
|
13
|
+
{saved ? (<div {...getRootProps()}>
|
|
14
14
|
<input {...getInputProps()}/>
|
|
15
15
|
<button className="flex h-[48px] items-center justify-center gap-[16px] rounded-[24px] bg-mycaseMainColor px-[16px] sm-top:h-[60px] sm-top:gap-[28px] sm-top:rounded-[36px] sm-top:px-[26px] lg:gap-[24px] lg:px-[36px]">
|
|
16
16
|
<Image src={upload} alt="file_upload" width={48} height={48} className="h-[16px] w-[16px] sm-top:h-[20px] sm-top:w-[20px] lg:h-[24px] lg:w-[24px] "/>
|
|
@@ -15,7 +15,7 @@ const FileDropZone = ({ id, refetch }: { id: string; refetch: () => void }) => {
|
|
|
15
15
|
<div className="mb-[80px] mt-[60px] flex w-full items-end justify-end">
|
|
16
16
|
{/* saved가 true일 때만 Dropzone 적용 */}
|
|
17
17
|
{saved ? (
|
|
18
|
-
<div {...getRootProps()}
|
|
18
|
+
<div {...getRootProps()}>
|
|
19
19
|
<input {...getInputProps()} />
|
|
20
20
|
<button className="flex h-[48px] items-center justify-center gap-[16px] rounded-[24px] bg-mycaseMainColor px-[16px] sm-top:h-[60px] sm-top:gap-[28px] sm-top:rounded-[36px] sm-top:px-[26px] lg:gap-[24px] lg:px-[36px]">
|
|
21
21
|
<Image
|
|
@@ -40,6 +40,11 @@ export declare const useActionGetContact: (id: string) => {
|
|
|
40
40
|
isFetched: boolean;
|
|
41
41
|
};
|
|
42
42
|
export declare const useActionPostMyFileUpload: (id: string) => {
|
|
43
|
-
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<
|
|
43
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
44
|
+
result: boolean;
|
|
45
|
+
data: any;
|
|
46
|
+
uploadStatus: number;
|
|
47
|
+
notificationStatus: boolean;
|
|
48
|
+
}, unknown, File, unknown>;
|
|
44
49
|
isLoading: boolean;
|
|
45
50
|
};
|
|
@@ -187,7 +187,11 @@ export const useActionGetContact = (id: string) => {
|
|
|
187
187
|
};
|
|
188
188
|
|
|
189
189
|
export const useActionPostMyFileUpload = (id: string) => {
|
|
190
|
-
const { mutateAsync, status } = useMutation<
|
|
190
|
+
const { mutateAsync, status } = useMutation<
|
|
191
|
+
{ result: boolean; data: any; uploadStatus: number; notificationStatus: boolean },
|
|
192
|
+
unknown,
|
|
193
|
+
File
|
|
194
|
+
>({
|
|
191
195
|
mutationFn: async (file: File) =>
|
|
192
196
|
await addMyFileUpload({
|
|
193
197
|
id: id as string,
|
|
@@ -10,25 +10,66 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import Fetch from '../../Login/_fetch/fetch';
|
|
11
11
|
const addMyFileUpload = (_a) => __awaiter(void 0, [_a], void 0, function* ({ id, file }) {
|
|
12
12
|
try {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
formData.append('file', file);
|
|
16
|
-
const response = yield Fetch(`/api/lawfirm/app/case/${id}/docs/my`, {
|
|
13
|
+
// 1단계: S3 presigned URL 요청
|
|
14
|
+
const response = yield Fetch(`/api/lawfirm/app/s3-upload`, {
|
|
17
15
|
method: 'POST',
|
|
18
16
|
headers: {
|
|
19
17
|
// Authorization: `${jwt}`
|
|
20
18
|
},
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
body: JSON.stringify({
|
|
20
|
+
target: 'legalCase',
|
|
21
|
+
caseIdx: parseInt(id, 10),
|
|
22
|
+
parentDir: null,
|
|
23
|
+
fileNames: [file.name]
|
|
24
|
+
})
|
|
23
25
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
26
|
+
if (!response.result) {
|
|
27
|
+
throw new Error('Failed to get S3 presigned URL');
|
|
28
|
+
}
|
|
29
|
+
// 2단계: 받은 presigned URL로 실제 파일을 S3에 업로드
|
|
30
|
+
const uploadData = response.data[0]; // 첫 번째 파일 정보
|
|
31
|
+
const { url: presignedUrl, name: fileName } = uploadData;
|
|
32
|
+
// 파일명과 일치하는 파일을 찾아 업로드 (현재는 하나만 업로드하므로 첫 번째 파일 사용)
|
|
33
|
+
const uploadResponse = yield fetch(presignedUrl, {
|
|
34
|
+
method: 'PUT',
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/octet-stream'
|
|
37
|
+
},
|
|
38
|
+
body: file
|
|
39
|
+
});
|
|
40
|
+
if (!uploadResponse.ok) {
|
|
41
|
+
throw new Error(`S3 upload failed: ${uploadResponse.statusText}`);
|
|
42
|
+
}
|
|
43
|
+
// 3단계: 서버에 업로드 완료 알림
|
|
44
|
+
// presigned URL에서 실제 파일 경로 추출
|
|
45
|
+
const urlObject = new URL(presignedUrl);
|
|
46
|
+
const s3Path = urlObject.pathname;
|
|
47
|
+
const cloudFrontPath = `https://d6robzfync7d.cloudfront.net${s3Path}`;
|
|
48
|
+
const notifyResponse = yield Fetch(`/api/lawfirm/app/case/${id}/docs/upload`, {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
headers: {
|
|
51
|
+
// Authorization: `${jwt}`
|
|
52
|
+
},
|
|
53
|
+
body: JSON.stringify({
|
|
54
|
+
caseIdx: parseInt(id, 10),
|
|
55
|
+
files: [
|
|
56
|
+
{
|
|
57
|
+
name: fileName,
|
|
58
|
+
path: cloudFrontPath,
|
|
59
|
+
size: file.size
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
result: true,
|
|
66
|
+
data: response.data,
|
|
67
|
+
uploadStatus: uploadResponse.status,
|
|
68
|
+
notificationStatus: notifyResponse.result
|
|
69
|
+
};
|
|
29
70
|
}
|
|
30
71
|
catch (error) {
|
|
31
|
-
console.error('Failed to
|
|
72
|
+
console.error('Failed to upload file:', error);
|
|
32
73
|
throw error;
|
|
33
74
|
}
|
|
34
75
|
});
|
|
@@ -2,25 +2,72 @@ import Fetch from '../../Login/_fetch/fetch';
|
|
|
2
2
|
|
|
3
3
|
const addMyFileUpload = async ({ id, file }: { id: string; file: File }) => {
|
|
4
4
|
try {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// 1단계: S3 presigned URL 요청
|
|
6
|
+
const response = await Fetch(`/api/lawfirm/app/s3-upload`, {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
headers: {
|
|
9
|
+
// Authorization: `${jwt}`
|
|
10
|
+
},
|
|
11
|
+
body: JSON.stringify({
|
|
12
|
+
target: 'legalCase',
|
|
13
|
+
caseIdx: parseInt(id, 10),
|
|
14
|
+
parentDir: null,
|
|
15
|
+
fileNames: [file.name]
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (!response.result) {
|
|
20
|
+
throw new Error('Failed to get S3 presigned URL');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 2단계: 받은 presigned URL로 실제 파일을 S3에 업로드
|
|
24
|
+
const uploadData = response.data[0]; // 첫 번째 파일 정보
|
|
25
|
+
const { url: presignedUrl, name: fileName } = uploadData;
|
|
8
26
|
|
|
9
|
-
|
|
27
|
+
// 파일명과 일치하는 파일을 찾아 업로드 (현재는 하나만 업로드하므로 첫 번째 파일 사용)
|
|
28
|
+
const uploadResponse = await fetch(presignedUrl, {
|
|
29
|
+
method: 'PUT',
|
|
30
|
+
headers: {
|
|
31
|
+
'Content-Type': 'application/octet-stream'
|
|
32
|
+
},
|
|
33
|
+
body: file
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (!uploadResponse.ok) {
|
|
37
|
+
throw new Error(`S3 upload failed: ${uploadResponse.statusText}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 3단계: 서버에 업로드 완료 알림
|
|
41
|
+
// presigned URL에서 실제 파일 경로 추출
|
|
42
|
+
const urlObject = new URL(presignedUrl);
|
|
43
|
+
const s3Path = urlObject.pathname;
|
|
44
|
+
const cloudFrontPath = `https://d6robzfync7d.cloudfront.net${s3Path}`;
|
|
45
|
+
|
|
46
|
+
const notifyResponse = await Fetch(`/api/lawfirm/app/case/${id}/docs/upload`, {
|
|
10
47
|
method: 'POST',
|
|
11
48
|
headers: {
|
|
12
49
|
// Authorization: `${jwt}`
|
|
13
50
|
},
|
|
14
|
-
|
|
15
|
-
|
|
51
|
+
body: JSON.stringify({
|
|
52
|
+
caseIdx: parseInt(id, 10),
|
|
53
|
+
files: [
|
|
54
|
+
{
|
|
55
|
+
name: fileName,
|
|
56
|
+
path: cloudFrontPath,
|
|
57
|
+
size: file.size
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
})
|
|
16
61
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
result: true,
|
|
65
|
+
data: response.data,
|
|
66
|
+
uploadStatus: uploadResponse.status,
|
|
67
|
+
notificationStatus: notifyResponse.result
|
|
68
|
+
};
|
|
22
69
|
} catch (error) {
|
|
23
|
-
console.error('Failed to
|
|
70
|
+
console.error('Failed to upload file:', error);
|
|
24
71
|
throw error;
|
|
25
72
|
}
|
|
26
73
|
};
|