From cecc51f29adf394e2303db04fce342c285c946b9 Mon Sep 17 00:00:00 2001 From: Lim Jonguk Date: Tue, 5 Apr 2022 05:25:35 +0900 Subject: [PATCH] fix: file form fix --- src/themes/compStyleOverride.js | 2 +- src/views/biz/board/PublicBoardForm.jsx | 58 +++++++++---------------- src/views/form/FileForm.jsx | 46 ++++++++++++++++++++ src/views/form/FileInputForm.jsx | 10 ++++- 4 files changed, 76 insertions(+), 40 deletions(-) create mode 100644 src/views/form/FileForm.jsx diff --git a/src/themes/compStyleOverride.js b/src/themes/compStyleOverride.js index 7c9df8a..e20c53b 100755 --- a/src/themes/compStyleOverride.js +++ b/src/themes/compStyleOverride.js @@ -9,7 +9,7 @@ export default function componentStyleOverrides(theme, borderRadius, outlinedFil styleOverrides: { root: { fontWeight: 500, - borderRadius: '4px' + borderRadius: '3px' } } }, diff --git a/src/views/biz/board/PublicBoardForm.jsx b/src/views/biz/board/PublicBoardForm.jsx index ad0fef4..12dc62f 100644 --- a/src/views/biz/board/PublicBoardForm.jsx +++ b/src/views/biz/board/PublicBoardForm.jsx @@ -16,6 +16,8 @@ import InputLabel from 'ui-component/extended/Form/InputLabel'; import { Delete, FileDownload, FileUpload, List, Save } from '@mui/icons-material'; import { fileDownload } from '../../../apis/common'; import FileInputForm from '../../form/FileInputForm'; +import FileInputForms from '../../form/FileInputForms'; +import FileForm from 'views/form/FileForm'; const PublicBoardForm = (props) => { // eslint-disable-next-line react/prop-types @@ -112,16 +114,15 @@ const PublicBoardForm = (props) => { [] ); - /* const onChangeFile = (file) => { setSelectedFile(file.name); setFilesInfo([file]); }; -*/ - const onChangeFile = (e) => { - setSelectedFile(e.target.files[0].name); - setFilesInfo(e.target.files); - }; + + // const onChangeFile = (e) => { + // setSelectedFile(e.target.files[0].name); + // setFilesInfo(e.target.files); + // }; const handleFileDownload = () => { if (!inFilename) { @@ -150,9 +151,6 @@ const PublicBoardForm = (props) => { onChange={(e) => setDept(e.target.value)} fullWidth > - {/* */} - {/* None */} - {/* */} 주정차위반 장애인위반 기타 @@ -173,35 +171,8 @@ const PublicBoardForm = (props) => { - - - - - ) - }} - /> - - {/* */} - - - {selectedFile ? : } - - - - + { @@ -217,6 +188,19 @@ const PublicBoardForm = (props) => { /> + + + + + diff --git a/src/views/form/FileForm.jsx b/src/views/form/FileForm.jsx new file mode 100644 index 0000000..c48f05a --- /dev/null +++ b/src/views/form/FileForm.jsx @@ -0,0 +1,46 @@ +import * as React from 'react'; +import { Button, Grid, InputAdornment, TextField } from '@mui/material'; +import { FileDownload, FileUpload } from '@mui/icons-material'; + +const FileForm = ({ isDownload = false, labelName, selectedFile, handleChangeFile, handleFileDownload, alert }) => { + const onChangeFile = (e) => { + const file = e.target.files[0]; + if (file.type.includes('image')) { + alert.show({`${file.name}`}); + } + handleChangeFile(file); + }; + + return ( + + + {isDownload ? ( + + + + ) + }} + onClick={handleFileDownload} + /> + ) : ( + + )} + + + + + + ); +}; + +export default FileForm; diff --git a/src/views/form/FileInputForm.jsx b/src/views/form/FileInputForm.jsx index 1fb9a76..7364640 100644 --- a/src/views/form/FileInputForm.jsx +++ b/src/views/form/FileInputForm.jsx @@ -14,10 +14,16 @@ const FileInputForm = ({ labelName, selectedFile, handleChangeFile, alert }) => return ( - } onClick={() => {}} /> + } + onClick={() => {}} + /> -