diff --git a/src/components/Abonnement.js b/src/components/Abonnement.js index 5e75728..09edf77 100644 --- a/src/components/Abonnement.js +++ b/src/components/Abonnement.js @@ -132,6 +132,11 @@ function Abonnement(props) { setmyApiResponse("False"); } + else if (String(data['status']) === String("Err_Connexion")) { + alert('Erreur: ' + data['message']); + history.push("/Connexion"); + return; + } else { setmyApiResponse("True"); @@ -169,12 +174,12 @@ function Abonnement(props) { .then((data) => { //console.log('LAAAAAAAAA Success:', data['message'], "data['status'] = ", data['status'], " nb_carte", data['nb_carte']); - if (String(data['status']) === String("true") ) { + if (String(data['status']) === String("true")) { setpaymentmodeapi("True"); setpaymentmode_nb_carte(data['nb_carte']); - if ( parseInt(data['nb_carte']) > 0 && + if (parseInt(data['nb_carte']) > 0 && data['message'] && data['message'][0] && Object.keys(data['message'][0]).length > 0) { setpaymentmode(data['message']); @@ -184,15 +189,20 @@ function Abonnement(props) { } - } else - { + } + else if (String(data['status']) === String("Err_Connexion")) { + alert('Erreur: ' + data['message']); + history.push("/Connexion"); + return; + } + else { //console.log("erreur rrrr:" + data['status']) setpaymentmodeapi("True"); setpaymentmode_nb_carte('0') - + } - + }).catch((error) => { console.error('GetPayementMode : Error:', error); @@ -546,9 +556,9 @@ function Abonnement(props) { setgotocheckout("1"); setselectedpacks(packs); window.scrollTo({ - top: 0, - behavior: "smooth", - }); + top: 0, + behavior: "smooth", + }); return; } @@ -586,9 +596,9 @@ function Abonnement(props) { setgotocheckout("1"); setselectedpacks(packs); window.scrollTo({ - top: 0, - behavior: "smooth", - }); + top: 0, + behavior: "smooth", + }); } } @@ -598,7 +608,7 @@ function Abonnement(props) { window.scrollTo({ top: 0, behavior: "smooth", - }); + }); if (Client_end_date_abonnement && String(Client_end_date_abonnement).length > 3) { @@ -649,9 +659,9 @@ function Abonnement(props) { setgotocheckout("1"); setselectedpacks(packs); window.scrollTo({ - top: 0, - behavior: "smooth", - }); + top: 0, + behavior: "smooth", + }); return; } @@ -689,9 +699,9 @@ function Abonnement(props) { setgotocheckout("1"); setselectedpacks(packs); window.scrollTo({ - top: 0, - behavior: "smooth", - }); + top: 0, + behavior: "smooth", + }); } } } @@ -1166,6 +1176,10 @@ function Abonnement(props) { } } + } else if (String(res.data.status) === String("Err_Connexion")) { + alert('Erreur: ' + res.data.message); + history.push("/Connexion"); + return; } else { @@ -1282,7 +1296,7 @@ function Abonnement(props) { {handleOnblur_Code_Promo_api && String(handleOnblur_Code_Promo_api) === "false" && - + } diff --git a/src/components/DisplayPartnerTrainingsPagination.js b/src/components/DisplayPartnerTrainingsPagination.js index 876e979..243a2ea 100644 --- a/src/components/DisplayPartnerTrainingsPagination.js +++ b/src/components/DisplayPartnerTrainingsPagination.js @@ -9,11 +9,14 @@ import { getCookie } from 'react-use-cookie'; import { DataGrid, GridToolbar, frFR } from '@mui/x-data-grid'; import Footer from "./Fotter"; import tick_ko from "../mysy_img/tick_KO.png"; - +import Popup from 'reactjs-popup'; +import 'reactjs-popup/dist/index.css'; import { AiFillCloseCircle, } from "react-icons/ai"; import parse from 'html-react-parser' import { BsEye, BsFileText } from "react-icons/bs"; import { useHistory } from "react-router-dom"; +import axios from "axios"; +import { CiCoffeeBean } from "react-icons/ci"; const DistplayPartnerTraningsPage = (props) => { @@ -26,6 +29,9 @@ const DistplayPartnerTraningsPage = (props) => { { value: 'certif', label: 'Certification' } ] + + + const [selectedfilt1, setselectedfilt1] = useState(""); const [selectedfilt2, setselectedfilt2] = useState(""); const [selectedfilt3, setselectedfilt3] = useState(""); @@ -243,6 +249,65 @@ const DistplayPartnerTraningsPage = (props) => { } }, + { + field: "push_to_lms", headerName: 'Push Elearning', + renderCell: (cellValues) => { + return ( + + { + handlepush_to_lms(event, cellValues); + }} + > + + + } + + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + + /!\ Important : Confirmer la publication de la formation dans l'eapce E-Learning +
+
+
+ + +
+
+ +
+
+
+ )} +
+ + ); + } + }, + ] @@ -289,12 +354,11 @@ const DistplayPartnerTraningsPage = (props) => { }); - - - } + + function handleClickManagement(event, cellValues) { // Verification de la validité du token avant action. @@ -577,13 +641,59 @@ const DistplayPartnerTraningsPage = (props) => { window.scrollTo({ top: 0, behavior: "smooth", - }); + }); }, []); function Clearselectedfilt1() { setselectedfilt1(""); } + + const [handlepush_to_lms_api, sethandlepush_to_lms_api] = useState(""); + const [handlepush_to_lms_result, sethandlepush_to_lms_result] = useState(""); + const [handlepush_to_lms_message, sethandlepush_to_lms_message] = useState(""); + + function handlepush_to_lms(event, cellValues) { + + //console.log(" ### event.target.value = ", event.target.value); + const formData = new FormData(); + const url = process.env.REACT_APP_API_URL + "myclass/api/Push_Class_To_MySy_LMS/"; + + const stored_cookie = getCookie('tokenmysypart'); + formData.append("token", stored_cookie); + formData.append('class_internal_url', cellValues.row.internal_url); + + axios.post(url, formData).then(res => { + //console.log(" In getCurrentUserData res.data.status = " + res.data.status); + //console.log(" In getCurrentUserData res.data.message = " + res.data.message); + if (String(res.data.status) === "true") { + + sethandlepush_to_lms_api("true"); + sethandlepush_to_lms_result(res.data.message); + + alert(res.data.message ); + + + } + else if (String(res.data.status) === String("Err_Connexion")) { + alert('Erreur: ' + res.data.message); + history.push("/Connexion"); + return; + } + else { + + sethandlepush_to_lms_api("false"); + sethandlepush_to_lms_message(res.data.message); + alert("Erreur : "+res.data.message ); + } + + }).catch((error) => { + console.warn('Erro handlepush_to_lms = ', error); + sethandlepush_to_lms_api("false"); + }) + } + + return (