11import axios from 'axios' ;
22import React , { useEffect , useState } from 'react' ;
3+ import { useDispatch } from 'react-redux' ;
4+ import { useNavigate } from 'react-router-dom' ;
5+ import { bindActionCreators } from 'redux' ;
36
47import { FileListBox } from '../../components' ;
5- import { getFileSize , getShortFileName } from '../../utils' ;
8+ import { actionCreators } from '../../state' ;
9+ import { getFileSize , getShortFileName , getDate } from '../../utils' ;
610import * as S from './styled' ;
711
812export const FileListPage : React . FC = ( ) => {
13+ const navigate = useNavigate ( ) ;
914 const [ loading , setLoading ] = useState ( false ) ;
1015 const SkeletonUIRandomWidth = [ '50' , '55' , '60' , '65' , '70' , '75' , '80' ] ;
16+ const dispatch = useDispatch ( ) ;
17+ const { SetDownloadFileProps } = bindActionCreators ( actionCreators , dispatch ) ;
1118 const [ fileList , setFileList ] = useState < any [ ] > ( ) ;
1219 const getFileList = async ( ) => {
1320 await axios ( {
1421 method : 'get' ,
1522 url : 'https://tfb.minpeter.cf/list' ,
1623 } )
1724 . then ( ( res ) => {
18- setFileList ( res . data . list ) ;
25+ setFileList ( res . data . list ) ; //파일리스트 요소 갯수에 따른 핸들링 추가예정
1926 setTimeout ( ( ) => {
2027 setLoading ( true ) ; //loading 확인하고싶으면 false로 바꿔주세요.
21- } , 2000 ) ;
28+ } , 1500 ) ;
2229 } )
2330 . catch ( ( err ) => {
2431 console . log ( err ) ;
@@ -37,7 +44,16 @@ export const FileListPage: React.FC = () => {
3744 key = { index }
3845 filename = { getShortFileName ( item . Name ) }
3946 size = { getFileSize ( item . Size ) }
40- LastModified = { new Date ( item . LastModified ) }
47+ LastModified = { getDate ( item . LastModified ) }
48+ click = { ( ) => {
49+ SetDownloadFileProps ( {
50+ Name : item . Name ,
51+ Size : item . Size ,
52+ LastModified : item . LastModified ,
53+ //passowrd 유무 추가예정
54+ } ) ;
55+ navigate ( '/download' ) ;
56+ } }
4157 />
4258 ) ) }
4359 </ S . FileListPageContainer >
0 commit comments