WikiLerni/front/src/paymentPage.js

87 lines
2.8 KiB
JavaScript
Raw Normal View History

// -- GESTION DE LA PAGE DU FINANCEMENT PARTICIPATIF (SANS DEVOIR ÊTRE CONNECTÉ)
/// Permet d'afficher les boutons de paiement WP suivant le choix de l'utilisateur.
/// Matomo est également activé si l'internaute n'est pas connecté.
// Fichier de configuration tirés du backend :
import { availableLangs, theme } from "../../config/instance.js";
const lang=availableLangs[0];
const configTemplate = require("../../views/"+theme+"/config/"+lang+".js");
// Fonctions utiles au script :
import { getLocaly } from "./tools/clientstorage.js";
import { helloDev, updateAccountLink } from "./tools/everywhere.js";
import { loadMatomo } from "./tools/matomo.js";
import { checkSession } from "./tools/users.js";
import { showBtnPayment, unCheckAllOthers } from "./tools/webportage.js";
helloDev();
const initialise = async () =>
{
try
{
const isConnected=await checkSession();
if(isConnected)
{
// on change le lien du compte en haut :
const user=getLocaly("user", true);
updateAccountLink(user.status, configTemplate);
}
else
loadMatomo();
// Les boutons de paiement WP :
const CGV=document.getElementById("CGVOk");
const abo1=document.getElementById("abo1");
const abo2=document.getElementById("abo2");
const abo3=document.getElementById("abo3");
const abo4=document.getElementById("abo4");
const divWPBtns=document.getElementById("WPBtns");
divWPBtns.style.display="none";
abo1.addEventListener("change", function(e)
{
unCheckAllOthers("abo1");
});
abo2.addEventListener("change", function(e)
{
unCheckAllOthers("abo2");
});
abo3.addEventListener("change", function(e)
{
unCheckAllOthers("abo3");
});
abo4.addEventListener("change", function(e)
{
unCheckAllOthers("abo4");
});
CGV.addEventListener("change", function(e)
{
if(CGV.checked===true)
{
divWPBtns.style.display="block";
if(abo1.checked===true)
showBtnPayment("btn1");
else if(abo2.checked===true)
showBtnPayment("btn2");
else if(abo3.checked===true)
showBtnPayment("btn3");
else if(abo4.checked===true)
showBtnPayment("btn4");
else
{
divWPBtns.style.display="none";
CGV.checked=false;
}
}
else
divWPBtns.style.display="none";
});
}
catch(e)
{
console.error(e);
}
}
initialise();