feat: 주정차의견진술 자료 등록 반영

main
minuk926 3 years ago
parent e02e319530
commit ee132cbdbb

@ -1,14 +1,17 @@
import axios from 'utils/axios'; import axios from 'utils/axios';
import FileSaver from 'file-saver'; import FileSaver from 'file-saver';
import { GET_CMM_CODE_LIST, GET_FILE_DOWNLOAD } from 'commons/ApiUrl'; import { GET_CMM_CODE_LIST, GET_FILE_DOWNLOAD } from 'commons/ApiUrl';
import { useCallback, useState } from 'react';
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Common : 공통 // Common : 공통
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
export function getComboCodeList(params) { export async function getComboCodeList(param) {
const params = { ...param, codeGrpId: 'TRAFFIC', codeLcd: 'GANGNAM_SIMSA' };
// eslint-disable-next-line no-return-await // eslint-disable-next-line no-return-await
return async () => await axios.get(GET_CMM_CODE_LIST, { params }); const res = await axios.get(GET_CMM_CODE_LIST, { params });
return res;
} }
// TODO: 헤더에서 파일 정보 읽을 수 있도록 변경 필요 // TODO: 헤더에서 파일 정보 읽을 수 있도록 변경 필요

@ -0,0 +1,10 @@
const combo = {
teams: [
{ code: '001', value: '1팀' },
{ code: '002', value: '2팀' },
{ code: '003', value: '3팀' },
{ code: '004', value: '4팀' }
]
};
export default combo;

@ -83,7 +83,7 @@ const PublicBoard = () => {
const handleOnCellClick = (e) => { const handleOnCellClick = (e) => {
if (e?.field === 'inTitle') { if (e?.field === 'inTitle') {
setCreate(false); setCreate(false);
setTitle('공지사 변경'); setTitle('공지사 변경');
setSelectedRow(e?.row); setSelectedRow(e?.row);
modifyPublicBoardHitCount(e?.row?.inCode); modifyPublicBoardHitCount(e?.row?.inCode);
setOpen(true); setOpen(true);
@ -120,7 +120,7 @@ const PublicBoard = () => {
<Grid container alignItems="right"> <Grid container alignItems="right">
<Grid item> <Grid item>
<Button variant="contained" size="small" onClick={handleCreate}> <Button variant="contained" size="small" onClick={handleCreate}>
공지사항등록 공지사항 등록
</Button> </Button>
</Grid> </Grid>
</Grid> </Grid>

@ -2,7 +2,7 @@ import { useMemo, useRef, useState } from 'react';
import { useAlert } from 'react-alert'; import { useAlert } from 'react-alert';
// material-ui // material-ui
import { Button, Grid, IconButton, InputAdornment, MenuItem, Select, TextField } from '@mui/material'; import { Button, FormControl, Grid, IconButton, InputAdornment, MenuItem, Select, TextField } from '@mui/material';
// assets // assets
@ -15,6 +15,7 @@ import InputLabel from 'ui-component/extended/Form/InputLabel';
import { Delete, FileDownload, FileUpload, List, Save } from '@mui/icons-material'; import { Delete, FileDownload, FileUpload, List, Save } from '@mui/icons-material';
import { fileDownload } from '../../../apis/common'; import { fileDownload } from '../../../apis/common';
import FileInputForm from '../../form/FileInputForm';
const PublicBoardForm = (props) => { const PublicBoardForm = (props) => {
// eslint-disable-next-line react/prop-types // eslint-disable-next-line react/prop-types
@ -111,6 +112,12 @@ const PublicBoardForm = (props) => {
[] []
); );
/*
const onChangeFile = (file) => {
setSelectedFile(file.name);
setFilesInfo([file]);
};
*/
const onChangeFile = (e) => { const onChangeFile = (e) => {
setSelectedFile(e.target.files[0].name); setSelectedFile(e.target.files[0].name);
setFilesInfo(e.target.files); setFilesInfo(e.target.files);
@ -126,37 +133,47 @@ const PublicBoardForm = (props) => {
return ( return (
<> <>
<Grid container spacing={2}> <Grid mt={2}>
<Grid item xs={12} sm={4}> <Grid container spacing={1} item xs={12} mb={1}>
<TextField required label="제목" value={subject} onChange={(e) => setSubject(e.target.value)} fullWidth /> <Grid item xs={12} sm={6}>
</Grid> <TextField size="small" required label="제목" value={subject} onChange={(e) => setSubject(e.target.value)} fullWidth />
<Grid item xs={12} sm={6}> </Grid>
{/* <FormControl variant="filled" sx={{ m:1, minWidth: 120 }}> */} <Grid item xs={12} sm={3}>
{/* <InputLabel id="demo-simple-select-filled-label">Age</InputLabel> */} <FormControl fullWidth>
<Select disabled={!create} label="업무구분" required value={dept} onChange={(e) => setDept(e.target.value)} fullWidth> <InputLabel required>진술유형</InputLabel>
{/* <MenuItem value=""> */} <Select
{/* <em>None</em> */} size="small"
{/* </MenuItem> */} disabled={!create}
<MenuItem value="주정차위반">주정차위반</MenuItem> label="업무구분"
<MenuItem value="장애인위반">장애인위반</MenuItem> required
<MenuItem value="기타">기타</MenuItem> value={dept}
</Select> onChange={(e) => setDept(e.target.value)}
{/* </FormControl> */} fullWidth
</Grid> >
<Grid item xs={12} sm={6}> {/* <MenuItem value=""> */}
<TextField disabled label="등록일" value={inNalja} fullWidth /> {/* <em>None</em> */}
</Grid> {/* </MenuItem> */}
<Grid item xs={12} sm={6}> <MenuItem value="주정차위반">주정차위반</MenuItem>
<TextField disabled label="번호" value={inCode} fullWidth /> <MenuItem value="장애인위반">장애인위반</MenuItem>
</Grid> <MenuItem value="기타">기타</MenuItem>
<Grid item xs={12} sm={6}> </Select>
<TextField disabled label="조회수" value={inHit} fullWidth /> </FormControl>
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid item xs={12} sm={3}>
<TextField disabled label="작성자" value={inName} fullWidth /> <TextField size="small" disabled label="작성자" value={inName} fullWidth />
</Grid>
</Grid> </Grid>
<Grid item xs={12} sm={6}> <Grid container spacing={1} item xs={12} mb={1}>
<Grid> <Grid item xs={12} sm={3}>
<TextField size="small" disabled label="등록일" value={inNalja} fullWidth />
</Grid>
<Grid item xs={12} sm={3}>
<TextField size="small" disabled label="번호" value={inCode} fullWidth />
</Grid>
<Grid item xs={12} sm={3}>
<TextField size="small" disabled label="조회수" value={inHit} fullWidth />
</Grid>
<Grid item xs={12} sm={3}>
<TextField <TextField
// label="" // label=""
value={selectedFile} value={selectedFile}
@ -182,26 +199,23 @@ const PublicBoardForm = (props) => {
{selectedFile ? <FileDownload fontSize="small" /> : <FileUpload fontSize="small" />} {selectedFile ? <FileDownload fontSize="small" /> : <FileUpload fontSize="small" />}
</IconButton> </IconButton>
</InputLabel> </InputLabel>
{/* </Tooltip> */}
{/* <InputLabel>{selectedFile ? selectedFile.name : 'Select Image'}</InputLabel>. . . */}
{/* <Button onClick={onSaveFile} color="primary"> */}
{/* Save */}
{/* </Button> */}
</Grid> </Grid>
</Grid> </Grid>
<Grid item xs={12}> <Grid container spacing={1} item xs={12} mt={1.5} mb={2}>
<ReactQuill <Grid item xs={12}>
ref={(element) => { <ReactQuill
if (element !== null) { ref={(element) => {
quillRef.current = element; if (element !== null) {
} quillRef.current = element;
}} }
value={contents} }}
onChange={setContents} value={contents}
modules={modules} onChange={setContents}
theme="snow" modules={modules}
placeholder="내용을 입력해주세요." theme="snow"
/> placeholder="내용을 입력해주세요."
/>
</Grid>
</Grid> </Grid>
</Grid> </Grid>
<Grid item container spacing={0.5} xs={12}> <Grid item container spacing={0.5} xs={12}>

@ -5,7 +5,7 @@ import getYear from 'date-fns/getYear';
// material-ui // material-ui
import { GridActionsCellItem } from '@mui/x-data-grid'; import { GridActionsCellItem } from '@mui/x-data-grid';
import { Divider, Grid, InputAdornment, Link, MenuItem, OutlinedInput, Select } from '@mui/material'; import { Divider, FormControl, Grid, InputAdornment, Link, MenuItem, OutlinedInput, Select } from '@mui/material';
import DeleteIcon from '@mui/icons-material/Delete'; import DeleteIcon from '@mui/icons-material/Delete';
import MuiTooltip from '@mui/material/Tooltip'; import MuiTooltip from '@mui/material/Tooltip';
@ -20,6 +20,7 @@ import MuiDataGrid from 'views/form/MuiDataGrid';
import xitCmm from 'commons/XitCmm'; import xitCmm from 'commons/XitCmm';
import ModalDetails from './ModalDetails'; import ModalDetails from './ModalDetails';
import { getSimsa680GroupList } from 'apis/parking'; import { getSimsa680GroupList } from 'apis/parking';
import InputLabel from '../../../ui-component/extended/Form/InputLabel';
const ParkingReview = () => { const ParkingReview = () => {
const isInit = useRef(true); const isInit = useRef(true);
@ -149,7 +150,8 @@ const ParkingReview = () => {
<Grid item xs={12}> <Grid item xs={12}>
<Grid container spacing={1}> <Grid container spacing={1}>
<Grid item xs={2}> <Grid item xs={2}>
<MuiTooltip title="의견진술 심의 년도"> <FormControl fullWidth>
<InputLabel required>심의 년도</InputLabel>
<Select <Select
size="small" size="small"
id="reviewYear" id="reviewYear"
@ -163,16 +165,7 @@ const ParkingReview = () => {
</MenuItem> </MenuItem>
))} ))}
</Select> </Select>
</MuiTooltip> </FormControl>
{/* <Autocomplete */}
{/* disableClearable */}
{/* value={year} */}
{/* onChange={(event, newValue) => newValue && setSelectedYear(newValue)} */}
{/* // id="controllable-states-demo" */}
{/* options={years} */}
{/* renderInput={(params) => <TextField {...params} label="의견진술심의년도" />} */}
{/* /> */}
</Grid> </Grid>
<Grid item> <Grid item>
<OutlinedInput <OutlinedInput

@ -13,16 +13,12 @@ import Button from '@mui/material/Button';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { IconFileExport } from '@tabler/icons'; import { IconFileExport } from '@tabler/icons';
const teams = [ import combo from 'commons/combo_data';
{ code: '001', value: '1팀' },
{ code: '002', value: '2팀' },
{ code: '003', value: '3팀' },
{ code: '004', value: '4팀' }
];
const toDate = new Date(); const toDate = new Date();
const SaveParkingSimsaForm = ({ isDisabled = true, handleModalSave }) => { const SaveParkingSimsaForm = ({ isDisabled = true, handleModalSave }) => {
const [msuTeam, setMsuTeam] = useState(teams[0].code); const [msuTeam, setMsuTeam] = useState(combo.teams[0].code);
const [msSdate, setMsSdate] = useState(format(toDate, 'yyyy-MM-dd')); const [msSdate, setMsSdate] = useState(format(toDate, 'yyyy-MM-dd'));
const [msStartsi, setMsStartsi] = useState(getHours(toDate)); const [msStartsi, setMsStartsi] = useState(getHours(toDate));
const [msEdate, setMsEdate] = useState(format(toDate, 'yyyy-MM-dd')); const [msEdate, setMsEdate] = useState(format(toDate, 'yyyy-MM-dd'));
@ -44,7 +40,7 @@ const SaveParkingSimsaForm = ({ isDisabled = true, handleModalSave }) => {
return ( return (
<> <>
<Grid container spacing={2}> <Grid container spacing={2} mt={1.5}>
<Grid item xs={12} sm={4}> <Grid item xs={12} sm={4}>
<LocalizationProvider dateAdapter={DateAdapter} locale={koLocale}> <LocalizationProvider dateAdapter={DateAdapter} locale={koLocale}>
<DatePicker <DatePicker
@ -98,7 +94,7 @@ const SaveParkingSimsaForm = ({ isDisabled = true, handleModalSave }) => {
<FormControl fullWidth> <FormControl fullWidth>
<InputLabel required></InputLabel> <InputLabel required></InputLabel>
<Select name="reviewYear" defaultValue={msuTeam} onChange={(e) => setMsuTeam(e.target.value)}> <Select name="reviewYear" defaultValue={msuTeam} onChange={(e) => setMsuTeam(e.target.value)}>
{teams.map((team) => ( {combo.teams.map((team) => (
<MenuItem key={team.code} value={team.code}> <MenuItem key={team.code} value={team.code}>
{team.value} {team.value}
</MenuItem> </MenuItem>

@ -11,6 +11,7 @@ import PublicBoardForm from '../board/PublicBoardForm';
import CmmModal from '../../form/Modal/CmmModal'; import CmmModal from '../../form/Modal/CmmModal';
import { getResidents } from '../../../apis/resident'; import { getResidents } from '../../../apis/resident';
import xitCmm from '../../../commons/XitCmm'; import xitCmm from '../../../commons/XitCmm';
import SaveResidentDataForm from './SaveResidentDataForm';
const ResidentDataReview = () => { const ResidentDataReview = () => {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@ -65,7 +66,7 @@ const ResidentDataReview = () => {
}, [rowsState.page, rowsState.pageSize]); }, [rowsState.page, rowsState.pageSize]);
const handleCreate = () => { const handleCreate = () => {
setTitle('의견진술 자료 등록'); setTitle('거주자 의견진술 자료 신규 등록');
setCreate(true); setCreate(true);
setOpen(true); setOpen(true);
}; };
@ -89,7 +90,7 @@ const ResidentDataReview = () => {
</Grid> </Grid>
<MuiDataGrid columns={columns} rowsState={rowsState} totalCount={totalCount} setRowsState={setRowsState} /> <MuiDataGrid columns={columns} rowsState={rowsState} totalCount={totalCount} setRowsState={setRowsState} />
<CmmModal isBackdrop title={title} open={open} setOpen={setOpen}> <CmmModal isBackdrop title={title} open={open} setOpen={setOpen}>
<h2>자료등록 modal</h2> <SaveResidentDataForm handleModalSave={() => {}} />
</CmmModal> </CmmModal>
</MainCard> </MainCard>
); );

@ -0,0 +1,246 @@
import { useCallback, useEffect, useState } from 'react';
import NumberFormat from 'react-number-format';
import format from 'date-fns/format';
import getHours from 'date-fns/getHours';
import koLocale from 'date-fns/locale/ko';
import { Grid, TextField, MenuItem, Select, FormControl, InputLabel, IconButton, InputAdornment } from '@mui/material';
import DateAdapter from '@mui/lab/AdapterDateFns';
import LocalizationProvider from '@mui/lab/LocalizationProvider';
import { DatePicker, TimePicker } from '@mui/lab';
import Button from '@mui/material/Button';
import PropTypes from 'prop-types';
import { IconFileExport } from '@tabler/icons';
import { getComboCodeList } from 'apis/common';
import combo from '../../../commons/combo_data';
import { FileDownload, FileUpload } from '@mui/icons-material';
import { useAlert } from 'react-alert';
import FileInputForm from '../../form/FileInputForm';
import FileInputForms from '../../form/FileInputForms';
const toDate = new Date();
const SaveResidentDataForm = ({ isDisabled = true, handleModalSave }) => {
const alert = useAlert();
const [scCarnum, setScCarnum] = useState();
const [scName, setScName] = useState();
const [scDong, setScDong] = useState();
const [scContDoc, setScContDoc] = useState();
const [selectedContDoc, setSelectedContDoc] = useState();
const [scIngb, setScIngb] = useState();
const [selectedIngb, setSelectedIngb] = useState();
const [zippost1, setZippost1] = useState();
const [scJuso, setScJuso] = useState();
const [scBunji, setScBunji] = useState();
const [scWdate, setScWdate] = useState();
const [scCdate, setScCdate] = useState();
const [scJbtime, setScJbtime] = useState();
const [scPicad, setScPcad] = useState([]);
const [selectedImgFile, setSelectedImgFile] = useState('');
const [selectedFile, setSelectedFile] = useState('');
const onSave = () => {
handleModalSave({});
};
useEffect(() => {
// setSelectedContDoc('11');
setScContDoc([]);
getComboCodeList({ codeMcd: 'SC_CONT_DOC' }).then((res) => {
console.log(res);
setScContDoc(res.data);
});
getComboCodeList({ codeMcd: 'RC_INGB' }).then((res) => {
console.log(res);
setScIngb(res.data);
});
}, []);
const handleChangeFile = (e) => {
// eslint-disable-next-line no-debugger
// debugger;
// console.log(e);
const idx = Number(e.target.dataset.index) + 1;
setScPcad([...scPicad, e.target.files[0]]);
// setScPcad([...scPicad, {`[${e.target.name}]${idx}`: e.target.files[0] });
console.log(scPicad);
// console.log(e);
// setSelectedFile(e.target.files[0].name);
// setFilesInfo(e.target.files);
// setSelectedFile(file.name);
// alert.show(<img alt="sample" src={URL.createObjectURL(e.target.files[0])} style={{ margin: 'auto' }} />);
// setSelectedImgFile(URL.createObjectURL(e.target.files[0]));
};
return (
<>
<Grid mt={2}>
<Grid container spacing={0.5} item xs={12} mb={1.5}>
<Grid item sm={3}>
<TextField
required
label="차량번호"
size="small"
fullWidth
value={scCarnum}
onValueChange={(values) => setScCarnum(values.value)}
/>
</Grid>
<Grid item sm={3}>
<TextField required label="성명" size="small" fullWidth value={scName} onValueChange={(values) => setScName(values.value)} />
</Grid>
<Grid item sm={3}>
<TextField required label="동명" size="small" fullWidth value={scDong} onValueChange={(values) => setScDong(values.value)} />
</Grid>
<Grid item sm={3}>
<FormControl fullWidth>
<InputLabel required>진술유형</InputLabel>
<Select size="small" defaultValue="11" onChange={(e) => setSelectedContDoc(e.target.value)}>
{scContDoc &&
scContDoc.map((contDoc) => (
<MenuItem key={contDoc.code} value={contDoc.code}>
{contDoc.value}
</MenuItem>
))}
</Select>
</FormControl>
</Grid>
</Grid>
<Grid container spacing={0.5} item xs={12} mb={1.5}>
<Grid item sm={3}>
<NumberFormat
size="small"
customInput={TextField}
required
label="접수일자"
format="########"
fullWidth
value={scCdate}
onValueChange={(values) => setScCdate(values.value)}
/>
</Grid>
<Grid item sm={3}>
<FormControl fullWidth>
<InputLabel required>접수방법</InputLabel>
<Select size="small" defaultValue="1" onChange={(e) => setSelectedIngb(e.target.value)}>
{scIngb &&
scIngb.map((ingb) => (
<MenuItem key={ingb.code} value={ingb.code}>
{ingb.value}
</MenuItem>
))}
</Select>
</FormControl>
</Grid>
<Grid item sm={3}>
<NumberFormat
size="small"
customInput={TextField}
required
label="위반일자"
format="########"
fullWidth
value={scWdate}
onValueChange={(values) => setScWdate(values.value)}
/>
</Grid>
<Grid item sm={3}>
<NumberFormat
size="small"
customInput={TextField}
required
label="위반시간"
format="####"
fullWidth
value={scJbtime}
onValueChange={(values) => setScJbtime(values.value)}
/>
</Grid>
</Grid>
<Grid container spacing={0.5} item xs={12} mb={2}>
<Grid item sm={1.5}>
<TextField
size="small"
required
label="우편번호"
fullWidth
value={zippost1}
onValueChange={(values) => setScCarnum(values.value)}
/>
</Grid>
<Grid item sm={7}>
<TextField size="small" required label="주소" fullWidth value={scJuso} onValueChange={(values) => setScJuso(values.value)} />
</Grid>
<Grid item sm={3.5}>
<TextField size="small" required label="번지" fullWidth value={scBunji} onValueChange={(values) => setScBunji(values.value)} />
</Grid>
</Grid>
<Grid container spacing={1} item xs={12} mt={1}>
<Grid item sm={3}>
<FileInputForms
isDisabled={false}
fieldName="scPicad"
index={0}
labelName="단속사진1"
selectedFile={scPicad[0]?.name}
handleChangeFile={handleChangeFile}
alert={alert}
isOrgFileInfo
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={scPicad.length < 1}
fieldName="scPicad"
labelName="단속사진2"
index={1}
selectedFile={scPicad[1]?.name}
handleChangeFile={handleChangeFile}
alert={alert}
isOrgFileInfo
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={scPicad.length < 2}
fieldName="scPicad"
labelName="단속사진3"
index={1}
selectedFile={scPicad[2]?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
<Grid item sm={3}>
<FileInputForms
isDisabled={scPicad.length < 3}
fieldName="scPicad"
labelName="단속사진4"
index={1}
selectedFile={scPicad[3]?.name}
handleChangeFile={handleChangeFile}
alert={alert}
/>
</Grid>
</Grid>
</Grid>
<Grid item sx={{ marginTop: 3 }}>
<Button variant="contained" color="primary" size="small" startIcon={<IconFileExport />} onClick={onSave}>
저장
</Button>
</Grid>
</>
);
};
SaveResidentDataForm.propTypes = {
handleModalSave: PropTypes.func.isRequired,
isDisabled: PropTypes.bool.isRequired
};
export default SaveResidentDataForm;

@ -23,9 +23,8 @@ const CustomPagination = ({ totalCount, pageSize }) => {
showLastButton showLastButton
count={pageCount} count={pageCount}
page={page + 1} page={page + 1}
boundaryCount={5} boundaryCount={2}
siblingCount={2} siblingCount={2}
pagesize={10}
onChange={(event, value) => { onChange={(event, value) => {
apiRef.current.setPage(value - 1); apiRef.current.setPage(value - 1);
}} }}

@ -0,0 +1,29 @@
import * as React from 'react';
import { Button, Grid, TextField } from '@mui/material';
import { FileUpload } from '@mui/icons-material';
const FileInputForm = ({ labelName, selectedFile, handleChangeFile, alert }) => {
const onChangeFile = (e) => {
const file = e.target.files[0];
if (file.type.includes('image')) {
alert.show(<img alt={`${file.name}`} src={URL.createObjectURL(file)} style={{ margin: 'auto' }} />);
}
handleChangeFile(file);
};
return (
<Grid container item spacing={0.5}>
<Grid item xs={12} sm={7.5}>
<TextField placeholder={labelName} value={selectedFile} size="small" startIcon={<FileUpload />} onClick={() => {}} />
</Grid>
<Grid item xs={12} sm={4.5}>
<Button variant="contained" component="label" color="primary" size="small" startIcon={<FileUpload />}>
파일
<input type="file" hidden onChange={onChangeFile} />
</Button>
</Grid>
</Grid>
);
};
export default FileInputForm;

@ -0,0 +1,29 @@
import * as React from 'react';
import { Button, Grid, TextField } from '@mui/material';
import { FileUpload } from '@mui/icons-material';
const FileInputForms = ({ fieldName, index, labelName, selectedFile, handleChangeFile, alert, isDisabled = true }) => {
const onChangeFile = (e) => {
const file = e.target.files[0];
if (file.type.includes('image')) {
alert.show(<img alt={`${file.name}`} src={URL.createObjectURL(file)} style={{ margin: 'auto' }} />);
}
handleChangeFile(e);
};
return (
<Grid container item spacing={0.5}>
<Grid item xs={12} sm={7.5}>
<TextField placeholder={labelName} value={selectedFile} size="small" startIcon={<FileUpload />} onClick={() => {}} />
</Grid>
<Grid item xs={12} sm={4.5}>
<Button disabled={isDisabled} variant="contained" component="label" color="primary" size="small" startIcon={<FileUpload />}>
파일
<input type="file" name={fieldName} data-index={index} hidden onChange={onChangeFile} />
</Button>
</Grid>
</Grid>
);
};
export default FileInputForms;

@ -1,51 +0,0 @@
import * as React from 'react';
import { Button, IconButton, InputLabel, Tooltip, makeStyles, Theme } from '@mui/material';
import { FileDownload, FileUpload, FileUploadTwoTone } from '@mui/icons-material';
import { useState } from 'react';
import { useTheme } from '@mui/material/styles';
// const useStyles = makeStyles((theme) => ({
// root: {
// '& > *': {
// margin: theme.spacing(1)
// }
// },
// input: {
// display: 'none'
// },
// faceImage: {
// color: theme.palette.primary.light
// }
// }));
const FileUploadForm = ({ onSaveFile }) => {
const theme = useTheme();
const [selectedFile, setSelectedFile] = useState(null);
const handleCapture = ({ target }) => {
setSelectedFile(target.files[0]);
};
const handleSubmit = () => {
onSaveFile(selectedFile);
};
return (
<>
<input accept="image/jpeg" className={theme.input} id="faceImage" type="file" onChange={handleCapture} />
<Tooltip title="Select Image">
<InputLabel htmlFor="faceImage">
<IconButton className={theme.faceImage} color="primary" aria-label="upload picture" component="span">
<FileUploadTwoTone fontSize="small" />
</IconButton>
</InputLabel>
</Tooltip>
<InputLabel>{selectedFile ? selectedFile.name : 'Select Image'}</InputLabel>. . .
<Button onClick={() => handleSubmit()} color="primary">
Save
</Button>
</>
);
};
export default FileUploadForm;
Loading…
Cancel
Save