From 9ba9ba8b942e05c066609ed752995b40792aa989 Mon Sep 17 00:00:00 2001 From: cherif Date: Fri, 20 Jan 2023 23:49:59 +0100 Subject: [PATCH] 20/01/23 - 23h --- src/components/Abonnement.js | 143 +++++++++++++++++-- src/components/CheckOut.js | 1 + src/components/PartenairStat.js | 25 ++-- src/styles/components/_produitsservices.scss | 10 ++ 4 files changed, 157 insertions(+), 22 deletions(-) diff --git a/src/components/Abonnement.js b/src/components/Abonnement.js index 782a32e..fb9b2d4 100644 --- a/src/components/Abonnement.js +++ b/src/components/Abonnement.js @@ -27,6 +27,8 @@ import fileDownload from 'js-file-download' import PayementComponent_Carte from "./PaymentMethode_Carte" import img_logo_stripe from "./../mysy_img/logo-stripe-secure.png"; import SendIcon from '@mui/icons-material/Send'; +import { confirmAlert } from 'react-confirm-alert'; // Import + function Abonnement(props) { @@ -361,6 +363,8 @@ function Abonnement(props) { //document.getElementsByName("vat_num")[0].style.backgroundColor = "#ECEFF1"; } + const [getCurrentUserData_result, setgetCurrentUserData_result] = useState([]); + function getCurrentUserData() { settestval('d'); // ==> Do not delete @@ -369,11 +373,13 @@ function Abonnement(props) { formData.append('token', stored_part); axios.post(url, formData).then(res => { - if (res.data.status != "False") { - 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) === String("true") ) { + //console.log(" In getCurrentUserData res.data.status = " + res.data.status); + //console.log(" In getCurrentUserData res.data.message = " + res.data.message); setmyApiResponse("True"); setResult(res.data.message); + setgetCurrentUserData_result(res.data.messag) var mylocaltraining = JSON.parse(res.data.message); if (mylocaltraining) { @@ -473,13 +479,7 @@ function Abonnement(props) { function confirmAbonnement(packs) { - /* alert(" test"); - history.push("/Partner", - {mysy_arg:'stat'}); - - return; - - */ + window.scrollTo(0, 0); if (String(packs).toLowerCase() === String("decouverte")) { @@ -551,6 +551,71 @@ function Abonnement(props) { } } + + const [StopAbonnement_api, setStopAbonnement_api] = useState([]); + const [StopAbonnement_message, setStopAbonnement_message] = useState([]); + const [StopAbonnement_result, setStopAbonnement_result] = useState([]); + function StopAbonnement(event) { + + var form = new FormData(); + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/stop_strip_subscription/"; + + + fetch(myurl, + { + method: 'POST', + body: form, + }) + .then((data) => data.json()) + .then((data) => { + + console.log(" In getCurrentUserData res.data.status = " + data.status); + console.log(" In getCurrentUserData res.data.message = " + data.message); + + if (String(data['status']) === String("false")) { + + setStopAbonnement_api("false"); + setStopAbonnement_message(data['message']); + + } + else if (String(data['status']) === String("true")) { + + setStopAbonnement_api("true"); + setStopAbonnement_result(data['message']); + } + + }).catch((error) => { + console.error('StopAbonnement Error:', error); + setStopAbonnement_api("false"); + }); + + } + + + function confirmSTOPAbonnement(localpacks) { + confirmAlert({ + title: '', + message: "Confirmez l'arret de votre abonnement " + String(localpacks), + buttons: [ + { + label: 'Yes', + onClick: () => { StopAbonnement(); } + }, + { + label: 'No', + onClick: () => { return } + } + ] + }); + } + + + + function returntoorder() { setgotocheckout("0"); @@ -567,12 +632,25 @@ function Abonnement(props) { } + {String(StopAbonnement_api) === String("true") &&
+ + +
} + + {String(StopAbonnement_api) === String("false") &&
+ + +
} + {String(gotocheckout) === String("0") &&
- +
Votre plan actuel
- Vous êtes actuellement sur un plan : {String(currentpack2).toUpperCase()} + Vous êtes actuellement sur un plan : {String(currentpack2).toUpperCase()} + {result && (JSON.parse(result).end_date_abonnement) && + } +
 
Mode de Paiement
@@ -1099,6 +1177,16 @@ function Abonnement(props) { > Activez ce pack
} + {String(currentpack2).toLowerCase() === String("Decouverte") &&
+ +
} +
@@ -1154,6 +1242,17 @@ function Abonnement(props) { }}> Activez ce pack
} + {String(currentpack2).toLowerCase() === String("standard") &&
+ +
} + +
@@ -1211,6 +1310,26 @@ function Abonnement(props) { > Activez ce pack } + {String(currentpack2).toLowerCase() === String("gold") && (!JSON.parse(result).end_date_abonnement) && +
+ +
} + + {String(currentpack2).toLowerCase() === String("gold") && (JSON.parse(result).end_date_abonnement) && +
+ +
} + diff --git a/src/components/CheckOut.js b/src/components/CheckOut.js index 8136f95..1ec50ae 100644 --- a/src/components/CheckOut.js +++ b/src/components/CheckOut.js @@ -786,6 +786,7 @@ function CheckOut(props) { var myurl = process.env.REACT_APP_API_URL + "myclass/api/confirm_payment/"; var form = new FormData(); form.append("stripe_payment_id", payement_id); + form.append('token', stored_part); fetch(myurl, { diff --git a/src/components/PartenairStat.js b/src/components/PartenairStat.js index ac092b5..c2201e4 100644 --- a/src/components/PartenairStat.js +++ b/src/components/PartenairStat.js @@ -127,7 +127,7 @@ Recuperation de toutes les formation du partenaire var new_data2 = ch_data2.split(',').map(Number); new_data2.push(123); - console.log(" new_data2 = " + new_data2); + console.log(" new_data2 b= " + new_data2); setglobal_view_data(ch_array); console.log(global_view_data); @@ -172,7 +172,7 @@ Recuperation de toutes les formation du partenaire form.append("date_start", date_start); form.append("date_end", date_end); form.append('token', stored_part); - form.append('topX', '5'); + form.append('topX', '6'); //alert("myurl = "+myurl); @@ -197,7 +197,7 @@ Recuperation de toutes les formation du partenaire var nom = JSON.parse(obj).name1; setdetail_view_data1_name(nom); - console.log("new_data2 = ", ch_data2); + console.log("new_data2 la = ", ch_data2); console.log("result = ", new_data2); } @@ -366,7 +366,7 @@ Recuperation de toutes les formation du partenaire var nom = JSON.parse(obj).name1; setdetail_view_data1_name_selected_training(nom); - console.log("new_data2 = ", ch_data2); + console.log("new_data2 a = ", ch_data2); console.log("result = ", new_data2); } @@ -469,16 +469,21 @@ Recuperation de toutes les formation du partenaire
- +
-
La tendance de votre entreprise
- +
La tendance de votre entreprise
+ + + + + {global_view_data && global_view_data.length > 3 &&
+

Graphique en ligne (Toute formation)

@@ -488,7 +493,7 @@ Recuperation de toutes les formation du partenaire

-Diagramme à bandes (Toute formation)

+ Diagramme à bandes (Toute formation)
@@ -500,7 +505,7 @@ Diagramme à bandes (Toute formation)
-
Le top 5 de vos formation sur la periode
+
Le top 5 de vos formation sur la periode
{topX_formation &&
@@ -531,7 +536,7 @@ Diagramme à bandes (Toute formation) {String(allclassAPI) === "true" &&
-
Les detail d'une formation
+
Les detail d'une formation
Selectionnez une formation