update
This commit is contained in:
parent
c27670af2e
commit
d4e283cd15
@ -8,9 +8,9 @@ import PageTitle from '../../../components/pageTitle/PageTitle'
|
|||||||
import { IndustryInfoView } from '../../../styles/layouts/industryInfo/IndustryInfoView'
|
import { IndustryInfoView } from '../../../styles/layouts/industryInfo/IndustryInfoView'
|
||||||
import InputUploadPdf from '../../../components/inputUploadPdf/inputUpload';
|
import InputUploadPdf from '../../../components/inputUploadPdf/inputUpload';
|
||||||
import { api } from '../../../services/api'
|
import { api } from '../../../services/api'
|
||||||
// import { Viewer } from '@react-pdf-viewer/core';
|
|
||||||
import '@react-pdf-viewer/core/lib/styles/index.css';
|
|
||||||
import FormData from 'form-data';
|
import FormData from 'form-data';
|
||||||
|
|
||||||
import Snackbar from '@mui/material/Snackbar';
|
import Snackbar from '@mui/material/Snackbar';
|
||||||
import MuiAlert, { AlertProps } from '@mui/material/Alert';
|
import MuiAlert, { AlertProps } from '@mui/material/Alert';
|
||||||
import { InputUploadView } from '../../../components/inputUploadPdf/inputUploadView'
|
import { InputUploadView } from '../../../components/inputUploadPdf/inputUploadView'
|
||||||
@ -22,16 +22,13 @@ const Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert(
|
|||||||
return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} />;
|
return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} />;
|
||||||
});
|
});
|
||||||
|
|
||||||
const formData = new FormData()
|
|
||||||
|
|
||||||
|
|
||||||
export default function industryInfo({userName}: any) {
|
export default function industryInfo({userName}: any) {
|
||||||
const [url, setUrl] = React.useState('');
|
const formData = new FormData();
|
||||||
|
|
||||||
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const [pdf, setPdf] = useState<any>();
|
||||||
const files = e.target.files;
|
function onChange(e) {
|
||||||
files.length > 0 && setUrl(URL.createObjectURL(files[0]));
|
setPdf(e.target.files[0])
|
||||||
};
|
}
|
||||||
|
|
||||||
const [openSnackSuccess, setOpenSnackSuccess] = useState<boolean>(false);
|
const [openSnackSuccess, setOpenSnackSuccess] = useState<boolean>(false);
|
||||||
const [openSnackError, setOpenSnackError] = useState<boolean>(false);
|
const [openSnackError, setOpenSnackError] = useState<boolean>(false);
|
||||||
@ -45,32 +42,16 @@ export default function industryInfo({userName}: any) {
|
|||||||
setOpenSnackSuccess(false);
|
setOpenSnackSuccess(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleCreateClient({
|
function handleCreateClient() {
|
||||||
pdf,
|
|
||||||
}) {
|
|
||||||
formData.append('file', pdf)
|
formData.append('file', pdf)
|
||||||
api.post('/updateFile', formData)
|
|
||||||
.then((res) => {
|
api.post('/updateFile', formData).then(res => {
|
||||||
setOpenSnackSuccess(true)
|
setOpenSnackSuccess(true)
|
||||||
window.location.reload()
|
}).catch(res => {
|
||||||
})
|
setOpenSnackError(true)
|
||||||
.catch((res) => {
|
})
|
||||||
setOpenSnackError(true)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// function handleCreateClient() {
|
|
||||||
// pdf,
|
|
||||||
// FormData.append('file', pdf)
|
|
||||||
|
|
||||||
// api.post('/updateFile', FormData).then(res => {
|
|
||||||
// setOpenSnackSuccess(true)
|
|
||||||
// }).catch(res => {
|
|
||||||
// setOpenSnackError(true)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IndustryInfoView>
|
<IndustryInfoView>
|
||||||
<Snackbar open={openSnackSuccess} autoHideDuration={4000} onClose={handleCloseSnack}>
|
<Snackbar open={openSnackSuccess} autoHideDuration={4000} onClose={handleCloseSnack}>
|
||||||
@ -89,46 +70,21 @@ export default function industryInfo({userName}: any) {
|
|||||||
<Header name={userName} />
|
<Header name={userName} />
|
||||||
<div className='title'>
|
<div className='title'>
|
||||||
<PageTitle title='Info Setorial' subtitle='Realize o upload da última versão de info setorial' />
|
<PageTitle title='Info Setorial' subtitle='Realize o upload da última versão de info setorial' />
|
||||||
{/* <InputUploadView>
|
<InputUploadView>
|
||||||
<div className="update">
|
<div className="update">
|
||||||
<form action="">
|
<form action="">
|
||||||
<div className='testess'>
|
<div className='testess'>
|
||||||
<label htmlFor="arquivo"> <p className='TitleButton'> Enviar PDF </p> </label>
|
<label htmlFor="arquivo"> <p className='TitleButton'> Enviar PDF </p> </label>
|
||||||
|
<input type="file" name='arquivo' id='arquivo' onChange={onChange} />
|
||||||
<input type="file" name='arquivo' id='arquivo' accept=".pdf" onChange={onChange} />
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</InputUploadView> */}
|
</InputUploadView>
|
||||||
{/* <InputUploadPdf/> */}
|
{/* <InputUploadPdf/> */}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='inputTeste'>
|
<BasicButton onClick={() => handleCreateClient()} title='Atualizar'/>
|
||||||
<form action="">
|
|
||||||
<div className='tesess'>
|
|
||||||
<label htmlFor="arquivo"> <p className='TitleBllutton'> </p> </label>
|
|
||||||
<input type="file" name='arquivo' id='arquivo' onChange={onChange} />
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<form>
|
|
||||||
<div>
|
|
||||||
<label htmlFor="arquivo"></label>
|
|
||||||
<input type="file" name='arquivo' id='arquivo'/>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{/* <BasicButton onClick={() => handleCreateClient()} title='Atualizar'/> */}
|
|
||||||
</IndustryInfoView>
|
</IndustryInfoView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user