refactor: 개발자도구 콘솔 에러 fix
parent
f1e8cfdf96
commit
06c08b756b
@ -1,42 +0,0 @@
|
||||
import { Button, Grid, TextField } from '@mui/material';
|
||||
import { FileUpload } from '@mui/icons-material';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
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 stroke={1.5} size="1rem" />}
|
||||
onClick={() => {}}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4.5}>
|
||||
<Button variant="contained" component="label" color="primary" size="small" startIcon={<FileUpload stroke={1.5} size="1rem" />}>
|
||||
파일
|
||||
<input type="file" hidden onChange={onChangeFile} />
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
|
||||
FileInputForm.propTypes = {
|
||||
labelName: PropTypes.string.isRequired,
|
||||
selectedFile: PropTypes.string,
|
||||
handleChangeFile: PropTypes.func.isRequired,
|
||||
alert: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default FileInputForm;
|
@ -1,45 +0,0 @@
|
||||
import { Button, Grid, TextField, Typography } from '@mui/material';
|
||||
import { FileUpload } from '@mui/icons-material';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
const FileReadInputForm = ({ 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 stroke={1.5} size="1rem" />}
|
||||
onClick={() => {}}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={4.5}>
|
||||
<Button variant="contained" component="label" color="primary" size="small" startIcon={<FileUpload stroke={1.5} size="1rem" />}>
|
||||
파일
|
||||
<input type="file" hidden onChange={onChangeFile} />
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Typography variant="h4">{selectedFile}</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
|
||||
FileReadInputForm.propTypes = {
|
||||
labelName: PropTypes.number.isRequired,
|
||||
selectedFile: PropTypes.string,
|
||||
handleChangeFile: PropTypes.func.isRequired,
|
||||
alert: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default FileReadInputForm;
|
@ -1,23 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
const Filedownload = () => {
|
||||
useEffect(() => {
|
||||
if (fileData) {
|
||||
const url = window.URL.createObjectURL(new Blob([fileData.data]));
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', 'test.xlsx');
|
||||
link.setAttribute('id', 'tempLink');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
}
|
||||
return () => {
|
||||
const link = document.querySelector('#tempLink');
|
||||
link && link.remove();
|
||||
};
|
||||
}, [fileData]);
|
||||
|
||||
return <div />;
|
||||
};
|
||||
|
||||
export default Filedownload;
|
Loading…
Reference in New Issue