@daeryun/dr_components 1.1.3 → 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.
@@ -9,6 +9,7 @@ declare const fix: {
9
9
  centerConsultUrl?: string;
10
10
  customFont?: string;
11
11
  bannerHeight?: number;
12
+ target?: boolean;
12
13
  }) => import("react").JSX.Element;
13
14
  title: string;
14
15
  };
@@ -6,5 +6,6 @@ declare const Fix: (props: {
6
6
  centerConsultUrl?: string;
7
7
  customFont?: string;
8
8
  bannerHeight?: number;
9
+ target?: boolean;
9
10
  }) => React.JSX.Element;
10
11
  export default Fix;
@@ -375,9 +375,9 @@ const Fix = (props) => {
375
375
  export default Fix;
376
376
  const OnlineBox = (props) => {
377
377
  const closeRef = useRef(null);
378
- return (<div ref={props.onlineRef} className={'fixed bottom-[80px] right-[25px] z-50 h-[300px] w-[300px] bg-white px-[30px] py-[26px] shadow-[0_4px_8px_0_rgba(0,0,0,0.1)] ' +
379
- 'max-5xl:bottom-[75px] max-5xl:h-[230px] max-5xl:w-[230px] max-5xl:px-[22px] max-5xl:py-[20px] ' +
380
- 'max-lg:bottom-[85px] max-lg:left-[20px] max-lg:h-[160px] max-lg:w-[240px] max-lg:px-[20px] max-lg:py-[17px] ' +
378
+ return (<div ref={props.onlineRef} className={'absolute right-[0px] top-[60px] z-50 h-[300px] w-[300px] bg-white px-[30px] py-[26px] shadow-[0_4px_8px_0_rgba(0,0,0,0.1)] ' +
379
+ 'max-5xl:top-[55px] max-5xl:h-[230px] max-5xl:w-[230px] max-5xl:px-[22px] max-5xl:py-[20px] ' +
380
+ 'max-lg:bottom-[85px] max-lg:left-[20px] max-lg:top-[unset] max-lg:h-[160px] max-lg:w-[240px] max-lg:px-[20px] max-lg:py-[17px] ' +
381
381
  'animate-[fadeIn_0.15s] transition-opacity '}>
382
382
  <span className={'z-10 mb-[11px] flex w-full items-center justify-between text-[26px] font-bold leading-[30px] tracking-[-1.3px] max-5xl:text-[20px] max-lg:text-[18px] max-lg:leading-[23px]'}>
383
383
  {props.titleTxt}
@@ -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,15 +584,16 @@ 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 (
589
591
  <div
590
592
  ref={props.onlineRef}
591
593
  className={
592
- 'fixed bottom-[80px] right-[25px] z-50 h-[300px] w-[300px] bg-white px-[30px] py-[26px] shadow-[0_4px_8px_0_rgba(0,0,0,0.1)] ' +
593
- 'max-5xl:bottom-[75px] max-5xl:h-[230px] max-5xl:w-[230px] max-5xl:px-[22px] max-5xl:py-[20px] ' +
594
- 'max-lg:bottom-[85px] max-lg:left-[20px] max-lg:h-[160px] max-lg:w-[240px] max-lg:px-[20px] max-lg:py-[17px] ' +
594
+ 'absolute right-[0px] top-[60px] z-50 h-[300px] w-[300px] bg-white px-[30px] py-[26px] shadow-[0_4px_8px_0_rgba(0,0,0,0.1)] ' +
595
+ 'max-5xl:top-[55px] max-5xl:h-[230px] max-5xl:w-[230px] max-5xl:px-[22px] max-5xl:py-[20px] ' +
596
+ 'max-lg:bottom-[85px] max-lg:left-[20px] max-lg:top-[unset] max-lg:h-[160px] max-lg:w-[240px] max-lg:px-[20px] max-lg:py-[17px] ' +
595
597
  'animate-[fadeIn_0.15s] transition-opacity '
596
598
  }
597
599
  >
@@ -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()} className="">
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()} className="">
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<FetchType<Question[]>, unknown, File, unknown>;
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<FetchType<Question[]>, unknown, File>({
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,
@@ -1,5 +1,10 @@
1
1
  declare const addMyFileUpload: ({ id, file }: {
2
2
  id: string;
3
3
  file: File;
4
- }) => Promise<any>;
4
+ }) => Promise<{
5
+ result: boolean;
6
+ data: any;
7
+ uploadStatus: number;
8
+ notificationStatus: any;
9
+ }>;
5
10
  export default addMyFileUpload;
@@ -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
- const formData = new FormData();
14
- formData.append('idx', id);
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
- type: 'form',
22
- body: formData
19
+ body: JSON.stringify({
20
+ target: 'legalCase',
21
+ caseIdx: parseInt(id, 10),
22
+ parentDir: null,
23
+ fileNames: [file.name]
24
+ })
23
25
  });
24
- // if (!response.ok) {
25
- // throw new Error('Network response was not ok');
26
- // }
27
- // const data = await response.json();
28
- return response;
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 fetch case:', error);
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
- const formData = new FormData();
6
- formData.append('idx', id);
7
- formData.append('file', file);
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
- const response = await Fetch(`/api/lawfirm/app/case/${id}/docs/my`, {
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
- type: 'form',
15
- body: formData
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
- // if (!response.ok) {
18
- // throw new Error('Network response was not ok');
19
- // }
20
- // const data = await response.json();
21
- return response;
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 fetch case:', error);
70
+ console.error('Failed to upload file:', error);
24
71
  throw error;
25
72
  }
26
73
  };
@@ -1042,6 +1042,10 @@ html {
1042
1042
  right: -70px;
1043
1043
  }
1044
1044
 
1045
+ .right-\[0px\] {
1046
+ right: 0px;
1047
+ }
1048
+
1045
1049
  .right-\[10\%\] {
1046
1050
  right: 10%;
1047
1051
  }
@@ -1226,6 +1230,10 @@ html {
1226
1230
  top: 5px;
1227
1231
  }
1228
1232
 
1233
+ .top-\[60px\] {
1234
+ top: 60px;
1235
+ }
1236
+
1229
1237
  .top-\[6px\] {
1230
1238
  top: 6px;
1231
1239
  }
@@ -9949,14 +9957,14 @@ body {
9949
9957
  bottom: 15px;
9950
9958
  }
9951
9959
 
9952
- .max-5xl\:bottom-\[75px\] {
9953
- bottom: 75px;
9954
- }
9955
-
9956
9960
  .max-5xl\:right-\[80px\] {
9957
9961
  right: 80px;
9958
9962
  }
9959
9963
 
9964
+ .max-5xl\:top-\[55px\] {
9965
+ top: 55px;
9966
+ }
9967
+
9960
9968
  .max-5xl\:mb-\[3px\] {
9961
9969
  margin-bottom: 3px;
9962
9970
  }
@@ -12636,6 +12644,10 @@ body {
12636
12644
  top: 50%;
12637
12645
  }
12638
12646
 
12647
+ .max-lg\:top-\[unset\] {
12648
+ top: unset;
12649
+ }
12650
+
12639
12651
  .max-lg\:m-0 {
12640
12652
  margin: 0px;
12641
12653
  }