@daeryun/dr_components 1.1.21 → 1.1.23
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/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/components/BrochureBtn/BrochureBtn.jsx +4 -0
- package/dist/components/BrochureBtn/BrochureBtn.stories.jsx +1 -1
- package/dist/components/BrochureBtn/BrochureBtn.stories.tsx +1 -1
- package/dist/components/BrochureBtn/BrochureBtn.tsx +4 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.js +1 -1
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useHistoryHandler.ts +1 -1
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +24 -16
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +73 -70
- package/dist/components/common/integrate/index.d.ts +1 -1
- package/dist/components/page/MapPage/MapPage.jsx +1 -1
- package/dist/components/page/MapPage/MapPage.tsx +1 -1
- package/dist/components/page/MyCase/[id]/_component/_document/Document.jsx +2 -2
- package/dist/components/page/MyCase/[id]/_component/_document/Document.tsx +2 -2
- package/dist/components/page/MyCase/[id]/_component/_document/FileUpload.js +3 -3
- package/dist/components/page/MyCase/[id]/_component/_document/FileUpload.ts +3 -4
- package/dist/components/page/MyCase/_actions/action.d.ts +12 -7
- package/dist/components/page/MyCase/_actions/action.js +5 -10
- package/dist/components/page/MyCase/_actions/action.ts +13 -16
- package/dist/components/page/MyCase/_fetchers/addMyFileUpload.d.ts +7 -2
- package/dist/components/page/MyCase/_fetchers/addMyFileUpload.js +36 -27
- package/dist/components/page/MyCase/_fetchers/addMyFileUpload.ts +41 -29
- package/dist/styles/globals.css +386 -386
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,11 @@ import {
|
|
|
13
13
|
} from '../../_api/daeryuntalk';
|
|
14
14
|
import { Message } from '../../_types/message';
|
|
15
15
|
import { History, IChatInquiryMainDataResponse } from '../../_api/daeryuntalk/type/response';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
convertApiMessageObjectToUiMessageObject,
|
|
18
|
+
convertApiMessageToUiMessage,
|
|
19
|
+
convertSocketObjectToUiMessage
|
|
20
|
+
} from '../../_lib';
|
|
17
21
|
import { MessageObject } from '../../_types/message_object';
|
|
18
22
|
import { IInquiryWorkFlowUpdate } from '../../_types/socket/workflow';
|
|
19
23
|
import { MessageSendSocketType, MessageSocketType } from '../../_enums/socket_type';
|
|
@@ -76,7 +80,6 @@ export const useSocketEventHandler = ({
|
|
|
76
80
|
setChatInquiryNumber,
|
|
77
81
|
setAgeCheckStatus
|
|
78
82
|
}: props) => {
|
|
79
|
-
|
|
80
83
|
const typingBlockRef = useRef<NodeJS.Timeout | null>(null);
|
|
81
84
|
const typingTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
82
85
|
const toast = useDaeryunTalkToast();
|
|
@@ -85,7 +88,7 @@ export const useSocketEventHandler = ({
|
|
|
85
88
|
|
|
86
89
|
// 현재 화면 가시성 상태
|
|
87
90
|
const [isVisible, setIsVisible] = useState(
|
|
88
|
-
typeof document !==
|
|
91
|
+
typeof document !== 'undefined' ? document.visibilityState === 'visible' : true
|
|
89
92
|
);
|
|
90
93
|
|
|
91
94
|
// 재연결 시도 횟수
|
|
@@ -111,8 +114,8 @@ export const useSocketEventHandler = ({
|
|
|
111
114
|
useEffect(() => {
|
|
112
115
|
chatInquiryNumberRef.current = chatInquiryNumber;
|
|
113
116
|
}, [chatInquiryNumber]);
|
|
114
|
-
consoleFn('chatInquiryNumber', chatInquiryNumber)
|
|
115
|
-
consoleFn('socketRef.current', socketRef.current?.readyState)
|
|
117
|
+
consoleFn('chatInquiryNumber', chatInquiryNumber);
|
|
118
|
+
consoleFn('socketRef.current', socketRef.current?.readyState);
|
|
116
119
|
|
|
117
120
|
/**
|
|
118
121
|
* 1. heartbeat
|
|
@@ -247,28 +250,26 @@ export const useSocketEventHandler = ({
|
|
|
247
250
|
/** 화면 전환 이벤트 (백그라운드 ↔ 포그라운드) */
|
|
248
251
|
useEffect(() => {
|
|
249
252
|
const handleVisibilityChange = () => {
|
|
250
|
-
const visible = document.visibilityState ===
|
|
253
|
+
const visible = document.visibilityState === 'visible';
|
|
251
254
|
setIsVisible(visible);
|
|
252
255
|
|
|
253
|
-
consoleFn('visible', visible)
|
|
256
|
+
consoleFn('visible', visible);
|
|
254
257
|
if (visible) {
|
|
255
|
-
|
|
256
|
-
consoleFn('
|
|
257
|
-
consoleFn('화면 켜짐 확인 - 재연결 시도')
|
|
258
|
+
consoleFn('socketRef.current', socketRef.current);
|
|
259
|
+
consoleFn('화면 켜짐 확인 - 재연결 시도');
|
|
258
260
|
if (!socketRef.current || socketRef.current.readyState !== WebSocket.OPEN) {
|
|
259
|
-
consoleFn(
|
|
261
|
+
consoleFn('📱 포그라운드 전환 → 재연결 카운트 리셋 후 재시도');
|
|
260
262
|
reconnectCountRef.current = 0; // 카운트 리셋
|
|
261
263
|
reconnectWithNewTokenSocket();
|
|
262
264
|
} else {
|
|
263
|
-
consoleFn('socketRef.current 준비 상태')
|
|
265
|
+
consoleFn('socketRef.current 준비 상태');
|
|
264
266
|
}
|
|
265
267
|
}
|
|
266
268
|
};
|
|
267
|
-
document.addEventListener(
|
|
268
|
-
return () => document.removeEventListener(
|
|
269
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
270
|
+
return () => document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
269
271
|
}, []);
|
|
270
272
|
|
|
271
|
-
|
|
272
273
|
const webSocketMessageHandler = useCallback((event: MessageEvent) => {
|
|
273
274
|
consoleFn('[DaeryuntalkContext] 웹소켓 메시지 수신됨');
|
|
274
275
|
try {
|
|
@@ -278,9 +279,7 @@ export const useSocketEventHandler = ({
|
|
|
278
279
|
if (data.type === MessageSocketType.MESSAGE_CREATED && data.payload?.message) {
|
|
279
280
|
const newMessage = convertApiMessageToUiMessage(data.payload.message, 'live');
|
|
280
281
|
setMessages(prev => {
|
|
281
|
-
const isDuplicate = prev.some(
|
|
282
|
-
msg => msg.messageNumber === newMessage.messageNumber
|
|
283
|
-
);
|
|
282
|
+
const isDuplicate = prev.some(msg => msg.messageNumber === newMessage.messageNumber);
|
|
284
283
|
return isDuplicate ? prev : [...prev, newMessage];
|
|
285
284
|
});
|
|
286
285
|
closeTyping();
|
|
@@ -324,12 +323,12 @@ export const useSocketEventHandler = ({
|
|
|
324
323
|
prev.map(item =>
|
|
325
324
|
item.chat_inquiry_number === socketData.chat_inquiry_number
|
|
326
325
|
? ({
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
326
|
+
chat_inquiry_number: socketData.chat_inquiry_number,
|
|
327
|
+
customer_name: item.customer_name,
|
|
328
|
+
recent_message_content: socketData.recent_message_content,
|
|
329
|
+
recent_message_date_time: socketData.recent_message_date_time,
|
|
330
|
+
unread_message_count: Number(socketData.unread_message_count)
|
|
331
|
+
} as History)
|
|
333
332
|
: item
|
|
334
333
|
)
|
|
335
334
|
);
|
|
@@ -381,7 +380,6 @@ export const useSocketEventHandler = ({
|
|
|
381
380
|
}
|
|
382
381
|
}, []);
|
|
383
382
|
|
|
384
|
-
|
|
385
383
|
/** util: 소켓 정리 */
|
|
386
384
|
const cleanupWebSocketInstance = useCallback((socket: WebSocket | null) => {
|
|
387
385
|
if (!socket) return;
|
|
@@ -391,12 +389,12 @@ export const useSocketEventHandler = ({
|
|
|
391
389
|
socket.onerror = null;
|
|
392
390
|
try {
|
|
393
391
|
socket.close();
|
|
394
|
-
} catch {
|
|
392
|
+
} catch {}
|
|
395
393
|
}, []);
|
|
396
394
|
|
|
397
395
|
/** util: 소켓 재연결 (새 토큰 발급 후 재연결) */
|
|
398
396
|
const reconnectWithNewTokenSocket = useCallback(async () => {
|
|
399
|
-
consoleFn('재연결 시도')
|
|
397
|
+
consoleFn('재연결 시도');
|
|
400
398
|
// 화면 꺼진 경우 재연결 X
|
|
401
399
|
if (!isVisible) return;
|
|
402
400
|
|
|
@@ -406,7 +404,7 @@ export const useSocketEventHandler = ({
|
|
|
406
404
|
try {
|
|
407
405
|
// 최대 시도 횟수 초과 시 종료
|
|
408
406
|
if (reconnectCountRef.current >= maxReconnectAttempts) {
|
|
409
|
-
consoleFn(
|
|
407
|
+
consoleFn('❌ 재연결 최대 횟수 초과, 더 이상 시도하지 않음');
|
|
410
408
|
return;
|
|
411
409
|
}
|
|
412
410
|
|
|
@@ -432,23 +430,26 @@ export const useSocketEventHandler = ({
|
|
|
432
430
|
setIsConnected,
|
|
433
431
|
userExpiredRef,
|
|
434
432
|
webSocketMessageHandler, // onMessage
|
|
435
|
-
() => {
|
|
433
|
+
() => {
|
|
434
|
+
// onOpen
|
|
436
435
|
consoleFn('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 성공');
|
|
437
436
|
setIsConnected(true);
|
|
438
437
|
isSocketReconnectingRef.current = false; // 성공 시 초기화
|
|
439
|
-
setInitialLoading(false)
|
|
438
|
+
setInitialLoading(false);
|
|
440
439
|
if (chatInquiryNumberRef.current) {
|
|
441
|
-
sendInquiryJoined(chatInquiryNumberRef.current);
|
|
442
|
-
sendInquiryWatching(chatInquiryNumberRef.current);
|
|
440
|
+
sendInquiryJoined(chatInquiryNumberRef.current || '');
|
|
441
|
+
sendInquiryWatching(chatInquiryNumberRef.current || '');
|
|
443
442
|
}
|
|
444
443
|
},
|
|
445
|
-
() => {
|
|
444
|
+
() => {
|
|
445
|
+
// onClose
|
|
446
446
|
consoleFn('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 종료');
|
|
447
447
|
setIsConnected(false);
|
|
448
448
|
isSocketReconnectingRef.current = false; // 실패 시 초기화
|
|
449
449
|
setTimeout(() => reconnectWithNewTokenSocket(), reconnectDelay);
|
|
450
450
|
},
|
|
451
|
-
event => {
|
|
451
|
+
event => {
|
|
452
|
+
// onError
|
|
452
453
|
console.error('[DaeryuntalkContext] 웹소켓 오류:', event);
|
|
453
454
|
setIsConnected(false);
|
|
454
455
|
isSocketReconnectingRef.current = false; // 오류 시 초기화
|
|
@@ -458,10 +459,10 @@ export const useSocketEventHandler = ({
|
|
|
458
459
|
socketRef.current = socket;
|
|
459
460
|
|
|
460
461
|
if (chatInquiryNumberRef.current) {
|
|
461
|
-
consoleFn('chatList 실행')
|
|
462
|
-
const chatList = await getChatInquiryMessageList(chatInquiryNumberRef.current);
|
|
462
|
+
consoleFn('chatList 실행');
|
|
463
|
+
const chatList = await getChatInquiryMessageList(chatInquiryNumberRef.current || '');
|
|
463
464
|
if (chatList.result_info.result_cd === 'OK' || chatList.result_info.result_type_cd === 'OK') {
|
|
464
|
-
//
|
|
465
|
+
//
|
|
465
466
|
if (chatList.data?.message_list && chatList.data.message_list.length > 0) {
|
|
466
467
|
const uiMessages = chatList.data.message_list
|
|
467
468
|
.sort((a, b) => a.timestamp - b.timestamp)
|
|
@@ -476,23 +477,21 @@ export const useSocketEventHandler = ({
|
|
|
476
477
|
}
|
|
477
478
|
}
|
|
478
479
|
} else {
|
|
479
|
-
console.log('chatInquiryNumber 없음')
|
|
480
|
+
// console.log('chatInquiryNumber 없음')
|
|
480
481
|
}
|
|
481
482
|
} else {
|
|
482
|
-
console.error("❌ 웹소켓 토큰 발급 실패:", wsInitData);
|
|
483
|
+
// console.error("❌ 웹소켓 토큰 발급 실패:", wsInitData);
|
|
483
484
|
isSocketReconnectingRef.current = false; // ✅ 토큰 발급 실패도 초기화
|
|
484
485
|
setTimeout(() => reconnectWithNewTokenSocket(), reconnectDelay);
|
|
485
486
|
}
|
|
486
487
|
} catch (error) {
|
|
487
|
-
console.error('[DaeryuntalkContext] 소켓 재연결 오류:', error);
|
|
488
|
+
// console.error('[DaeryuntalkContext] 소켓 재연결 오류:', error);
|
|
488
489
|
isSocketReconnectingRef.current = false; // ✅ 예외 발생 시 초기화
|
|
489
490
|
setTimeout(() => reconnectWithNewTokenSocket(), reconnectDelay);
|
|
490
491
|
}
|
|
491
492
|
}, [cleanupWebSocketInstance, chatInquiryNumber]);
|
|
492
493
|
|
|
493
|
-
|
|
494
494
|
const handleTypingStarted = () => {
|
|
495
|
-
|
|
496
495
|
openTyping();
|
|
497
496
|
|
|
498
497
|
if (typingTimeoutRef.current) {
|
|
@@ -505,8 +504,6 @@ export const useSocketEventHandler = ({
|
|
|
505
504
|
}, 3000);
|
|
506
505
|
};
|
|
507
506
|
|
|
508
|
-
|
|
509
|
-
|
|
510
507
|
// Daeryuntalk API 초기화 메소드
|
|
511
508
|
const initializeDaeryuntalk = useCallback(
|
|
512
509
|
async (hashValue: string | null, isOpen: boolean, centerCode: string, version?: string) => {
|
|
@@ -529,17 +526,20 @@ export const useSocketEventHandler = ({
|
|
|
529
526
|
socket => {
|
|
530
527
|
consoleFn('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 성공');
|
|
531
528
|
setIsConnected(true);
|
|
532
|
-
setInitialLoading(true)
|
|
529
|
+
setInitialLoading(true);
|
|
533
530
|
},
|
|
534
|
-
event => {
|
|
531
|
+
event => {
|
|
532
|
+
// onMessage
|
|
535
533
|
webSocketMessageHandler(event);
|
|
536
534
|
},
|
|
537
|
-
event => {
|
|
535
|
+
event => {
|
|
536
|
+
// onClose
|
|
538
537
|
consoleFn('[DaeryuntalkContext] 웹소켓 연결 콜백 - 연결 실패');
|
|
539
538
|
setIsConnected(false);
|
|
540
539
|
setTimeout(() => reconnectWithNewTokenSocket(), reconnectDelay);
|
|
541
540
|
},
|
|
542
|
-
event => {
|
|
541
|
+
event => {
|
|
542
|
+
// onError
|
|
543
543
|
console.error('[DaeryuntalkContext] 웹소켓 오류:', event);
|
|
544
544
|
setIsConnected(false);
|
|
545
545
|
setTimeout(() => reconnectWithNewTokenSocket(), reconnectDelay);
|
|
@@ -574,28 +574,35 @@ export const useSocketEventHandler = ({
|
|
|
574
574
|
return inquiryData;
|
|
575
575
|
}
|
|
576
576
|
|
|
577
|
-
|
|
578
577
|
let detailResponse = null;
|
|
579
578
|
let chatList = null;
|
|
580
|
-
let chatNumber ='';
|
|
579
|
+
let chatNumber = '';
|
|
581
580
|
// 기존 문의가 있는 경우
|
|
582
|
-
if(inquiryData.data?.progress_inquiry_number){
|
|
583
|
-
chatNumber=inquiryData.data?.progress_inquiry_number;
|
|
584
|
-
detailResponse= await getChatInquiryDetailNew(inquiryData.data?.progress_inquiry_number);
|
|
581
|
+
if (inquiryData.data?.progress_inquiry_number) {
|
|
582
|
+
chatNumber = inquiryData.data?.progress_inquiry_number;
|
|
583
|
+
detailResponse = await getChatInquiryDetailNew(inquiryData.data?.progress_inquiry_number);
|
|
585
584
|
|
|
586
585
|
chatList = await getChatInquiryMessageList(inquiryData.data?.progress_inquiry_number);
|
|
587
586
|
}
|
|
588
587
|
// 기존 문의가 없는 경우
|
|
589
|
-
else{
|
|
588
|
+
else {
|
|
590
589
|
// 채팅 생성
|
|
591
|
-
const createResponse = await generateChatInquiry(
|
|
592
|
-
|
|
590
|
+
const createResponse = await generateChatInquiry(
|
|
591
|
+
inquiryData.data?.channel_number || '',
|
|
592
|
+
fullUrl,
|
|
593
|
+
centerCode
|
|
594
|
+
);
|
|
595
|
+
if (
|
|
596
|
+
!(
|
|
597
|
+
createResponse.result_info.result_cd === 'OK' ||
|
|
598
|
+
createResponse.result_info.result_type_cd === 'OK'
|
|
599
|
+
)
|
|
600
|
+
) {
|
|
593
601
|
toast.error(getErrorMessageMap(createResponse));
|
|
594
602
|
return createResponse;
|
|
595
603
|
}
|
|
596
|
-
|
|
597
604
|
|
|
598
|
-
chatNumber= createResponse?.data?.chat_inquiry_number || '';
|
|
605
|
+
chatNumber = createResponse?.data?.chat_inquiry_number || '';
|
|
599
606
|
// 채팅 상세 조회
|
|
600
607
|
detailResponse = await getChatInquiryDetailNew(chatNumber);
|
|
601
608
|
// 채팅 메시지 리스트 조회
|
|
@@ -603,20 +610,20 @@ export const useSocketEventHandler = ({
|
|
|
603
610
|
}
|
|
604
611
|
|
|
605
612
|
if (
|
|
606
|
-
!(
|
|
613
|
+
!(
|
|
614
|
+
detailResponse?.result_info?.result_cd === 'OK' ||
|
|
615
|
+
detailResponse?.result_info?.result_type_cd === 'OK'
|
|
616
|
+
)
|
|
607
617
|
) {
|
|
608
618
|
toast.error(getErrorMessageMap(detailResponse));
|
|
609
619
|
return detailResponse;
|
|
610
620
|
}
|
|
611
621
|
|
|
612
|
-
if (
|
|
613
|
-
!(chatList?.result_info?.result_cd === 'OK' || chatList?.result_info?.result_type_cd === 'OK')
|
|
614
|
-
) {
|
|
622
|
+
if (!(chatList?.result_info?.result_cd === 'OK' || chatList?.result_info?.result_type_cd === 'OK')) {
|
|
615
623
|
toast.error(getErrorMessageMap(chatList));
|
|
616
624
|
return chatList;
|
|
617
625
|
}
|
|
618
626
|
|
|
619
|
-
|
|
620
627
|
setChatInquiryNumber(chatNumber);
|
|
621
628
|
if (chatList.data.message_list.length > 0) {
|
|
622
629
|
const uiMessages = chatList.data.message_list
|
|
@@ -651,7 +658,7 @@ export const useSocketEventHandler = ({
|
|
|
651
658
|
setWorkFlowStack(detailResponse.data?.work_flow_progress_stack ?? []);
|
|
652
659
|
}
|
|
653
660
|
|
|
654
|
-
setInquiryMainData({...inquiryData.data, progress_inquiry_number: chatNumber});
|
|
661
|
+
setInquiryMainData({ ...inquiryData.data, progress_inquiry_number: chatNumber });
|
|
655
662
|
if (socket) {
|
|
656
663
|
socketRef.current = socket;
|
|
657
664
|
}
|
|
@@ -680,10 +687,6 @@ export const useSocketEventHandler = ({
|
|
|
680
687
|
setInquiryMainData(result.data as IChatInquiryMainDataResponse);
|
|
681
688
|
}, []);
|
|
682
689
|
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
690
|
return {
|
|
688
691
|
initializeDaeryuntalk,
|
|
689
692
|
|
|
@@ -695,6 +698,6 @@ export const useSocketEventHandler = ({
|
|
|
695
698
|
sendInquiryJoined,
|
|
696
699
|
sendInquiryLeft,
|
|
697
700
|
sendHistoryEntered,
|
|
698
|
-
sendHistoryLeft
|
|
701
|
+
sendHistoryLeft
|
|
699
702
|
};
|
|
700
|
-
};
|
|
703
|
+
};
|
|
@@ -84,7 +84,7 @@ const MapPage = ({ officeList, mapInfo }) => {
|
|
|
84
84
|
<CategoryMenuForPage />
|
|
85
85
|
</div>
|
|
86
86
|
<div className={'m-auto '}>
|
|
87
|
-
<SubPageTitle titleTxt={'오시는 길'} minTitle={'LOCATION'}/>
|
|
87
|
+
<SubPageTitle titleTxt={'오시는 길'} minTitle={'LOCATION'} isViewP={!!mapInfo}/>
|
|
88
88
|
<p className={'mt-[10px] text-[16px] font-bold text-[#7b7b7b] 3xs:text-[16px] sm:text-[16px] md:text-[18px] lg:text-[22px]'}>
|
|
89
89
|
전국 어디서나 365일 24시간 상담접수 가능합니다.
|
|
90
90
|
</p>
|
|
@@ -84,7 +84,7 @@ const MapPage = ({ officeList, mapInfo }: { officeList: IOfficeListTypes[]; mapI
|
|
|
84
84
|
<CategoryMenuForPage />
|
|
85
85
|
</div>
|
|
86
86
|
<div className={'m-auto '}>
|
|
87
|
-
<SubPageTitle titleTxt={'오시는 길'} minTitle={'LOCATION'} />
|
|
87
|
+
<SubPageTitle titleTxt={'오시는 길'} minTitle={'LOCATION'} isViewP={!!mapInfo} />
|
|
88
88
|
<p
|
|
89
89
|
className={
|
|
90
90
|
'mt-[10px] text-[16px] font-bold text-[#7b7b7b] 3xs:text-[16px] sm:text-[16px] md:text-[18px] lg:text-[22px]'
|
|
@@ -8,10 +8,10 @@ const Document = ({ courtFileList, myFileList, id, refetch }) => {
|
|
|
8
8
|
return (<CaseLayout isMobilePadding={false} outerClassName="mt-[35px] sm-top:mt-[24px] lg:mt-[40px] " innerClassName={'pt-[32px] px-[20px] 2sm:px-[40px] sm-top:pt-[56px] sm-top:px-[50px] sm-top:pb-[60px] lg:pt-[60px] lg:pb-[80px] lg:px-[60px]'}>
|
|
9
9
|
<div className="flex h-[48px] w-full overflow-hidden rounded-[12px] bg-grayScale4 sm-top:h-[60px]">
|
|
10
10
|
<button onClick={() => setTap('my')} className={`h-full w-full transition-all duration-300 ${tap === 'my' ? 'rounded-[12px] border-[2px] border-solid border-grayScale4 bg-white sm-top:border-[3px] lg:border-[4px]' : 'border-[4px] border-solid border-grayScale4 text-white'}`}>
|
|
11
|
-
<p className="body_medium1_mo sm-top:body_medium1_tb lg:body_medium1"
|
|
11
|
+
<p className="body_medium1_mo sm-top:body_medium1_tb lg:body_medium1">나의전달문서</p>
|
|
12
12
|
</button>
|
|
13
13
|
<button onClick={() => setTap('court')} className={`h-full w-full transition-all duration-300 ${tap === 'court' ? 'rounded-[12px] border-[2px] border-solid border-grayScale4 bg-white sm-top:border-[3px] lg:border-[4px]' : 'border-[4px] border-solid border-grayScale4 text-white'}`}>
|
|
14
|
-
<p className="body_medium1_mo sm-top:body_medium1_tb lg:body_medium1"
|
|
14
|
+
<p className="body_medium1_mo sm-top:body_medium1_tb lg:body_medium1">법원문서</p>
|
|
15
15
|
</button>
|
|
16
16
|
</div>
|
|
17
17
|
<div className="mt-[16px] lg:mt-[20px]">
|
|
@@ -33,13 +33,13 @@ const Document = ({
|
|
|
33
33
|
onClick={() => setTap('my')}
|
|
34
34
|
className={`h-full w-full transition-all duration-300 ${tap === 'my' ? 'rounded-[12px] border-[2px] border-solid border-grayScale4 bg-white sm-top:border-[3px] lg:border-[4px]' : 'border-[4px] border-solid border-grayScale4 text-white'}`}
|
|
35
35
|
>
|
|
36
|
-
<p className="body_medium1_mo sm-top:body_medium1_tb lg:body_medium1"
|
|
36
|
+
<p className="body_medium1_mo sm-top:body_medium1_tb lg:body_medium1">나의전달문서</p>
|
|
37
37
|
</button>
|
|
38
38
|
<button
|
|
39
39
|
onClick={() => setTap('court')}
|
|
40
40
|
className={`h-full w-full transition-all duration-300 ${tap === 'court' ? 'rounded-[12px] border-[2px] border-solid border-grayScale4 bg-white sm-top:border-[3px] lg:border-[4px]' : 'border-[4px] border-solid border-grayScale4 text-white'}`}
|
|
41
41
|
>
|
|
42
|
-
<p className="body_medium1_mo sm-top:body_medium1_tb lg:body_medium1"
|
|
42
|
+
<p className="body_medium1_mo sm-top:body_medium1_tb lg:body_medium1">법원문서</p>
|
|
43
43
|
</button>
|
|
44
44
|
</div>
|
|
45
45
|
<div className="mt-[16px] lg:mt-[20px]">
|
|
@@ -12,11 +12,11 @@ import { useCallback, useState } from 'react';
|
|
|
12
12
|
import { useActionPostMyFileUpload } from '../../../_actions/action';
|
|
13
13
|
const FileUpload = ({ id, refetch }) => {
|
|
14
14
|
const [uploadedFiles, setUploadedFiles] = useState([]);
|
|
15
|
-
const { mutateAsync
|
|
15
|
+
const { mutateAsync } = useActionPostMyFileUpload(id);
|
|
16
16
|
const [isSuccess, setIsSuccess] = useState(false);
|
|
17
17
|
const onDrop = useCallback((acceptedFiles) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
// setUploadedFiles((prev: File[]) => [...prev, ...acceptedFiles]);
|
|
19
|
-
const res = yield mutateAsync(acceptedFiles
|
|
19
|
+
const res = yield mutateAsync(acceptedFiles);
|
|
20
20
|
if (res.result) {
|
|
21
21
|
setIsSuccess(res.result);
|
|
22
22
|
if (refetch) {
|
|
@@ -44,7 +44,7 @@ const FileUpload = ({ id, refetch }) => {
|
|
|
44
44
|
'image/webp': ['.webp'],
|
|
45
45
|
'image/svg+xml': ['.svg']
|
|
46
46
|
},
|
|
47
|
-
multiple:
|
|
47
|
+
multiple: true,
|
|
48
48
|
maxSize: 10 * 1024 * 1024 // 10MB
|
|
49
49
|
});
|
|
50
50
|
return { getRootProps, getInputProps, isSuccess, setIsSuccess };
|
|
@@ -4,12 +4,11 @@ import { useActionPostMyFileUpload } from '../../../_actions/action';
|
|
|
4
4
|
|
|
5
5
|
const FileUpload = ({ id, refetch }: { id: string; refetch: () => void }) => {
|
|
6
6
|
const [uploadedFiles, setUploadedFiles] = useState<File[]>([]);
|
|
7
|
-
const { mutateAsync
|
|
7
|
+
const { mutateAsync } = useActionPostMyFileUpload(id);
|
|
8
8
|
const [isSuccess, setIsSuccess] = useState(false);
|
|
9
9
|
const onDrop = useCallback(async (acceptedFiles: File[]) => {
|
|
10
10
|
// setUploadedFiles((prev: File[]) => [...prev, ...acceptedFiles]);
|
|
11
|
-
|
|
12
|
-
const res = await mutateAsync(acceptedFiles[0]);
|
|
11
|
+
const res = await mutateAsync(acceptedFiles);
|
|
13
12
|
|
|
14
13
|
if (res.result) {
|
|
15
14
|
setIsSuccess(res.result);
|
|
@@ -39,7 +38,7 @@ const FileUpload = ({ id, refetch }: { id: string; refetch: () => void }) => {
|
|
|
39
38
|
'image/webp': ['.webp'],
|
|
40
39
|
'image/svg+xml': ['.svg']
|
|
41
40
|
},
|
|
42
|
-
multiple:
|
|
41
|
+
multiple: true,
|
|
43
42
|
maxSize: 10 * 1024 * 1024 // 10MB
|
|
44
43
|
});
|
|
45
44
|
|
|
@@ -39,12 +39,17 @@ export declare const useActionGetContact: (id: string) => {
|
|
|
39
39
|
isLoading: boolean;
|
|
40
40
|
isFetched: boolean;
|
|
41
41
|
};
|
|
42
|
+
export type UploadResponse = {
|
|
43
|
+
result: boolean;
|
|
44
|
+
data: any;
|
|
45
|
+
uploads: {
|
|
46
|
+
name: string;
|
|
47
|
+
path: string;
|
|
48
|
+
size: number;
|
|
49
|
+
status: number;
|
|
50
|
+
}[];
|
|
51
|
+
notificationStatus: boolean;
|
|
52
|
+
};
|
|
42
53
|
export declare const useActionPostMyFileUpload: (id: string) => {
|
|
43
|
-
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<
|
|
44
|
-
result: boolean;
|
|
45
|
-
data: any;
|
|
46
|
-
uploadStatus: number;
|
|
47
|
-
notificationStatus: boolean;
|
|
48
|
-
}, unknown, File, unknown>;
|
|
49
|
-
isLoading: boolean;
|
|
54
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<UploadResponse, unknown, File[], unknown>;
|
|
50
55
|
};
|
|
@@ -167,17 +167,12 @@ export const useActionGetContact = (id) => {
|
|
|
167
167
|
};
|
|
168
168
|
export const useActionPostMyFileUpload = (id) => {
|
|
169
169
|
const { mutateAsync, status } = useMutation({
|
|
170
|
-
mutationFn: (
|
|
170
|
+
mutationFn: (files) => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
171
|
return yield addMyFileUpload({
|
|
172
|
-
id
|
|
173
|
-
file:
|
|
172
|
+
id,
|
|
173
|
+
file: files
|
|
174
174
|
});
|
|
175
|
-
})
|
|
176
|
-
onSuccess: res => { },
|
|
177
|
-
onError: error => {
|
|
178
|
-
console.log(error);
|
|
179
|
-
}
|
|
175
|
+
})
|
|
180
176
|
});
|
|
181
|
-
|
|
182
|
-
return { mutateAsync, isLoading };
|
|
177
|
+
return { mutateAsync };
|
|
183
178
|
};
|
|
@@ -185,25 +185,22 @@ export const useActionGetContact = (id: string) => {
|
|
|
185
185
|
});
|
|
186
186
|
return { data, isLoading, isFetched };
|
|
187
187
|
};
|
|
188
|
+
export type UploadResponse = {
|
|
189
|
+
result: boolean;
|
|
190
|
+
data: any;
|
|
191
|
+
uploads: { name: string; path: string; size: number; status: number }[];
|
|
192
|
+
notificationStatus: boolean;
|
|
193
|
+
};
|
|
188
194
|
|
|
189
195
|
export const useActionPostMyFileUpload = (id: string) => {
|
|
190
|
-
const { mutateAsync, status } = useMutation<
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
await addMyFileUpload({
|
|
197
|
-
id: id as string,
|
|
198
|
-
file: file
|
|
199
|
-
}),
|
|
200
|
-
|
|
201
|
-
onSuccess: res => {},
|
|
202
|
-
onError: error => {
|
|
203
|
-
console.log(error);
|
|
196
|
+
const { mutateAsync, status } = useMutation<UploadResponse, unknown, File[]>({
|
|
197
|
+
mutationFn: async (files: File[]) => {
|
|
198
|
+
return await addMyFileUpload({
|
|
199
|
+
id,
|
|
200
|
+
file: files
|
|
201
|
+
});
|
|
204
202
|
}
|
|
205
203
|
});
|
|
206
204
|
|
|
207
|
-
|
|
208
|
-
return { mutateAsync, isLoading };
|
|
205
|
+
return { mutateAsync };
|
|
209
206
|
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
declare const addMyFileUpload: ({ id, file }: {
|
|
2
2
|
id: string;
|
|
3
|
-
file: File;
|
|
3
|
+
file: File[];
|
|
4
4
|
}) => Promise<{
|
|
5
5
|
result: boolean;
|
|
6
6
|
data: any;
|
|
7
|
-
|
|
7
|
+
uploads: {
|
|
8
|
+
name: string;
|
|
9
|
+
path: string;
|
|
10
|
+
size: number;
|
|
11
|
+
status: number;
|
|
12
|
+
}[];
|
|
8
13
|
notificationStatus: any;
|
|
9
14
|
}>;
|
|
10
15
|
export default addMyFileUpload;
|
|
@@ -20,51 +20,60 @@ const addMyFileUpload = (_a) => __awaiter(void 0, [_a], void 0, function* ({ id,
|
|
|
20
20
|
target: 'legalCase',
|
|
21
21
|
caseIdx: parseInt(id, 10),
|
|
22
22
|
parentDir: null,
|
|
23
|
-
fileNames:
|
|
23
|
+
fileNames: file.map(file => file.name)
|
|
24
24
|
})
|
|
25
25
|
});
|
|
26
26
|
if (!response.result) {
|
|
27
27
|
throw new Error('Failed to get S3 presigned URL');
|
|
28
28
|
}
|
|
29
29
|
// 2단계: 받은 presigned URL로 실제 파일을 S3에 업로드
|
|
30
|
-
const uploadData = response.data
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
const uploadData = response.data;
|
|
31
|
+
// 2단계: presigned URL 로 각각의 파일 업로드
|
|
32
|
+
const uploadResults = yield Promise.all(uploadData.map((_a) => __awaiter(void 0, [_a], void 0, function* ({ url: presignedUrl, name }) {
|
|
33
|
+
const targetFile = file.find(f => f.name === name);
|
|
34
|
+
if (!targetFile)
|
|
35
|
+
throw new Error(`File not found for ${name}`);
|
|
36
|
+
const uploadResponse = yield fetch(presignedUrl, {
|
|
37
|
+
method: 'PUT',
|
|
38
|
+
headers: { 'Content-Type': 'application/octet-stream' },
|
|
39
|
+
body: targetFile
|
|
40
|
+
});
|
|
41
|
+
if (!uploadResponse.ok) {
|
|
42
|
+
throw new Error(`S3 upload failed: ${uploadResponse.statusText}`);
|
|
43
|
+
}
|
|
44
|
+
// CloudFront 경로 변환
|
|
45
|
+
const urlObject = new URL(presignedUrl);
|
|
46
|
+
const s3Path = urlObject.pathname;
|
|
47
|
+
const cloudFrontPath = `https://d6robzfync7d.cloudfront.net${s3Path}`;
|
|
48
|
+
return {
|
|
49
|
+
name,
|
|
50
|
+
path: cloudFrontPath,
|
|
51
|
+
size: targetFile.size,
|
|
52
|
+
status: uploadResponse.status
|
|
53
|
+
};
|
|
54
|
+
})));
|
|
55
|
+
// if (!uploadResponse.ok) {
|
|
56
|
+
// throw new Error(`S3 upload failed: ${uploadResponse.statusText}`)
|
|
57
|
+
// }
|
|
43
58
|
// 3단계: 서버에 업로드 완료 알림
|
|
44
|
-
// presigned URL에서 실제 파일 경로 추출
|
|
45
|
-
const urlObject = new URL(presignedUrl);
|
|
46
|
-
const s3Path = urlObject.pathname;
|
|
47
|
-
const cloudFrontPath = `https://d6robzfync7d.cloudfront.net${s3Path}`;
|
|
48
59
|
const notifyResponse = yield Fetch(`/api/lawfirm/app/case/${id}/docs/upload`, {
|
|
49
60
|
method: 'POST',
|
|
50
61
|
headers: {
|
|
51
|
-
// Authorization: `${jwt}
|
|
62
|
+
// Authorization: `${jwt}`,
|
|
52
63
|
},
|
|
53
64
|
body: JSON.stringify({
|
|
54
65
|
caseIdx: parseInt(id, 10),
|
|
55
|
-
files:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
]
|
|
66
|
+
files: uploadResults.map(({ name, path, size }) => ({
|
|
67
|
+
name,
|
|
68
|
+
path,
|
|
69
|
+
size
|
|
70
|
+
}))
|
|
62
71
|
})
|
|
63
72
|
});
|
|
64
73
|
return {
|
|
65
74
|
result: true,
|
|
66
75
|
data: response.data,
|
|
67
|
-
|
|
76
|
+
uploads: uploadResults,
|
|
68
77
|
notificationStatus: notifyResponse.result
|
|
69
78
|
};
|
|
70
79
|
}
|