diff --git a/src/pages/administrative/industryInfo/index.tsx b/src/pages/administrative/industryInfo/index.tsx index 5ea4b36..5cdf3bb 100644 --- a/src/pages/administrative/industryInfo/index.tsx +++ b/src/pages/administrative/industryInfo/index.tsx @@ -8,9 +8,9 @@ import PageTitle from '../../../components/pageTitle/PageTitle' import { IndustryInfoView } from '../../../styles/layouts/industryInfo/IndustryInfoView' import InputUploadPdf from '../../../components/inputUploadPdf/inputUpload'; 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 Snackbar from '@mui/material/Snackbar'; import MuiAlert, { AlertProps } from '@mui/material/Alert'; import { InputUploadView } from '../../../components/inputUploadPdf/inputUploadView' @@ -22,16 +22,13 @@ const Alert = React.forwardRef(function Alert( return ; }); -const formData = new FormData() - - export default function industryInfo({userName}: any) { - const [url, setUrl] = React.useState(''); + const formData = new FormData(); - const onChange = (e: React.ChangeEvent) => { - const files = e.target.files; - files.length > 0 && setUrl(URL.createObjectURL(files[0])); - }; + const [pdf, setPdf] = useState(); + function onChange(e) { + setPdf(e.target.files[0]) + } const [openSnackSuccess, setOpenSnackSuccess] = useState(false); const [openSnackError, setOpenSnackError] = useState(false); @@ -45,32 +42,16 @@ export default function industryInfo({userName}: any) { setOpenSnackSuccess(false); }; - function handleCreateClient({ - pdf, - }) { + function handleCreateClient() { formData.append('file', pdf) - api.post('/updateFile', formData) - .then((res) => { - setOpenSnackSuccess(true) - window.location.reload() - }) - .catch((res) => { - setOpenSnackError(true) - }) + + api.post('/updateFile', formData).then(res => { + setOpenSnackSuccess(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 ( @@ -89,46 +70,21 @@ export default function industryInfo({userName}: any) {
- {/* +
- - +
-
*/} +
{/* */}
-
-
-
- - -
-
-
+ handleCreateClient()} title='Atualizar'/> - - - -
-
- - -
-
- - - - - - - - {/* handleCreateClient()} title='Atualizar'/> */} ) }