diff --git a/apps/sn/app/components/lib/common/date.ts b/apps/sn/app/components/lib/common/date.ts new file mode 100644 index 000000000..4b7aa1e73 --- /dev/null +++ b/apps/sn/app/components/lib/common/date.ts @@ -0,0 +1,5 @@ +export const formatDate = (date: Date): string => { + if (!date) return ''; + const isoString = date.toISOString(); + return isoString ? isoString.split('T')[0] || '' : ''; +}; diff --git a/apps/sn/app/components/lib/common/fileDownload.ts b/apps/sn/app/components/lib/utils/fileDownload.ts similarity index 91% rename from apps/sn/app/components/lib/common/fileDownload.ts rename to apps/sn/app/components/lib/utils/fileDownload.ts index 8c760b1cc..681203196 100644 --- a/apps/sn/app/components/lib/common/fileDownload.ts +++ b/apps/sn/app/components/lib/utils/fileDownload.ts @@ -1,9 +1,8 @@ -const handleDownload = async (api:string, fileNm:string) => { +export const handleDownload = async (api:string, fileNm:string) => { try { const response = await fetch(api, { method: 'GET', }); - if (!response.ok) { throw new Error('파일 다운로드 실패'); } diff --git a/apps/sn/app/components/lib/utils/index.tsx b/apps/sn/app/components/lib/utils/index.tsx index 519afbc11..9cbcba6bb 100644 --- a/apps/sn/app/components/lib/utils/index.tsx +++ b/apps/sn/app/components/lib/utils/index.tsx @@ -1,2 +1,3 @@ export { getCookie, setCookie, removeCookie } from "./cookie"; export { handleUpload } from "./fileUploadUtil"; +export * from "./fileDownload"; diff --git a/apps/sn/app/components/ui/fileUploadForm.tsx b/apps/sn/app/components/ui/fileUploadForm.tsx index 3c57bb812..d41f56709 100644 --- a/apps/sn/app/components/ui/fileUploadForm.tsx +++ b/apps/sn/app/components/ui/fileUploadForm.tsx @@ -4,17 +4,16 @@ import { FileUpload, SelectBox } from '@common/business_components/ui'; import { Button, Input } from '@common/components/ui'; import React, { useState } from 'react' -const FileUploadForm = ({ title }: { title: string }) => { - const [files, setFiles] = useState(null); - const [selectedYear, setSelectedYear] = useState(''); - const [selectedQuarter, setSelectedQuarter] = useState(''); - - // 현재 년도부터 10년 전까지의 년도 옵션 생성 +const FileUploadForm = ({ title, onSubmit }: { title: string, onSubmit:(files:FileList, year:string, quarter:string) => void }) => { + // 현재 년도부터 10년 전까지의 년도 옵션 생성 const yearOptions = Array.from({ length: 10 }, (_, i) => { const year = new Date().getFullYear() - i; return { text: `${year}년`, val: year.toString() }; }); const quater = [{text: '1분기', val: '1'}, {text: '2분기', val: '2'}, {text: '3분기', val: '3'}, {text: '4분기', val: '4'}] + const [files, setFiles] = useState(null); + const [selectedYear, setSelectedYear] = useState(yearOptions[0]?.val || ''); + const [selectedQuarter, setSelectedQuarter] = useState(quater[0]?.val || ''); return (
@@ -39,18 +38,18 @@ const FileUploadForm = ({ title }: { title: string }) => {
- + {if(e.target.files)setFiles(e.target.files)}}/>
- - - -
-

사업정보 등록현황

-
- - +
+ + setManageYear(e.target.value)} + /> + ~ + setMngQu(e.target.value)} + /> +
+
+ + setUsr(e.target.value)} + /> +
+
+ + setpjNm(e.target.value)} + />
- {console.log(index, headId) }} onPageChange={function (page: number): void { - throw new Error('Function not implemented.') - }}> - - - - - - ) + + + + + + +
+

사업정보 등록현황

+
+ + +
+
+ { if (index != null) { const fileName = tableData[index]?.fileNm ?? ""; setFileNm(fileName) } }} onPageChange={function (page: number): void { + throw new Error('Function not implemented.') + }}> +
+ + {}}/> + + +) } export default Page \ No newline at end of file diff --git a/apps/sn/app/oper/oldPp/page.tsx b/apps/sn/app/oper/oldPp/page.tsx index c7184a0fd..4f91d5121 100644 --- a/apps/sn/app/oper/oldPp/page.tsx +++ b/apps/sn/app/oper/oldPp/page.tsx @@ -6,17 +6,29 @@ import FileUploadForm from '../../components/ui/fileUploadForm' import ListDiv from '@common/business_components/ui/list_div' import ContentLayout from '@/components/ui/contentLayout' import { tableHeadlist } from '..' +import { handleDownload } from '@/components/lib/utils/fileDownload' +import { searchData } from '@/components/lib/common/apiHelpers' +import { formatDate } from '@/components/lib/common/date' // TODO: 임시 id -export const tableData = [{'no':'1', 'fileNm':'2023년 노후하수관로 정비사업', 'mngYr':'2023', 'mngQu':'1', 'registDt':'2023-10-01', 'registUsr':'홍길동'},] +export const tableData = [{ 'no': '1', 'fileNm': '2023년 노후하수관로 정비사업', 'mngYr': '2023', 'mngQu': '1', 'registDt': '2023-10-01', 'registUsr': '홍길동' },] const Page = () => { const [fromDate, setFromDate] = useState(new Date()); const [toDate, setToDate] = useState(new Date()); - const [company, setCompany] = useState('') + const [manageYear, setManageYear] = useState('') + const [mngQu, setMngQu] = useState('') + const [usr, setUsr] = useState('') const [pjNm, setpjNm] = useState('') - const searchData = ()=> { - - } + const [fileNm, setFileNm] = useState('') + const isChckFile = () => { + if (fileNm === '' || fileNm === undefined) { + alert('파일을 선택해주세요') + return false + } + // TODO: 추후 파일코드 동적으로 세팅 + handleDownload('/sn/attach-service/api/v1/download/6066b08c-2a55-438c-b8ff-2aed9739a0c6', fileNm) + return true + } return ( @@ -31,12 +43,26 @@ const Page = () => { { if (date) setToDate(date) }} /> +
+ + setManageYear(e.target.value)} + /> + ~ + setMngQu(e.target.value)} + /> +
setCompany(e.target.value)} + value={usr} + onChange={(e) => setUsr(e.target.value)} />
@@ -51,23 +77,23 @@ const Page = () => {
- +

사업정보 등록현황

- +
- { }} onPageChange={function (page: number): void { + { if (index != null) { const fileName = tableData[index]?.fileNm ?? ""; setFileNm(fileName) } }} onPageChange={function (page: number): void { throw new Error('Function not implemented.') }}>
- + { }} />
)