diff --git a/src/components/GestionAdministrative.js b/src/components/GestionAdministrative.js
index e8db1ff..527a7e9 100644
--- a/src/components/GestionAdministrative.js
+++ b/src/components/GestionAdministrative.js
@@ -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 (
@@ -2036,8 +2074,11 @@ function GestionAdministrative(props) {
}}
id='menu_import_participant' name='menu_import_participant'>Import participants
-
- {participant_file_name}
+
+ {participant_file_name}
+ {String(liste_participants_file_change_api) === String("false") && }
+ {String(liste_participants_file_change_api) !== String("false") && }
+