19/03/23 - 19h45

recette2
cherif 2023-03-19 19:45:08 +01:00
parent 409f6d639d
commit e4824fa451
11 changed files with 331 additions and 28 deletions

View File

@ -28,7 +28,7 @@ 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
import { RiAddCircleLine } from "react-icons/ri";
function Abonnement(props) {
@ -42,6 +42,7 @@ function Abonnement(props) {
const [selectedpacks, setselectedpacks] = useState("");
const [currentpack, setcurrentpack] = useState(props.currentpack);
const [currentpack2, setcurrentpack2] = useState("");
const [parnternbformation, setparnternbformation] = useState("");
const columns = [
{ field: 'id', headerName: 'id', hide: true },
@ -449,6 +450,11 @@ function Abonnement(props) {
}
if (mylocaltraining.nb_formation) {
setparnternbformation(String(mylocaltraining.nb_formation));
}
desablefield1();
}
@ -625,7 +631,6 @@ function Abonnement(props) {
function returntoorder() {
setgotocheckout("0");
@ -633,6 +638,174 @@ function Abonnement(props) {
const [packprice, setpackprice] = useState();
const [changepartnb_ftion, setchangepartnb_ftion] = useState();
const [new_nb_formations, setnew_nb_formations] = useState();
function Change_Partne_Nb_Ftion() {
setchangepartnb_ftion(true);
setnew_nb_formations(parnternbformation);
get_production_service_by_pack();
if (String(currentpack2).toLowerCase() === String("standard")) {
setpackprice("50");
}
else if (String(currentpack2).toLowerCase() === String("gold")) {
setpackprice("90");
}
else if (String(currentpack2).toLowerCase() === String("decouverte")) {
setpackprice("0");
}
}
const change_nb_formations = event => {
let valeur = event.target.value;
setnew_nb_formations(event.target.value);
// document.getElementById('div_nb_formation').style.color = "#104277";
//document.getElementById('div_ttc').style.color = "#104277";
}
function annule_enreg_new_ftion() {
setchangepartnb_ftion(false);
}
const [getpackproducts, setgetpackproducts] = useState();
const [get_production_service_by_pack_api, setget_production_service_by_pack_api] = useState();
const [get_production_service_by_pack_result, setget_production_service_by_pack_result] = useState();
function get_production_service_by_pack() {
const formData = new FormData();
const url = process.env.REACT_APP_API_URL + "myclass/api/get_product_service/";
formData.append('token', stored_part);
formData.append('pack_name', currentpack);
axios.post(url, formData).then(res => {
if (res.data.status != "False") {
//console.log(" In test res.data.status = " + res.data.status);
//console.log(" In test res.data.message = " + res.data.message);
setget_production_service_by_pack_api("True");
setget_production_service_by_pack_result(res.data.message);
setgetpackproducts(res.data.message);
}
else {
//console.log(" In test res.data.status = " + res.data.status);
//console.log(" In test res.data.message = " + res.data.message);
setget_production_service_by_pack_api("False");
setgetpackproducts("");
}
}).catch((error) => {
console.warn('Not good man :( mysearchtext = ');
setget_production_service_by_pack_api("False");
setgetpackproducts("");
//setmyApimyApiMessage("")
})
}
const [neworderid, setneworderid] = useState("");
const [New_Ordervalidation_api, setNew_Ordervalidation_api] = useState();
const [New_Ordervalidation_message, setNew_Ordervalidation_message] = useState();
function New_Ordervalidation() {
//alert(" confirmation ok");
var form = new FormData();
const stored_cookie = getCookie('tokenmysypart');
form.append("token", stored_cookie);
form.append("periodicite", "mensuel");
form.append("discount", "0");
form.append("pack", currentpack);
/*
/!\ : Important, il faut preciser le nombre d'article envoyé avec ceci : form.append("nb_product", nb_article);
*/
form.append("nb_product", "1");
var prod_service = ""
getpackproducts.map((service) => (
prod_service = prod_service + " -- " + JSON.parse(service).designation
))
//alert("prod_ser = " + prod_service);
form.append("0", JSON.stringify({
"code": currentpack, "prix": packprice, "comment": "nc", "qty": new_nb_formations, "pack_products": prod_service
}));
//form.append("1", JSON.stringify({ "code": "art_supp", "prix": "120", "comment": "nc" }));
var myurl = process.env.REACT_APP_API_URL + "myclass/api/createOrder/";
fetch(myurl,
{
method: 'POST',
body: form,
})
.then((data) => data.json())
.then((data) => {
console.log('Success:', data['message'], "data['status'] = ", data['status'], "ORDER ID = ", data['order_id']);
if (String(data['status']) === String("true")) {
setneworderid(data['order_id']);
setNew_Ordervalidation_api("true");
setchangepartnb_ftion(false);
setparnternbformation(new_nb_formations);
}
else {
setNew_Ordervalidation_api("false");
setNew_Ordervalidation_message(data['message']);
}
}).catch((error) => {
console.error('Error:', error);
setneworderid("");
setNew_Ordervalidation_api("false");
});
}
function confirmSNEwAbonnement() {
confirmAlert({
title: '',
message: "Confirmez la modification du nombre de formations",
buttons: [
{
label: 'Yes',
onClick: () => { New_Ordervalidation(); }
},
{
label: 'No',
onClick: () => { return }
}
]
});
}
function make_new_abonnement() {
//console.log(" old qty = ", parnternbformation, " New qty = ", new_nb_formations);
if (parnternbformation == new_nb_formations) {
alert(" Le nombre de formations est identique à l'abonnement actuel.");
return;
}
confirmSNEwAbonnement();
}
return (
<div className="abonnement">
@ -659,7 +832,97 @@ function Abonnement(props) {
<div className="div_row_gauche">
<div className="titre1"> Votre plan actuel </div>
Vous êtes actuellement sur un plan : {String(currentpack2).toUpperCase()}
Vous êtes actuellement sur un plan : {String(currentpack2).toUpperCase()} <br /><br />
<div className="div_row">
<div className="div_row_gauche">
Nombre de formations : {String(parnternbformation)} &nbsp;
{result && !(JSON.parse(result).end_date_abonnement) && !changepartnb_ftion &&
<Button className="btn_modif_nb_ftion" onClick={Change_Partne_Nb_Ftion} >Modifier &nbsp; <RiAddCircleLine /> </Button>
}
</div>
{String(New_Ordervalidation_api) === "true" && <div className="div_row okUpdateData">
la commande N° {neworderid} a été créée. Vous allez recevoir la confirmation de la commande et la facture par email. <br /> Merci.
</div>
}
{String(New_Ordervalidation_api) === "false" && <div className="div_row koUpdateData">
Impossible de créer la commande. {New_Ordervalidation_message}
</div>
}
{changepartnb_ftion && <div className="div_row_gauche" style={{ "textAlign": "right", "borderLeft": "5px solid", "paddingLeft": "2px" }}>
<div style={{ "width": "100%" }} >
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }}>
<b><u> Mesnuel </u> </b>
</div>
<div style={{ "textAlign": "right", "width": "50%", "float": "left" }}>
{packprice}
</div>
</div>
<div style={{ "width": "100%" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }}>
Nombre :
</div>
<div style={{ "textAlign": "right", "width": "50%", "float": "left" }}>
<input
value={new_nb_formations}
onChange={change_nb_formations}
type="number"
min="1"
max="50"
className="nb_ftion"
/>
</div>
</div>
<div style={{ "width": "100%" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }}>
Total HT :
</div>
<div style={{ "textAlign": "right", "width": "50%", "float": "left" }}>
{packprice * new_nb_formations}
</div>
</div>
<div style={{ "width": "100%" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }}>
TVA :
</div>
<div style={{ "textAlign": "right", "width": "50%", "float": "left" }}>
{packprice * new_nb_formations * .2}
</div>
</div>
<div style={{ "width": "100%" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }}>
Total TTC :
</div>
<div style={{ "textAlign": "right", "width": "50%", "float": "left" }}>
{packprice * new_nb_formations * 1.2}
</div>
</div>
<div style={{ "width": "100%" }} id="div_nb_formation" className="mob_heigh">
<div style={{ "textAlign": "left", "width": "50%", "float": "left" }}>
<Button className="btn_enreg_new_nb_ftion" onClick={make_new_abonnement} >Enregistrer </Button>
</div>
<div style={{ "textAlign": "right", "width": "50%", "float": "left" }}>
<Button className="btn_annule_new_nb_ftion" onClick={annule_enreg_new_ftion} >Annuler </Button>
</div>
</div>
</div>}
</div>
<br />
{result && (JSON.parse(result).end_date_abonnement) &&
<nav style={{ "color": "red" }}>Cet abonnement expire le {(JSON.parse(result).end_date_abonnement)} </nav>}
@ -949,7 +1212,7 @@ function Abonnement(props) {
<div className="div_row22">
{fields1desabled == false && <div className="div_row">
<div className="div_row_gauche">
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={RecordData}>Enregister</Button>
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={RecordData}>Enregistrer</Button>
</div>
<div className="div_row_droite">
<Button variant="contained" color="success" className="div_row22 btn_modif" onClick={getCurrentUserData}>Annuler</Button>
@ -1186,7 +1449,7 @@ function Abonnement(props) {
onClick={(e) => {
confirmAbonnement("Decouverte");
}}
> Activez ce pack </Button>
> Activer ce pack </Button>
</div>}
{String(currentpack2).toLowerCase() === String("decouverte") && (!JSON.parse(result).end_date_abonnement) &&
@ -1197,7 +1460,7 @@ function Abonnement(props) {
onClick={(e) => {
confirmSTOPAbonnement("decouverte");
}}
> Arretez </Button>
> Arreter </Button>
</div>}
{String(currentpack2).toLowerCase() === String("decouverte") && (JSON.parse(result).end_date_abonnement) &&
@ -1261,7 +1524,7 @@ function Abonnement(props) {
className="btn_abonnement"
onClick={(e) => {
confirmAbonnement("Standard");
}}> Activez ce pack </Button>
}}> Activer ce pack </Button>
</div>}
{String(currentpack2).toLowerCase() === String("standard") && (!JSON.parse(result).end_date_abonnement) && <div className="abonnement">
@ -1271,9 +1534,10 @@ function Abonnement(props) {
onClick={(e) => {
confirmSTOPAbonnement("standard");
}}
> Arretez </Button>
> Arreter </Button>
</div>}
{String(currentpack2).toLowerCase() === String("standard") && (JSON.parse(result).end_date_abonnement) &&
<div className="abonnement">
<Button variant="contained"
@ -1338,7 +1602,7 @@ function Abonnement(props) {
onClick={(e) => {
confirmAbonnement("Gold");
}}
> Activez ce pack </Button>
> Activer ce pack </Button>
</div>}
{String(currentpack2).toLowerCase() === String("gold") && (!JSON.parse(result).end_date_abonnement) &&
@ -1349,7 +1613,7 @@ function Abonnement(props) {
onClick={(e) => {
confirmSTOPAbonnement("Gold");
}}
> Arretez </Button>
> Arreter </Button>
</div>}
{String(currentpack2).toLowerCase() === String("gold") && (JSON.parse(result).end_date_abonnement) &&

View File

@ -27,6 +27,7 @@ import { FaHandPointRight } from "react-icons/fa";
import OrderConfirmation from "./OrderConfirmation";
import Pricing from "./Pricing";
const Partner = (props) => {
const { commingmenu, commingpack } = useParams();
const [myApiResponse, setmyApiResponse] = useState("");
@ -34,6 +35,7 @@ const Partner = (props) => {
const [cookie_part, setCookie_part, removeCookie_part] = useCookies(['tokenmysypart']);
const stored_part = getCookie('tokenmysypart');
const [parntername, setparntername] = useState("");
const [parnternbformation, setparnternbformation] = useState("");
const [selectedfilt1, setselectedfilt1] = useState("");
const [selectedfilt2, setselectedfilt2] = useState("");
const [selectedfilt3, setselectedfilt3] = useState("");
@ -400,6 +402,14 @@ const Partner = (props) => {
setpartnerPackService("Aucun Service");
}
if (JSON.parse(res.data.message).nb_formation) {
setparnternbformation(JSON.parse(res.data.message).nb_formation);
}
else {
setparnternbformation("");
}
if (JSON.parse(res.data.message).ispending) {
setpartnerstatus(JSON.parse(res.data.message).ispending);
}
@ -534,7 +544,7 @@ const Partner = (props) => {
</div>}
<div className="nom_prenom"> {parntername && <b> {parntername}&nbsp;-&nbsp;{String(partnerPackService).toUpperCase()} </b>}
<div className="nom_prenom"> {parntername && <b> {parntername}&nbsp;-&nbsp;{String(partnerPackService).toUpperCase()} ({parnternbformation})</b>}
{!parntername && <b> Partenaire </b>} </div>
<hr className="my_hr" />
{String(menu) !== "infopartner" && <div className="sousmenu" onClick={PersonnalData} > INFORMATIONS PERSONNELLES</div>}

View File

@ -473,7 +473,7 @@ function PaymentMethode(props) {
}}>J'ai lu et j'accepte les conditions ci-dessus.</label>
</div>
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={RecordData}>Enregister</Button>
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={RecordData}>Enregistrer</Button>
</div>
</div>

View File

@ -407,7 +407,7 @@ function PaymentMethodeNoConnect(props) {
</div>
<div className="div_row_centre">
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={RecordData}>Enregister</Button>
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={RecordData}>Enregistrer</Button>
</div>
</div>
);

View File

@ -354,7 +354,7 @@ function PaymentMethodeNoConnect(props) {
<div className="div_row_centre">
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={RecordData}>Enregister</Button>
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={RecordData}>Enregistrer</Button>
</div>
</div>

View File

@ -1532,7 +1532,7 @@ function UpdateParnterInfo() {
<div className="div_row22">
{fields1desabled == false && <div className="div_row">
<div className="div_row_gauche">
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={RecordData}>Enregister</Button>
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={RecordData}>Enregistrer</Button>
</div>
<div className="div_row_droite">
<Button variant="contained" color="success" className="div_row22 btn_modif" onClick={annuler_change_user_data}>Annuler</Button>
@ -1658,7 +1658,7 @@ function UpdateParnterInfo() {
{pwdfieldsdesabled == false && <div className="div_row">
<div className="div_row_gauche">
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={UpdatePartnerPwd}>Enregister</Button>
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={UpdatePartnerPwd}>Enregistrer</Button>
</div>
<div className="div_row_droite">
<Button variant="contained" color="success" className="div_row22 btn_modif " onClick={desablesecurtypwdfields}>Annuler</Button>
@ -1749,7 +1749,7 @@ function UpdateParnterInfo() {
</div>
{mailfieldsdesabled == false && <div className="div_row" >
<div className="div_row_gauche" >
<Button variant="contained" color="success" className="div_row22 btn_enreg " style={{ "marginTop": "0px" }} onClick={UpdatePartnerMail}>Enregister</Button>
<Button variant="contained" color="success" className="div_row22 btn_enreg " style={{ "marginTop": "0px" }} onClick={UpdatePartnerMail}>Enregistrer</Button>
</div>
<div className="div_row_droite">
<Button variant="contained" color="success" className="div_row22 btn_modif" style={{ "marginTop": "0px" }} onClick={desablesecurtymailfields}>Annuler</Button>
@ -1879,7 +1879,7 @@ function UpdateParnterInfo() {
{insert_keyfieldsdesabled == false && <div className="div_row">
<div className="div_row_gauche">
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={UpdatePartnerInsertKey}>Enregister</Button>
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={UpdatePartnerInsertKey}>Enregistrer</Button>
</div>
<div className="div_row_droite">

View File

@ -372,7 +372,7 @@ function UpdateUserGoals(props) {
{(!props.name_obj || fiedsupdated) && <div className="div_row">
<div className="div_row_gauche">
<Button variant="contained" color="success" className="div_row22 bton_enreg " onClick={RecordData}>Enregister &nbsp; <AiTwotoneSave /> </Button>
<Button variant="contained" color="success" className="div_row22 bton_enreg " onClick={RecordData}>Enregistrer &nbsp; <AiTwotoneSave /> </Button>
</div>
<div className="div_row_droite" style={{ "textAlign": "right" }}>
<Button variant="contained" color="success" className="div_row22 bton_annnule" onClick={"CloseLocalcomp"}>Annuler</Button>

View File

@ -690,7 +690,7 @@ function UpdateUserInfo() {
<div className="div_row22">
{fields1desabled == false && <div className="div_row">
<div className="div_row_gauche">
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={RecordData}>Enregister</Button>
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={RecordData}>Enregistrer</Button>
</div>
<div className="div_row_droite">
<Button variant="contained" color="success" className="div_row22 btn_modif" onClick={desablefield1}>Annuler</Button>
@ -796,7 +796,7 @@ function UpdateUserInfo() {
{pwdfieldsdesabled == false && <div className="div_row">
<div className="div_row_gauche">
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={UpdateUserPwd}>Enregister</Button>
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={UpdateUserPwd}>Enregistrer</Button>
</div>
<div className="div_row_droite">
<Button variant="contained" color="success" className="div_row22 btn_modif " onClick={desablesecurtypwdfields}>Annuler</Button>

View File

@ -296,7 +296,7 @@ function UpdateUserProfil(props) {
{fiedsupdated && <div className="div_row">
<div className="div_row_gauche">
<Button variant="contained" color="success" className="div_row22 bton_enreg " onClick={RecordData}>Enregister &nbsp; <AiTwotoneSave /> </Button>
<Button variant="contained" color="success" className="div_row22 bton_enreg " onClick={RecordData}>Enregistrer &nbsp; <AiTwotoneSave /> </Button>
</div>
<div className="div_row_droite" style={{ "textAlign": "right" }}>
<Button variant="contained" color="success" className="div_row22 bton_annnule" onClick={"CloseLocalcomp"}>Annuler</Button>

View File

@ -561,7 +561,7 @@ function UpgradeToPro() {
onClick={(e) => {
confirmAbonnement("Decouverte");
}}
> Activez le compte PRO </Button>
> Activer le compte PRO </Button>
</div>
</div>
@ -629,7 +629,7 @@ function UpgradeToPro() {
className="btn_abonnement"
onClick={(e) => {
confirmAbonnement("Standard");
}}> Activez le compte PRO </Button>
}}> Activer le compte PRO </Button>
</div>
@ -699,7 +699,7 @@ function UpgradeToPro() {
onClick={(e) => {
confirmAbonnement("Gold");
}}
> Activez le compte PRO </Button>
> Activer le compte PRO </Button>
</div>
@ -780,7 +780,7 @@ function UpgradeToPro() {
<div className="div_row22">
{fields1desabled == false && <div className="div_row">
<div className="div_row_gauche">
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={"RecordData"}>Enregister</Button>
<Button variant="contained" color="success" className="div_row22 btn_enreg " onClick={"RecordData"}>Enregistrer</Button>
</div>
<div className="div_row_droite">
<Button variant="contained" color="success" className="div_row22 btn_modif" onClick={"desablefield1"}>Annuler</Button>

View File

@ -658,7 +658,7 @@
.list_produits_service {
font-size: small;
}
}
.btn_retour_ps {
background-color: rgb(228, 236, 228) !important;
@ -666,7 +666,36 @@
padding-right: 5px;
}
.btn_modif_nb_ftion {
width: 10rem;
background-color: green !important;
color: white;
border-radius: 5rem;
font-size: small;
}
.nb_ftion{
text-align: center;
width: 50%;
}
.btn_enreg_new_nb_ftion {
width: 95%;
background-color: green !important;
color: white;
border-radius: 5rem;
font-size: small;
}
.btn_annule_new_nb_ftion {
width: 95%;
background-color: black !important;
color: white;
border-radius: 5rem;
font-size: small;
}
}