diff --git a/src/components/DisplayPartnerTrainingsPagination.js b/src/components/DisplayPartnerTrainingsPagination.js index 56d4c1a..5ecd2d1 100644 --- a/src/components/DisplayPartnerTrainingsPagination.js +++ b/src/components/DisplayPartnerTrainingsPagination.js @@ -7,7 +7,7 @@ import Button from '@mui/material/Button'; import Select from 'react-select' import { getCookie } from 'react-use-cookie'; import { DataGrid, GridToolbar, frFR } from '@mui/x-data-grid'; - +import excel_icone from "../mysy_img/excel_icone.png"; import Popup from 'reactjs-popup'; import 'reactjs-popup/dist/index.css'; import { AiFillCloseCircle, } from "react-icons/ai"; @@ -33,6 +33,9 @@ import DialogContent from '@mui/material/DialogContent'; import DialogContentText from '@mui/material/DialogContentText'; import DialogTitle from '@mui/material/DialogTitle'; import ToggleSwitch from "./ToggleSwitch"; +import SendIcon from '@mui/icons-material/Send'; +import { GrDocumentCsv } from "react-icons/gr"; + const DistplayPartnerTraningsPage = (props) => { const history = useHistory(); @@ -51,6 +54,110 @@ const DistplayPartnerTraningsPage = (props) => { const [createtraining, setcreatetraining] = useState(false); + const changeHandler2 = (event) => { + Closecreatetraining(); + setapiexcelimportmessage(); + setformation_file_name(); + sethandleSubmission_api(); + hiddenFileInput_formation.current.click(); + }; + + const [formation_file_name, setformation_file_name] = useState(); + + const hiddenFileInput_formation = React.useRef(null); + + const [excelimportmessage, setexcelimportmessage] = useState(""); + const [apiexcelimportmessage, setapiexcelimportmessage] = useState(""); + + const [handleSubmission_api, sethandleSubmission_api] = useState(); + const [handleSubmission_result, sethandleSubmission_result] = useState(); + const [handleSubmission_message, sethandleSubmission_message] = useState(); + + const handleSubmission = event => { + + const formData = new FormData(); + + const fileUploaded = event.target.files[0]; + let file_size = event.target.files[0].size; + let file_type = event.target.files[0].type; + + //console.log("file_size = ",file_size," file_type = ",file_type); + if (file_size > 1000000) { + alert("Le fichier ne doit pas dépasser un 1 Méga octets"); + return; + } + + setformation_file_name(event.target.files[0].name); + + //console.log(" import du ficier ", event.target.files[0].name); + + + formData.append('File', fileUploaded); + //formData.append('token', 'K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA'); + const stored_cookie = getCookie('tokenmysypart'); + + + formData.append("token", stored_cookie); + + //console.log("token = " + stored_cookie); theme_name + setLoading(true); + fetch( + process.env.REACT_APP_API_URL + "myclass/api/add_class_mass/", + { + method: 'POST', + body: formData, + } + ) + .then((response) => response.json()) + .then((result) => { + //console.log('Success:', result['message']); + setexcelimportmessage(result['message']); + setmyApiResponse("true"); + setapiexcelimportmessage(result['status']); + setLoading(false); + if (String(result['status']) === String("true")) { + + sethandleSubmission_api("true"); + GetAllClass_new(); + var local_message = result['message']; // + " Vous allez être redirigé vers la liste des formations" + window.scrollTo({ + top: 0, + behavior: "smooth", + }); + + alert(local_message); + //history.push("/Partner/affichage"); + //window.location.reload(); + //return; + + } else if (String(result['status']) === String("Err_Connexion")) { + alert('Erreur: ' + result['message']); + history.push("/Connexion"); + } + + else { + sethandleSubmission_api("false"); + sethandleSubmission_message(result['message']); + window.scrollTo({ + top: 0, + behavior: "smooth", + }); + alert(result['message']); + console.log(" 000000000000000&") + + + } + //alert("result['status'] " + result['status']); + }) + .catch((error) => { + setLoading(false); + setmyApiResponse("false"); + setapiexcelimportmessage("-1"); + sethandleSubmission_api("false"); + alert(" Impossible d'importer/mettre à jour les formations"); + }); + }; + function handleClick(event, cellValues) { @@ -1650,10 +1757,10 @@ const DistplayPartnerTraningsPage = (props) => { } - {String(myApiResponse) === "True" && -