eee
parent
abfdc62900
commit
481a72929e
|
@ -1389,6 +1389,9 @@ function GestionAdministrative(props) {
|
|||
|
||||
const hiddenFileInput = React.useRef(null);
|
||||
|
||||
const [liste_participants_file_change_api, setliste_participants_file_change_api] = useState();
|
||||
const [liste_participants_file_change_result, setliste_participants_file_change_result] = useState();
|
||||
const [liste_participants_file_change_message, setliste_participants_file_change_message] = useState();
|
||||
const liste_participants_file_change = event => {
|
||||
const fileUploaded = event.target.files[0];
|
||||
let file_size = event.target.files[0].size;
|
||||
|
@ -1401,6 +1404,41 @@ function GestionAdministrative(props) {
|
|||
}
|
||||
|
||||
setparticipant_file_name(event.target.files[0].name);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('File', fileUploaded);
|
||||
//formData.append('token', 'K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA');
|
||||
const stored_cookie = getCookie('tokenmysypart');
|
||||
|
||||
formData.append("token", stored_cookie);
|
||||
formData.append("session_id", mysession);
|
||||
//console.log("token = " + stored_cookie);
|
||||
|
||||
fetch(
|
||||
process.env.REACT_APP_API_URL + "myclass/api/AddStagiairetoClass_mass/",
|
||||
{
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
}
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then((result) => {
|
||||
if (String(result['message']) === String("true")) {
|
||||
//console.log('Success:', result['message']);
|
||||
setliste_participants_file_change_result(result['message']);
|
||||
setliste_participants_file_change_api("true");
|
||||
}
|
||||
else {
|
||||
setliste_participants_file_change_message(result['message']);
|
||||
setliste_participants_file_change_api("false");
|
||||
}
|
||||
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
setliste_participants_file_change_api("false");
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -2037,7 +2075,10 @@ function GestionAdministrative(props) {
|
|||
id='menu_import_participant' name='menu_import_participant'>Import participants <SendIcon />
|
||||
</Button> <br />
|
||||
|
||||
{participant_file_name}
|
||||
<i>{participant_file_name}</i><br />
|
||||
{String(liste_participants_file_change_api) === String("false") && <nav className="okUpdateData"> Les participants ont été correctement importés</nav>}
|
||||
{String(liste_participants_file_change_api) !== String("false") && <nav className="koUpdateData"> {liste_participants_file_change_message} </nav>}
|
||||
|
||||
<input type="file"
|
||||
accept=".csv"
|
||||
ref={hiddenFileInput}
|
||||
|
|
Loading…
Reference in New Issue