@@ -51,4 +51,6 @@ export const handleUpload = (files: FileList, options?: UploadOptions) => {
|
|||||||
|
|
||||||
upload.start();
|
upload.start();
|
||||||
options?.handleUploadStart?.(upload);
|
options?.handleUploadStart?.(upload);
|
||||||
|
|
||||||
|
console.log("upload start");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,16 @@ import { FileUploader } from "@common/components";
|
|||||||
import { handleUpload } from "@utils";
|
import { handleUpload } from "@utils";
|
||||||
|
|
||||||
const FileUploadForm = ({ title, onSubmit }: { title: string, onSubmit:(files:FileList, year:string, quarter:string) => void }) => {
|
const FileUploadForm = ({ title, onSubmit }: { title: string, onSubmit:(files:FileList, year:string, quarter:string) => void }) => {
|
||||||
|
|
||||||
|
const handleUploadResponse = (file: File) => async (res: HttpResponse) => {
|
||||||
|
const fileInfo = res.getHeader("X-File-Info");
|
||||||
|
if (!fileInfo) return;
|
||||||
|
|
||||||
|
const { atflCd, atflId } = JSON.parse(fileInfo) ?? {};
|
||||||
|
const orgnlFileNm = file.name;
|
||||||
|
|
||||||
|
console.log(atflCd, atflId, orgnlFileNm);
|
||||||
|
};
|
||||||
|
|
||||||
// 현재 년도부터 10년 전까지의 년도 옵션 생성
|
// 현재 년도부터 10년 전까지의 년도 옵션 생성
|
||||||
const yearOptions = Array.from({ length: 10 }, (_, i) => {
|
const yearOptions = Array.from({ length: 10 }, (_, i) => {
|
||||||
@@ -17,6 +27,8 @@ const FileUploadForm = ({ title, onSubmit }: { title: string, onSubmit:(files:Fi
|
|||||||
const [files, setFiles] = useState<FileList | null>(null);
|
const [files, setFiles] = useState<FileList | null>(null);
|
||||||
const [selectedYear, setSelectedYear] = useState<string>(yearOptions[0]?.val || '');
|
const [selectedYear, setSelectedYear] = useState<string>(yearOptions[0]?.val || '');
|
||||||
const [selectedQuarter, setSelectedQuarter] = useState<string>(quater[0]?.val || '');
|
const [selectedQuarter, setSelectedQuarter] = useState<string>(quater[0]?.val || '');
|
||||||
|
const [upload, setUpload] = useState<Upload | null>(null);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className='card-header'>
|
<div className='card-header'>
|
||||||
@@ -49,7 +61,9 @@ const FileUploadForm = ({ title, onSubmit }: { title: string, onSubmit:(files:Fi
|
|||||||
if (!selectedFiles) return;
|
if (!selectedFiles) return;
|
||||||
|
|
||||||
const fileArray = Array.from(selectedFiles);
|
const fileArray = Array.from(selectedFiles);
|
||||||
setFiles(fileArray);
|
if(!fileArray){
|
||||||
|
setFiles(fileArray);
|
||||||
|
}
|
||||||
if (fileArray[0]) {
|
if (fileArray[0]) {
|
||||||
handleUpload(selectedFiles, {
|
handleUpload(selectedFiles, {
|
||||||
handleUploadStart: setUpload,
|
handleUploadStart: setUpload,
|
||||||
@@ -57,6 +71,7 @@ const FileUploadForm = ({ title, onSubmit }: { title: string, onSubmit:(files:Fi
|
|||||||
handleResponse: handleUploadResponse(fileArray[0]),
|
handleResponse: handleUploadResponse(fileArray[0]),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
customPreview={<></>}
|
customPreview={<></>}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const Page = () => {
|
|||||||
alert('파일을 선택해주세요')
|
alert('파일을 선택해주세요')
|
||||||
}
|
}
|
||||||
// TODO: 추후 파일코드 동적으로 세팅
|
// TODO: 추후 파일코드 동적으로 세팅
|
||||||
handleDownload('/sn/attach-service/api/v1/download/6066b08c-2a55-438c-b8ff-2aed9739a0c6', fileNm)
|
handleDownload('/attach-service/api/v1/download/6066b08c-2a55-438c-b8ff-2aed9739a0c6', fileNm)
|
||||||
}
|
}
|
||||||
//TODO: 파일 업로드 처리
|
//TODO: 파일 업로드 처리
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user