2024-11-21
fonc(db) exporte la BDD de production corvée(images) ajoute les images téléversées
|
|
@ -130,9 +130,6 @@
|
|||
* 1. Longueur minimale pour le Bouton n'ait pas à changer de taille quel que soit son texte
|
||||
*/
|
||||
}
|
||||
#panneau-panier .panneau__instructions-code-promo__code-promo input {
|
||||
width: 20rem;
|
||||
}
|
||||
#panneau-panier .panneau__instructions-code-promo__code-promo button {
|
||||
padding: var(--espace-xs) var(--espace-xl);
|
||||
text-transform: lowercase;
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"sourceRoot":"","sources":["../../../src/sass/layouts/_panneau-panier.scss","../../../src/sass/layouts/_panneau-informations-client.scss","../../../src/sass/pages/page-panier.scss"],"names":[],"mappings":";AAEA;EACE;;AAEA;EACE;;AAIF;EACE;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAGA;EACE;;AAEA;EACE;;AAGF;EACE;EACA;;AAMN;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;;AAIJ;EACE;EACA;;AAIF;EACE;EACA;EACA;EACA;EACA;AAEA;AASA;AAAA;AAAA;AAAA;AAmBA;AASA;;AApCA;EACE;EACA;EACA;EACA;EACA;;AAOF;EACE;EACA;EACA;EACA;EACA;EACA;;AAEA;EAEE;EACA;;AAKJ;EACE;EACA;EACA;EACA;EACA;;AAIF;EACE;EACA;EACA;EACA;EACA;;AAOR;EACE;EACA;EACA;EACA;AAEA;AAAA;AAAA;AAAA;;AAIA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;AAMA;AAAA;AAAA;;AAJA;EACE;;AAMF;EACE;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;;AAKN;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;;AAKA;EACE;;AAEA;EACE;;AAMR;EACE;EACA;EACA;EACA;EACA;;AAKJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;;;ACjON;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;;AAIF;EAEE;EACA;EACA;EAGA;EAEA;EACA;;AAEA;EACE;EACA;;AAIF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;;AAGF;EACE;;AAMN;EACE;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAKF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAGE;EACE;;AAOV;EACE;EACA;;AAEA;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;;AAIA;EACE;;AAKN;EACE;EACA;EACA;;AAEA;EACE;;AAIJ;EACE;;AAKJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;;;AC1JN;AAAA;AAAA;AAAA;AAIA;AACE;EACA;AAEA;EACA;EAEA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAGA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;;AAKN;EACE;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;EACA;;AAKF;EACE;;AAGF;EACE","file":"page-panier.css"}
|
||||
{"version":3,"sourceRoot":"","sources":["../../../src/sass/layouts/_panneau-panier.scss","../../../src/sass/layouts/_panneau-informations-client.scss","../../../src/sass/pages/page-panier.scss"],"names":[],"mappings":";AAEA;EACE;;AAEA;EACE;;AAIF;EACE;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAGA;EACE;;AAEA;EACE;;AAGF;EACE;EACA;;AAMN;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;;AAIJ;EACE;EACA;;AAIF;EACE;EACA;EACA;EACA;EACA;AAEA;AASA;AAAA;AAAA;AAAA;AAmBA;AASA;;AApCA;EACE;EACA;EACA;EACA;EACA;;AAOF;EACE;EACA;EACA;EACA;EACA;EACA;;AAEA;EAEE;EACA;;AAKJ;EACE;EACA;EACA;EACA;EACA;;AAIF;EACE;EACA;EACA;EACA;EACA;;AAOR;EACE;EACA;EACA;EACA;AAEA;AAAA;AAAA;AAAA;;AAIA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;EACA;EACA;AAEA;AAAA;AAAA;;AAGA;EACE;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;;AAKN;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;;AAKA;EACE;;AAEA;EACE;;AAMR;EACE;EACA;EACA;EACA;EACA;;AAKJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;;;AC7NN;EACE;EACA;EACA;EACA;;AAEA;EACE;EACA;;AAIF;EAEE;EACA;EACA;EAGA;EAEA;EACA;;AAEA;EACE;EACA;;AAIF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;;AAGF;EACE;;AAMN;EACE;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAKF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAGE;EACE;;AAOV;EACE;EACA;;AAEA;EACE;;AAGF;EACE;EACA;EACA;EACA;EACA;;AAGF;EACE;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;;AAIA;EACE;;AAKN;EACE;EACA;EACA;;AAEA;EACE;;AAIJ;EACE;;AAKJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;;;AC1JN;AAAA;AAAA;AAAA;AAIA;AACE;EACA;AAEA;EACA;EAEA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;;AAGA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA;EACA;;AAKN;EACE;EACA;EACA;EACA;EACA;;AAEA;EACE;;AAGF;EACE;EACA;EACA;;AAKF;EACE;;AAGF;EACE","file":"page-panier.css"}
|
||||
|
|
@ -68,7 +68,7 @@
|
|||
"name": "dom",
|
||||
"src": "web/app/themes/haiku-atelier-2024/src/scripts/constantes/dom.ts",
|
||||
"isEntry": true,
|
||||
"integrity": "sha512-ldPkBLWjE77dp7raA0LauVQS11/w/N0RpOCtgmJu3PQfwEezQS4iVPnp10lZGduIClmliT7WPpbqrZchRTpITw=="
|
||||
"integrity": "sha512-I1Z5v7vScYFe97juQAHfl5K/N6OR+BQCiVvxTIBbgPv8Y0NQMIBebWYj1/xhKB7AUSlIUYOaFvus/zOeU5TJOQ=="
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/erreurs.ts": {
|
||||
"file": "erreurs.js",
|
||||
|
|
@ -110,6 +110,13 @@
|
|||
],
|
||||
"integrity": "sha512-mskLArAQPBWERMQR6U4/xLPd+NfjZ59hrptjz2G/7KUnC8cVe33bzBkQzUHZDNxy2/YlDFXTWO6NwQjgKKzgxQ=="
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/animations.ts": {
|
||||
"file": "animations.js",
|
||||
"name": "animations",
|
||||
"src": "web/app/themes/haiku-atelier-2024/src/scripts/lib/animations.ts",
|
||||
"isEntry": true,
|
||||
"integrity": "sha512-SD+1/duJm9OdEuU10TyTp/l4GTZulyECskFYLi5TBLOf5GLkbtiI7wgYto28fXhXRPVcoWuD1Coul4mXCiyAng=="
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/dom.ts": {
|
||||
"file": "dom2.js",
|
||||
"name": "dom",
|
||||
|
|
@ -121,7 +128,7 @@
|
|||
"_Either.wHNxn7Os.js",
|
||||
"_exports.3IcOsN8u.js"
|
||||
],
|
||||
"integrity": "sha512-nNoNk0nD88HRS8LqyIx5kV9MOZBIbcHO4IaumhTh6T3p34OdBIJtM8QQVngu6X/jPdCbMFDj9uajXKAgMkE8bQ=="
|
||||
"integrity": "sha512-I/u87SjbDtW7SK4O2yinDf8MAhDVpWyRBxa4gWSoLB2tXtqjqkg5YfhJXWIf3az36oSjHunCsSRzdZjrgXUqug=="
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts": {
|
||||
"file": "erreurs2.js",
|
||||
|
|
@ -179,7 +186,7 @@
|
|||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/cart-coupons.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/couts-livraison.ts"
|
||||
],
|
||||
"integrity": "sha512-eNfGzO+xLfiHFnNdNdE+zBcnvpPz/wE6vXX1rKbYVlFuf2gPC9kxCEwQnH+BijivLi/JkqkrtXv+m/92RShOrA=="
|
||||
"integrity": "sha512-1kRDhi1+KGja3JCleYjLnsjVDpCrRXQqB8ZGAjpuTEAMiKpSQqj3x8vPCySRvkv8wreUc2UzTOa1xCljoZ8bPA=="
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/nombres.ts": {
|
||||
"file": "nombres.js",
|
||||
|
|
@ -368,7 +375,7 @@
|
|||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/cart-coupons.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/couts-livraison.ts"
|
||||
],
|
||||
"integrity": "sha512-DRQfMEltCFFPp1xUw26z4CbypxMn//NWQEsKGc98p9UTSaoSNUy7rDWR7JJYM5mnZvglEu+jEzzrKXCrZvQB2w=="
|
||||
"integrity": "sha512-e0iafVBzxA+LOMbD4VlzjtXW1GU/LmETBKAQ5cV7glJdsaY5/ZWVGcSOOPdwT6kvQkMBohKCgn9K5Bqwoi38zA=="
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/types/api/v3/orders.ts": {
|
||||
"file": "orders.js",
|
||||
|
|
@ -541,6 +548,7 @@
|
|||
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/api.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/dom.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/erreurs.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/animations.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/dom.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs/codes-promo.ts",
|
||||
|
|
@ -564,7 +572,7 @@
|
|||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/cart-coupons.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/couts-livraison.ts"
|
||||
],
|
||||
"integrity": "sha512-Dcq5CmQJWGUY0FPDHu4fI5COKoVMxA0I0zUpOpPIS6IQ8HXCvzQjH+18wNzCpbqNB/L0mrILXsSVmLmpeLGEWw=="
|
||||
"integrity": "sha512-YYKaBtgzKquj63eMhqcijL6/wgAFl1WCKSED+/q4B2h7+YibZkgBMyWOkKRZcUVWQZYHhx2PHMgWIAdRbnld/A=="
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-panier.ts": {
|
||||
"file": "scripts-page-panier.js",
|
||||
|
|
@ -602,13 +610,14 @@
|
|||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/cart-coupons.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/orders.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/erreurs.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/animations.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs/codes-promo.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/cart-apply-coupon.ts",
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/cart-remove-coupon.ts",
|
||||
"_MaybeAsync.AE1jnxuc.js",
|
||||
"_belt_Option-91f3b350.cBye8bLJ.js"
|
||||
],
|
||||
"integrity": "sha512-nv6WicLF3qhp2tyjzl7Ns5Yyfon9onWi/u5nxsvBRT6oEpdb9h5rXxDx3ydC6OsMR9n/B1wdXsuxxHTmECqX/w=="
|
||||
"integrity": "sha512-LrETkMtNpCGK3ohj7yLHF5vz4lIdAgQaqSzq/6Ij7TGl67V0nu+E4TOATuT56B0djGTtJJXc24fflEYEf/rW/A=="
|
||||
},
|
||||
"web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-produit.ts": {
|
||||
"file": "scripts-page-produit.js",
|
||||
|
|
@ -642,6 +651,6 @@
|
|||
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/api/couts-livraison.ts",
|
||||
"_belt_Option-91f3b350.cBye8bLJ.js"
|
||||
],
|
||||
"integrity": "sha512-lUQ7gg9r4XVBz+5ivZvD+nP+ncAJ4I78VpiJJE3NSWecpGYoyN/2/LvWzQr8maRyf7Ox4+aJRrbHIaQZVul/fQ=="
|
||||
"integrity": "sha512-4HoksAZ1TvIRrylHgveTV7HHpYiDQSxAhFCCJ7kUj8iGrwC46k9oFevH3wyFOWdxK+fsUoTjyEZ9BK7R5q64ig=="
|
||||
}
|
||||
}
|
||||
21
web/app/themes/haiku-atelier-2024/assets/js/animations.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
const lanceAnimationCycleTexte = (args) => {
|
||||
const animation = {
|
||||
callback: () => {
|
||||
if (!args.element.hasAttribute(args.attribut)) {
|
||||
clearInterval(animation.interval);
|
||||
return;
|
||||
}
|
||||
args.element.textContent = animation.etapes.at(animation.index) ?? "Loading...";
|
||||
animation.index = animation.index + 1 > animation.etapes.length - 1 ? 0 : animation.index + 1;
|
||||
},
|
||||
etapes: args.etapes,
|
||||
index: 0,
|
||||
interval: setInterval(() => {
|
||||
}, 2147483647)
|
||||
};
|
||||
return animation;
|
||||
};
|
||||
export {
|
||||
lanceAnimationCycleTexte as l
|
||||
};
|
||||
//# sourceMappingURL=animations.js.map
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"animations.js","sources":["../../src/scripts/lib/animations.ts"],"sourcesContent":["/** Fonctions pour la création de simples animations JavaScript. */\n\n// Types\ninterface AnimationCycleTexte {\n callback: () => void;\n etapes: Array<string>;\n index: number;\n interval: NodeJS.Timeout;\n}\n\ninterface ParametresAnimationCycleTexte {\n attribut: string;\n element: HTMLElement;\n etapes: Array<string>;\n}\n\n/**\n * Créer le nécessaire pour une animation s'exécutant jusqu'à ce que un interval soit manuellement arrêté. L'animation\n * consiste en la mise à jour d'un texte avec l'utilisation de toutes les valeurs d'un tableau, une par une.\n *\n * @param args Les paramètres nécessaires pour la création de l'animation.\n * @returns Un objet contenant les informations de l'animation, notamment l'interval utilisable pour son arrêt.\n */\nexport const lanceAnimationCycleTexte = (args: ParametresAnimationCycleTexte): AnimationCycleTexte => {\n const animation: AnimationCycleTexte = {\n callback: (): void => {\n // Arrête le cycle quand l'Attribut de chargement n'est plus présent\n if (!args.element.hasAttribute(args.attribut)) {\n clearInterval(animation.interval);\n return;\n }\n\n // Change le texte\n args.element.textContent = animation.etapes.at(animation.index) ?? \"Loading...\";\n // Incrémente ou réinitialise l'index\n animation.index = animation.index + 1 > animation.etapes.length - 1 ? 0 : animation.index + 1;\n },\n etapes: args.etapes,\n index: 0,\n interval: setInterval(() => {}, 2147483647),\n };\n\n return animation;\n};\n"],"names":[],"mappings":"AAuBa,MAAA,2BAA2B,CAAC,SAA6D;AACpG,QAAM,YAAiC;AAAA,IACrC,UAAU,MAAY;AAEpB,UAAI,CAAC,KAAK,QAAQ,aAAa,KAAK,QAAQ,GAAG;AAC7C,sBAAc,UAAU,QAAQ;AAChC;AAAA,MAAA;AAIF,WAAK,QAAQ,cAAc,UAAU,OAAO,GAAG,UAAU,KAAK,KAAK;AAEzD,gBAAA,QAAQ,UAAU,QAAQ,IAAI,UAAU,OAAO,SAAS,IAAI,IAAI,UAAU,QAAQ;AAAA,IAC9F;AAAA,IACA,QAAQ,KAAK;AAAA,IACb,OAAO;AAAA,IACP,UAAU,YAAY,MAAM;AAAA,IAAA,GAAI,UAAU;AAAA,EAC5C;AAEO,SAAA;AACT;"}
|
||||
|
|
@ -65,15 +65,15 @@ const SELECTEUR_PRIX_PRODUIT = ".selecteur-produit__prix";
|
|||
export {
|
||||
SELECTEUR_BOUTON_MENU_MOBILE as $,
|
||||
ATTRIBUT_CONTIENT_ARTICLES as A,
|
||||
SELECTEUR_BOUTON_SUPPRESSION_PANIER as B,
|
||||
SELECTEUR_PRIX_LIGNE_PANIER as C,
|
||||
ATTRIBUT_DESACTIVE as D,
|
||||
SELECTEUR_BOUTON_CODE_PROMO as E,
|
||||
SELECTEUR_CHAMP_CODE_PROMO as F,
|
||||
SELECTEUR_ENSEMBLE_CODE_PROMO as G,
|
||||
SELECTEUR_MESSAGE_CODE_PROMO as H,
|
||||
SELECTEUR_TOTAL_REDUCTION as I,
|
||||
SELECTEUR_TOTAL_REDUCTION_VALEUR as J,
|
||||
SELECTEUR_BOUTON_ADDITION_QUANTITE as B,
|
||||
SELECTEUR_BOUTON_SUPPRESSION_PANIER as C,
|
||||
SELECTEUR_PRIX_LIGNE_PANIER as D,
|
||||
ATTRIBUT_DESACTIVE as E,
|
||||
SELECTEUR_BOUTON_CODE_PROMO as F,
|
||||
SELECTEUR_CHAMP_CODE_PROMO as G,
|
||||
SELECTEUR_ENSEMBLE_CODE_PROMO as H,
|
||||
SELECTEUR_MESSAGE_CODE_PROMO as I,
|
||||
SELECTEUR_TOTAL_REDUCTION as J,
|
||||
ATTRIBUT_CHARGEMENT as K,
|
||||
ATTRIBUT_CODE_PROMO_PRESENT as L,
|
||||
SELECTEUR_BOUTON_AJOUT_PANIER as M,
|
||||
|
|
@ -121,10 +121,10 @@ export {
|
|||
SELECTEUR_FORMULAIRE_PANIER as s,
|
||||
SELECTEUR_FORMULAIRE_FACTURATION as t,
|
||||
SELECTEUR_BOUTON_ACTIONS_FORMULAIRE as u,
|
||||
SELECTEUR_INSTRUCTIONS_CLIENT as v,
|
||||
ATTRIBUT_CLE_PANIER as w,
|
||||
SELECTEUR_BOUTON_SOUSTRACTION_QUANTITE as x,
|
||||
SELECTEUR_CHAMP_QUANTITE_LIGNE_PANIER as y,
|
||||
SELECTEUR_BOUTON_ADDITION_QUANTITE as z
|
||||
SELECTEUR_TOTAL_REDUCTION_VALEUR as v,
|
||||
SELECTEUR_INSTRUCTIONS_CLIENT as w,
|
||||
ATTRIBUT_CLE_PANIER as x,
|
||||
SELECTEUR_BOUTON_SOUSTRACTION_QUANTITE as y,
|
||||
SELECTEUR_CHAMP_QUANTITE_LIGNE_PANIER as z
|
||||
};
|
||||
//# sourceMappingURL=dom.js.map
|
||||
|
|
|
|||
|
|
@ -2035,13 +2035,13 @@ const html = (strings, ...args) => pipe(
|
|||
);
|
||||
const eitherSessionStorageGet = (cle) => Maybe.fromNullable(sessionStorage.getItem(cle)).toEither(ErreurEntreeInexistante(`Clé ${cle} absente dans le stockage de session.`));
|
||||
const eitherJsonParse = (chaine) => Either.encase(() => JSON.parse(chaine));
|
||||
const correspondCibleSelecteur = (cible, selecteur) => cible !== null && cible.matches(selecteur);
|
||||
const accorderCibleASelecteur = (cible, selecteur) => cible !== null && cible.matches(selecteur);
|
||||
export {
|
||||
Ra as R,
|
||||
recupereElementsAvecSelecteur as a,
|
||||
eitherJsonParse as b,
|
||||
recupereElementAvecSelecteur as c,
|
||||
correspondCibleSelecteur as d,
|
||||
accorderCibleASelecteur as d,
|
||||
eitherSessionStorageGet as e,
|
||||
recupereElementsOuLeve as f,
|
||||
equal as g,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ const emetMessageMajContenuPanier = (args) => {
|
|||
canal.postMessage({
|
||||
donnees: {
|
||||
produits: args.produits,
|
||||
sousTotalPanier: args.sousTotalPanier,
|
||||
sousTotalProduits: args.sousTotalProduits,
|
||||
sousTotalReduction: args.sousTotalReduction,
|
||||
totalPanier: args.totalPanier
|
||||
},
|
||||
type: TYPES_MESSAGES.MajContenuPanier
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"messages.js","sources":["../../src/scripts/lib/messages.ts"],"sourcesContent":["import { pipe } from \"@mobily/ts-belt\";\nimport { Either } from \"purify-ts\";\nimport { parse, type ValiError } from \"valibot\";\n\nimport type {\n MessageMajBoutonPanier,\n MessageMajBoutonPanierDonnees,\n MessageMajContenuPanier,\n MessageMajContenuPanierDonnees,\n} from \"./types/messages\";\n\nimport { NOM_CANAL_BOUTON_PANIER, NOM_CANAL_CONTENU_PANIER, TYPES_MESSAGES } from \"../constantes/messages.ts\";\nimport { reporteErreur } from \"./erreurs.ts\";\nimport { WCErrorSchema } from \"./schemas/api/erreurs.ts\";\nimport { MessageMajBoutonPanierSchema, MessageMajContenuPanierSchema } from \"./schemas/messages.ts\";\nimport { ReponseSimplifiee } from \"./types/reseau\";\nimport { eitherParse } from \"./validation.ts\";\n\nexport const canalPostMessage = (canal: BroadcastChannel, message: any): BroadcastChannel => {\n canal.postMessage(message);\n return canal;\n};\n\n// Émissions\nexport const emetMessageMajBoutonPanier = (args: MessageMajBoutonPanierDonnees): void => {\n const canal = new BroadcastChannel(NOM_CANAL_BOUTON_PANIER);\n canal.postMessage({\n donnees: {\n quantiteProduits: args.quantiteProduits,\n },\n type: TYPES_MESSAGES.MajBoutonPanier,\n } as MessageMajBoutonPanier);\n canal.close();\n};\n\nexport const emetMessageMajContenuPanier = (args: MessageMajContenuPanierDonnees): void => {\n const canal = new BroadcastChannel(NOM_CANAL_CONTENU_PANIER);\n canal.postMessage({\n donnees: {\n produits: args.produits,\n sousTotalPanier: args.sousTotalPanier,\n totalPanier: args.totalPanier,\n },\n type: TYPES_MESSAGES.MajContenuPanier,\n } as MessageMajContenuPanier);\n canal.close();\n};\n\n/**\n * Émet un unique message vers un BroadcastChannel (canal) généré sur le moment puis le ferme.\n *\n * @param nomCanal Le nom du BroadcastChannel pour lequel le message est émis.\n * @param message Le message émis.\n * @return void\n */\nexport const emetUniqueMessageCanal = <M>(nomCanal: string, message: M): void =>\n pipe(new BroadcastChannel(nomCanal), canal => canalPostMessage(canal, message), canal => canal.close());\n\n// Validations\nexport const valideMessageMajBoutonPanier = (\n evenementMessage: MessageEvent<unknown>,\n): Either<ValiError<typeof MessageMajBoutonPanierSchema>, MessageMajBoutonPanier> =>\n Either\n .of<ValiError<typeof MessageMajBoutonPanierSchema>, MessageMajBoutonPanier>(\n parse(MessageMajBoutonPanierSchema, evenementMessage.data),\n )\n .ifLeft(erreur => reporteErreur(erreur));\n\nexport const valideMessageMajContenuPanier = (\n evenementMessage: MessageEvent<unknown>,\n): Either<ValiError<typeof MessageMajContenuPanierSchema>, MessageMajContenuPanier> =>\n Either\n .of<ValiError<typeof MessageMajContenuPanierSchema>, MessageMajContenuPanier>(\n parse(MessageMajContenuPanierSchema, evenementMessage.data),\n )\n .ifLeft(erreur => reporteErreur(erreur));\n\n// Correspondances\nexport const reponseEstCodeErreurWC = (reponse: ReponseSimplifiee, codeErreurWC: string): boolean =>\n eitherParse(reponse, WCErrorSchema)\n .map(v => v.body.code === codeErreurWC)\n .orDefault(false);\n"],"names":[],"mappings":";;;;;;;;;;;;;AAwBa,MAAA,6BAA6B,CAAC,SAA8C;AACjF,QAAA,QAAQ,IAAI,iBAAiB,uBAAuB;AAC1D,QAAM,YAAY;AAAA,IAChB,SAAS;AAAA,MACP,kBAAkB,KAAK;AAAA,IACzB;AAAA,IACA,MAAM,eAAe;AAAA,EAAA,CACI;AAC3B,QAAM,MAAM;AACd;AAEa,MAAA,8BAA8B,CAAC,SAA+C;AACnF,QAAA,QAAQ,IAAI,iBAAiB,wBAAwB;AAC3D,QAAM,YAAY;AAAA,IAChB,SAAS;AAAA,MACP,UAAU,KAAK;AAAA,MACf,iBAAiB,KAAK;AAAA,MACtB,aAAa,KAAK;AAAA,IACpB;AAAA,IACA,MAAM,eAAe;AAAA,EAAA,CACK;AAC5B,QAAM,MAAM;AACd;AAaa,MAAA,+BAA+B,CAC1C,qBAEA,OACG;AAAA,EACC,MAAM,8BAA8B,iBAAiB,IAAI;AAC3D,EACC,OAAO,CAAA,WAAU,cAAc,MAAM,CAAC;AAE9B,MAAA,gCAAgC,CAC3C,qBAEA,OACG;AAAA,EACC,MAAM,+BAA+B,iBAAiB,IAAI;AAC5D,EACC,OAAO,CAAA,WAAU,cAAc,MAAM,CAAC;AAGpC,MAAM,yBAAyB,CAAC,SAA4B,iBACjE,YAAY,SAAS,aAAa,EAC/B,IAAI,CAAA,MAAK,EAAE,KAAK,SAAS,YAAY,EACrC,UAAU,KAAK;"}
|
||||
{"version":3,"file":"messages.js","sources":["../../src/scripts/lib/messages.ts"],"sourcesContent":["import { pipe } from \"@mobily/ts-belt\";\nimport { Either } from \"purify-ts\";\nimport { parse, type ValiError } from \"valibot\";\n\nimport type {\n MessageMajBoutonPanier,\n MessageMajBoutonPanierDonnees,\n MessageMajContenuPanier,\n MessageMajContenuPanierDonnees,\n} from \"./types/messages\";\nimport type { ReponseSimplifiee } from \"./types/reseau\";\n\nimport { NOM_CANAL_BOUTON_PANIER, NOM_CANAL_CONTENU_PANIER, TYPES_MESSAGES } from \"../constantes/messages.ts\";\nimport { reporteErreur } from \"./erreurs.ts\";\nimport { WCErrorSchema } from \"./schemas/api/erreurs.ts\";\nimport { MessageMajBoutonPanierSchema, MessageMajContenuPanierSchema } from \"./schemas/messages.ts\";\nimport { eitherParse } from \"./validation.ts\";\n\nexport const canalPostMessage = (canal: BroadcastChannel, message: any): BroadcastChannel => {\n canal.postMessage(message);\n return canal;\n};\n\n// Émissions\nexport const emetMessageMajBoutonPanier = (args: MessageMajBoutonPanierDonnees): void => {\n const canal = new BroadcastChannel(NOM_CANAL_BOUTON_PANIER);\n canal.postMessage({\n donnees: {\n quantiteProduits: args.quantiteProduits,\n },\n type: TYPES_MESSAGES.MajBoutonPanier,\n } as MessageMajBoutonPanier);\n canal.close();\n};\n\nexport const emetMessageMajContenuPanier = (args: MessageMajContenuPanierDonnees): void => {\n const canal = new BroadcastChannel(NOM_CANAL_CONTENU_PANIER);\n canal.postMessage({\n donnees: {\n produits: args.produits,\n sousTotalProduits: args.sousTotalProduits,\n sousTotalReduction: args.sousTotalReduction,\n totalPanier: args.totalPanier,\n },\n type: TYPES_MESSAGES.MajContenuPanier,\n } as MessageMajContenuPanier);\n canal.close();\n};\n\n/**\n * Émet un unique message vers un BroadcastChannel (canal) généré sur le moment puis le ferme.\n *\n * @param nomCanal Le nom du BroadcastChannel pour lequel le message est émis.\n * @param message Le message émis.\n * @return void\n */\nexport const emetUniqueMessageCanal = <M>(nomCanal: string, message: M): void =>\n pipe(new BroadcastChannel(nomCanal), canal => canalPostMessage(canal, message), canal => canal.close());\n\n// Validations\nexport const valideMessageMajBoutonPanier = (\n evenementMessage: MessageEvent<unknown>,\n): Either<ValiError<typeof MessageMajBoutonPanierSchema>, MessageMajBoutonPanier> =>\n Either\n .of<ValiError<typeof MessageMajBoutonPanierSchema>, MessageMajBoutonPanier>(\n parse(MessageMajBoutonPanierSchema, evenementMessage.data),\n )\n .ifLeft(erreur => reporteErreur(erreur));\n\nexport const valideMessageMajContenuPanier = (\n evenementMessage: MessageEvent<unknown>,\n): Either<ValiError<typeof MessageMajContenuPanierSchema>, MessageMajContenuPanier> =>\n Either\n .of<ValiError<typeof MessageMajContenuPanierSchema>, MessageMajContenuPanier>(\n parse(MessageMajContenuPanierSchema, evenementMessage.data),\n )\n .ifLeft(erreur => reporteErreur(erreur));\n\n// Correspondances\nexport const reponseEstCodeErreurWC = (reponse: ReponseSimplifiee, codeErreurWC: string): boolean =>\n eitherParse(reponse, WCErrorSchema)\n .map(v => v.body.code === codeErreurWC)\n .orDefault(false);\n"],"names":[],"mappings":";;;;;;;;;;;;;AAwBa,MAAA,6BAA6B,CAAC,SAA8C;AACjF,QAAA,QAAQ,IAAI,iBAAiB,uBAAuB;AAC1D,QAAM,YAAY;AAAA,IAChB,SAAS;AAAA,MACP,kBAAkB,KAAK;AAAA,IACzB;AAAA,IACA,MAAM,eAAe;AAAA,EAAA,CACI;AAC3B,QAAM,MAAM;AACd;AAEa,MAAA,8BAA8B,CAAC,SAA+C;AACnF,QAAA,QAAQ,IAAI,iBAAiB,wBAAwB;AAC3D,QAAM,YAAY;AAAA,IAChB,SAAS;AAAA,MACP,UAAU,KAAK;AAAA,MACf,mBAAmB,KAAK;AAAA,MACxB,oBAAoB,KAAK;AAAA,MACzB,aAAa,KAAK;AAAA,IACpB;AAAA,IACA,MAAM,eAAe;AAAA,EAAA,CACK;AAC5B,QAAM,MAAM;AACd;AAaa,MAAA,+BAA+B,CAC1C,qBAEA,OACG;AAAA,EACC,MAAM,8BAA8B,iBAAiB,IAAI;AAC3D,EACC,OAAO,CAAA,WAAU,cAAc,MAAM,CAAC;AAE9B,MAAA,gCAAgC,CAC3C,qBAEA,OACG;AAAA,EACC,MAAM,+BAA+B,iBAAiB,IAAI;AAC5D,EACC,OAAO,CAAA,WAAU,cAAc,MAAM,CAAC;AAGpC,MAAM,yBAAyB,CAAC,SAA4B,iBACjE,YAAY,SAAS,aAAa,EAC/B,IAAI,CAAA,MAAK,EAAE,KAAK,SAAS,YAAY,EACrC,UAAU,KAAK;"}
|
||||
|
|
@ -15,7 +15,8 @@ const MessageMajBoutonPanierSchema = object({
|
|||
});
|
||||
const MessageMajContenuPanierDonneesSchema = object({
|
||||
produits: array(WCStoreCartItemSchema),
|
||||
sousTotalPanier: number(),
|
||||
sousTotalProduits: number(),
|
||||
sousTotalReduction: number(),
|
||||
totalPanier: number()
|
||||
});
|
||||
const MessageMajContenuPanierSchema = object({
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"messages2.js","sources":["../../src/scripts/lib/schemas/messages.ts"],"sourcesContent":["/**\n * Schémas des Messages passés avec BroadcastChannel.\n */\n\nimport * as v from \"valibot\";\n\nimport { TYPES_MESSAGES } from \"../../constantes/messages.ts\";\nimport { WCStoreCartItemSchema } from \"./api/cart.ts\";\n\nexport const TypesMessagesSchema = v.enum(TYPES_MESSAGES);\n\nexport const MessageMajBoutonPanierDonneesSchema = v.object({\n quantiteProduits: v.number(),\n});\n\nexport const MessageMajBoutonPanierSchema = v.object({\n donnees: MessageMajBoutonPanierDonneesSchema,\n type: v.pipe(v.string(), v.value(TYPES_MESSAGES.MajBoutonPanier)),\n});\n\nexport const MessageMajContenuPanierDonneesSchema = v.object({\n produits: v.array(WCStoreCartItemSchema),\n sousTotalPanier: v.number(),\n totalPanier: v.number(),\n});\n\nexport const MessageMajContenuPanierSchema = v.object({\n donnees: MessageMajContenuPanierDonneesSchema,\n type: v.pipe(v.string(), v.value(TYPES_MESSAGES.MajContenuPanier)),\n});\n"],"names":["v.enum","v.object","v.number","v.pipe","v.string","v.value","v.array"],"mappings":";;;;;;;AASmCA,MAAO,cAAc;AAE3C,MAAA,sCAAsCC,OAAS;AAAA,EAC1D,kBAAkBC,OAAS;AAC7B,CAAC;AAEY,MAAA,+BAA+BD,OAAS;AAAA,EACnD,SAAS;AAAA,EACT,MAAME,KAAOC,OAAE,GAAUC,MAAQ,eAAe,eAAe,CAAC;AAClE,CAAC;AAEY,MAAA,uCAAuCJ,OAAS;AAAA,EAC3D,UAAUK,MAAQ,qBAAqB;AAAA,EACvC,iBAAiBJ,OAAS;AAAA,EAC1B,aAAaA,OAAS;AACxB,CAAC;AAEY,MAAA,gCAAgCD,OAAS;AAAA,EACpD,SAAS;AAAA,EACT,MAAME,KAAOC,OAAE,GAAUC,MAAQ,eAAe,gBAAgB,CAAC;AACnE,CAAC;"}
|
||||
{"version":3,"file":"messages2.js","sources":["../../src/scripts/lib/schemas/messages.ts"],"sourcesContent":["/**\n * Schémas des Messages passés avec BroadcastChannel.\n */\n\nimport * as v from \"valibot\";\n\nimport { TYPES_MESSAGES } from \"../../constantes/messages.ts\";\nimport { WCStoreCartItemSchema } from \"./api/cart.ts\";\n\nexport const TypesMessagesSchema = v.enum(TYPES_MESSAGES);\n\nexport const MessageMajBoutonPanierDonneesSchema = v.object({\n quantiteProduits: v.number(),\n});\n\nexport const MessageMajBoutonPanierSchema = v.object({\n donnees: MessageMajBoutonPanierDonneesSchema,\n type: v.pipe(v.string(), v.value(TYPES_MESSAGES.MajBoutonPanier)),\n});\n\nexport const MessageMajContenuPanierDonneesSchema = v.object({\n produits: v.array(WCStoreCartItemSchema),\n sousTotalProduits: v.number(),\n sousTotalReduction: v.number(),\n totalPanier: v.number(),\n});\n\nexport const MessageMajContenuPanierSchema = v.object({\n donnees: MessageMajContenuPanierDonneesSchema,\n type: v.pipe(v.string(), v.value(TYPES_MESSAGES.MajContenuPanier)),\n});\n"],"names":["v.enum","v.object","v.number","v.pipe","v.string","v.value","v.array"],"mappings":";;;;;;;AASmCA,MAAO,cAAc;AAE3C,MAAA,sCAAsCC,OAAS;AAAA,EAC1D,kBAAkBC,OAAS;AAC7B,CAAC;AAEY,MAAA,+BAA+BD,OAAS;AAAA,EACnD,SAAS;AAAA,EACT,MAAME,KAAOC,OAAE,GAAUC,MAAQ,eAAe,eAAe,CAAC;AAClE,CAAC;AAEY,MAAA,uCAAuCJ,OAAS;AAAA,EAC3D,UAAUK,MAAQ,qBAAqB;AAAA,EACvC,mBAAmBJ,OAAS;AAAA,EAC5B,oBAAoBA,OAAS;AAAA,EAC7B,aAAaA,OAAS;AACxB,CAAC;AAEY,MAAA,gCAAgCD,OAAS;AAAA,EACpD,SAAS;AAAA,EACT,MAAME,KAAOC,OAAE,GAAUC,MAAQ,eAAe,gBAAgB,CAAC;AACnE,CAAC;"}
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
import { z, N } from "./index.CeK6pfoJ.js";
|
||||
import { V as ValiError } from "./index.DxUTT09Y.js";
|
||||
import { e as ROUTE_API_APPLIQUE_COUPON, f as ROUTE_API_RETIRE_COUPON } from "./api.js";
|
||||
import { E as SELECTEUR_BOUTON_CODE_PROMO, F as SELECTEUR_CHAMP_CODE_PROMO, G as SELECTEUR_ENSEMBLE_CODE_PROMO, H as SELECTEUR_MESSAGE_CODE_PROMO, q as SELECTEUR_TOTAL_PANIER, I as SELECTEUR_TOTAL_REDUCTION, J as SELECTEUR_TOTAL_REDUCTION_VALEUR, D as ATTRIBUT_DESACTIVE, K as ATTRIBUT_CHARGEMENT, L as ATTRIBUT_CODE_PROMO_PRESENT, k as ATTRIBUT_HIDDEN } from "./dom.js";
|
||||
import { F as SELECTEUR_BOUTON_CODE_PROMO, G as SELECTEUR_CHAMP_CODE_PROMO, H as SELECTEUR_ENSEMBLE_CODE_PROMO, I as SELECTEUR_MESSAGE_CODE_PROMO, q as SELECTEUR_TOTAL_PANIER, J as SELECTEUR_TOTAL_REDUCTION, v as SELECTEUR_TOTAL_REDUCTION_VALEUR, E as ATTRIBUT_DESACTIVE, K as ATTRIBUT_CHARGEMENT, L as ATTRIBUT_CODE_PROMO_PRESENT, k as ATTRIBUT_HIDDEN } from "./dom.js";
|
||||
import { E as ERREUR_CODE_PROMO_INVALIDE } from "./erreurs.js";
|
||||
import { d as correspondCibleSelecteur, i as identity } from "./dom2.js";
|
||||
import { l as lanceAnimationCycleTexte } from "./animations.js";
|
||||
import { d as accorderCibleASelecteur, i as identity } from "./dom2.js";
|
||||
import { S as ServerError } from "./erreurs2.js";
|
||||
import { E as ErreurCodePromoInvalide } from "./codes-promo.js";
|
||||
import { e as estReponse500 } from "./gardes.js";
|
||||
|
|
@ -45,7 +46,7 @@ const initialiseElementsCodePromo = () => {
|
|||
}).with(
|
||||
{
|
||||
cible: N.when(
|
||||
(cible) => correspondCibleSelecteur(cible, SELECTEUR_BOUTON_CODE_PROMO)
|
||||
(cible) => accorderCibleASelecteur(cible, SELECTEUR_BOUTON_CODE_PROMO)
|
||||
),
|
||||
codePromoPresent: false,
|
||||
valeurCodePromo: N.string
|
||||
|
|
@ -54,24 +55,16 @@ const initialiseElementsCodePromo = () => {
|
|||
ELEMENTS.BOUTON_CODE_PROMO.setAttribute(ATTRIBUT_DESACTIVE, "");
|
||||
ELEMENTS.BOUTON_CODE_PROMO.setAttribute(ATTRIBUT_CHARGEMENT, "");
|
||||
ELEMENTS.MESSAGE_CODE_PROMO.textContent = "";
|
||||
const animation = {
|
||||
callback: () => {
|
||||
if (!ELEMENTS.BOUTON_CODE_PROMO.hasAttribute(ATTRIBUT_CHARGEMENT)) {
|
||||
clearInterval(animation.interval);
|
||||
return;
|
||||
}
|
||||
ELEMENTS.BOUTON_CODE_PROMO.textContent = animation.etapes.at(animation.index) ?? "Loading...";
|
||||
animation.index = animation.index + 1 > animation.etapes.length - 1 ? 0 : animation.index + 1;
|
||||
},
|
||||
const animation = lanceAnimationCycleTexte({
|
||||
attribut: ATTRIBUT_CHARGEMENT,
|
||||
element: ELEMENTS.BOUTON_CODE_PROMO,
|
||||
etapes: [
|
||||
"Loading",
|
||||
"Loading.",
|
||||
"Loading..",
|
||||
"Loading..."
|
||||
],
|
||||
index: 0,
|
||||
interval: 0
|
||||
};
|
||||
]
|
||||
});
|
||||
animation.callback();
|
||||
animation.interval = setInterval(animation.callback, 500);
|
||||
}).map(
|
||||
|
|
@ -82,12 +75,11 @@ const initialiseElementsCodePromo = () => {
|
|||
})
|
||||
).chain(
|
||||
(reponse) => EitherAsync(async ({ throwE }) => {
|
||||
if (estReponse500(reponse)) throwE(new ServerError("500 Server Error"));
|
||||
const reponseSimplifiee = {
|
||||
body: await reponse.json(),
|
||||
status: reponse.status
|
||||
};
|
||||
return z(reponseSimplifiee).with({
|
||||
return z(reponseSimplifiee).with({ status: 500 }, () => throwE(new ServerError("500 Server Error"))).with({
|
||||
body: N.when(() => reponseEstCodeErreurWC(reponseSimplifiee, ERREUR_CODE_PROMO_INVALIDE)),
|
||||
status: 400
|
||||
}, () => throwE(new ErreurCodePromoInvalide(recupereValeurCodePromo() ?? ""))).with({ status: 200 }, () => reponseSimplifiee.body).run();
|
||||
|
|
@ -107,14 +99,20 @@ const initialiseElementsCodePromo = () => {
|
|||
z(erreur).with(N.instanceOf(ValiError), (e) => console.error("ValiError", e.issues)).with(N.instanceOf(ErreurCodePromoInvalide), (e) => {
|
||||
ELEMENTS.MESSAGE_CODE_PROMO.textContent = "This promo code does not exist.";
|
||||
console.error(e);
|
||||
}).with(N.instanceOf(ServerError), (e) => console.error(e)).with(N.instanceOf(TypeError), (e) => console.error(e)).exhaustive();
|
||||
}).with(N.instanceOf(ServerError), (e) => {
|
||||
ELEMENTS.MESSAGE_CODE_PROMO.textContent = "Sorry, something went wrong! Please refresh the page and try again.";
|
||||
console.error(e);
|
||||
}).with(N.instanceOf(TypeError), (e) => {
|
||||
ELEMENTS.MESSAGE_CODE_PROMO.textContent = "Sorry, something went wrong! Please refresh the page and try again.";
|
||||
console.error(e);
|
||||
}).exhaustive();
|
||||
}).finally(() => {
|
||||
ELEMENTS.BOUTON_CODE_PROMO.removeAttribute(ATTRIBUT_CHARGEMENT);
|
||||
ELEMENTS.BOUTON_CODE_PROMO.removeAttribute(ATTRIBUT_DESACTIVE);
|
||||
}).run()
|
||||
).with(
|
||||
{
|
||||
cible: N.when((cible) => correspondCibleSelecteur(cible, SELECTEUR_BOUTON_CODE_PROMO)),
|
||||
cible: N.when((cible) => accorderCibleASelecteur(cible, SELECTEUR_BOUTON_CODE_PROMO)),
|
||||
codePromoPresent: true,
|
||||
valeurCodePromo: N.string
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { z } from "./index.CeK6pfoJ.js";
|
||||
import { p as parse, V as ValiError } from "./index.DxUTT09Y.js";
|
||||
import { a as ROUTE_API_RETIRE_ARTICLE_PANIER, b as ROUTE_API_MAJ_ARTICLE_PANIER, c as ROUTE_API_MAJ_CLIENT, d as ROUTE_API_NOUVELLE_COMMANDES } from "./api.js";
|
||||
import { l as SELECTEUR_ENTREES_PANIER, m as SELECTEUR_CONTENEUR_PANIER, n as SELECTEUR_SOUS_TOTAL_PRODUITS, o as SELECTEUR_SOUS_TOTAL_LIVRAISON_COUT, p as SELECTEUR_SOUS_TOTAL_LIVRAISON_PRESTATAIRE, q as SELECTEUR_TOTAL_PANIER, r as SELECTEUR_BOUTON_SEPARATION_ADRESSES, s as SELECTEUR_FORMULAIRE_PANIER, t as SELECTEUR_FORMULAIRE_FACTURATION, u as SELECTEUR_BOUTON_ACTIONS_FORMULAIRE, v as SELECTEUR_INSTRUCTIONS_CLIENT, w as ATTRIBUT_CLE_PANIER, x as SELECTEUR_BOUTON_SOUSTRACTION_QUANTITE, y as SELECTEUR_CHAMP_QUANTITE_LIGNE_PANIER, z as SELECTEUR_BOUTON_ADDITION_QUANTITE, B as SELECTEUR_BOUTON_SUPPRESSION_PANIER, A as ATTRIBUT_CONTIENT_ARTICLES, C as SELECTEUR_PRIX_LIGNE_PANIER, k as ATTRIBUT_HIDDEN, D as ATTRIBUT_DESACTIVE } from "./dom.js";
|
||||
import { l as SELECTEUR_ENTREES_PANIER, m as SELECTEUR_CONTENEUR_PANIER, n as SELECTEUR_SOUS_TOTAL_PRODUITS, o as SELECTEUR_SOUS_TOTAL_LIVRAISON_COUT, p as SELECTEUR_SOUS_TOTAL_LIVRAISON_PRESTATAIRE, q as SELECTEUR_TOTAL_PANIER, r as SELECTEUR_BOUTON_SEPARATION_ADRESSES, s as SELECTEUR_FORMULAIRE_PANIER, t as SELECTEUR_FORMULAIRE_FACTURATION, u as SELECTEUR_BOUTON_ACTIONS_FORMULAIRE, v as SELECTEUR_TOTAL_REDUCTION_VALEUR, w as SELECTEUR_INSTRUCTIONS_CLIENT, x as ATTRIBUT_CLE_PANIER, y as SELECTEUR_BOUTON_SOUSTRACTION_QUANTITE, z as SELECTEUR_CHAMP_QUANTITE_LIGNE_PANIER, B as SELECTEUR_BOUTON_ADDITION_QUANTITE, C as SELECTEUR_BOUTON_SUPPRESSION_PANIER, A as ATTRIBUT_CONTIENT_ARTICLES, D as SELECTEUR_PRIX_LIGNE_PANIER, k as ATTRIBUT_HIDDEN, E as ATTRIBUT_DESACTIVE } from "./dom.js";
|
||||
import { N as NOM_CANAL_BOUTON_PANIER, a as NOM_CANAL_CONTENU_PANIER } from "./messages3.js";
|
||||
import { r as recupereElementOuLeve, a as recupereElementsAvecSelecteur, e as eitherSessionStorageGet, b as eitherJsonParse, c as recupereElementAvecSelecteur } from "./dom2.js";
|
||||
import { l as leveServerError, r as reporteErreur, a as leveErreur } from "./erreurs2.js";
|
||||
|
|
@ -28,6 +28,7 @@ import "./cart2.js";
|
|||
import "./cart-coupons.js";
|
||||
import "./orders3.js";
|
||||
import "./erreurs.js";
|
||||
import "./animations.js";
|
||||
import "./codes-promo.js";
|
||||
import "./cart-apply-coupon.js";
|
||||
import "./cart-remove-coupon.js";
|
||||
|
|
@ -53,6 +54,9 @@ const SOUS_TOTAL_LIVRAISON_PRESTATAIRE = pipe(
|
|||
recupereElementDocumentEither(SELECTEUR_SOUS_TOTAL_LIVRAISON_PRESTATAIRE),
|
||||
recupereElementOuLeve
|
||||
);
|
||||
const SOUS_TOTAL_REDUCTION = recupereElementDansDocumentOuLeve(
|
||||
SELECTEUR_TOTAL_REDUCTION_VALEUR
|
||||
);
|
||||
const INSTRUCTIONS_CLIENT = recupereElementDansDocumentOuLeve(
|
||||
SELECTEUR_INSTRUCTIONS_CLIENT
|
||||
);
|
||||
|
|
@ -138,7 +142,8 @@ const initialiseMajEntreesPanier = () => {
|
|||
emetMessageMajBoutonPanier({ quantiteProduits: panier.items_count });
|
||||
emetMessageMajContenuPanier({
|
||||
produits: panier.items,
|
||||
sousTotalPanier: Number(panier.totals.total_items) / 100,
|
||||
sousTotalProduits: Number(panier.totals.total_items) / 100,
|
||||
sousTotalReduction: Number(panier.totals.total_discount) / 100,
|
||||
totalPanier: Number(panier.totals.total_price) / 100
|
||||
});
|
||||
entree.remove();
|
||||
|
|
@ -178,7 +183,8 @@ const initialiseMajEntreesPanier = () => {
|
|||
emetMessageMajBoutonPanier({ quantiteProduits: panier.items_count });
|
||||
emetMessageMajContenuPanier({
|
||||
produits: panier.items,
|
||||
sousTotalPanier: Number(panier.totals.total_items) / 100,
|
||||
sousTotalProduits: Number(panier.totals.total_items) / 100,
|
||||
sousTotalReduction: Number(panier.totals.total_discount) / 100,
|
||||
totalPanier: Number(panier.totals.total_price) / 100
|
||||
});
|
||||
})
|
||||
|
|
@ -218,7 +224,8 @@ const initialiseMajEntreesPanier = () => {
|
|||
emetMessageMajBoutonPanier({ quantiteProduits: panier.items_count });
|
||||
emetMessageMajContenuPanier({
|
||||
produits: panier.items,
|
||||
sousTotalPanier: Number(panier.totals.total_items) / 100,
|
||||
sousTotalProduits: Number(panier.totals.total_items) / 100,
|
||||
sousTotalReduction: Number(panier.totals.total_discount) / 100,
|
||||
totalPanier: Number(panier.totals.total_price) / 100
|
||||
});
|
||||
})
|
||||
|
|
@ -260,7 +267,8 @@ const initialiseMajContenuPanier = () => {
|
|||
champQuantite.setAttribute("value", String(ligne.quantity));
|
||||
majEtatsActivationBoutons(entrees);
|
||||
});
|
||||
SOUS_TOTAL_PRODUITS.textContent = `${String(donnees.sousTotalPanier)}€`;
|
||||
SOUS_TOTAL_REDUCTION.textContent = `-${String(donnees.sousTotalReduction)}€`;
|
||||
SOUS_TOTAL_PRODUITS.textContent = `${String(donnees.sousTotalProduits)}€`;
|
||||
TOTAL_PANIER.textContent = `${String(donnees.totalPanier)}€`;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { z } from "./index.CeK6pfoJ.js";
|
||||
import { g as ROUTE_API_AJOUTE_ARTICLE_PANIER, E as ENTETE_WC_NONCE } from "./api.js";
|
||||
import { M as SELECTEUR_BOUTON_AJOUT_PANIER, N as SELECTEUR_SELECTEUR_QUANTITE, O as SELECTEUR_LIENS_ONGLETS, P as SELECTEUR_SECTIONS_CONTENUS, Q as SELECTEUR_PRIX_PRODUIT, R as SELECTEUR_CONTENEUR_FLECHES_DEFILEMENT, T as SELECTEUR_FLECHE_DEFILEMENT_GAUCHE, U as SELECTEUR_FLECHE_DEFILEMENT_DROITE, V as SELECTEUR_PHOTOS_PRODUIT, W as SELECTEUR_IMAGE_COLONNE_GAUCHE, X as SELECTEUR_IMAGES_COLONNE_DROITE, Y as ATTRIBUT_INDEX_IMAGE_ACTIVE, Z as ATTRIBUT_ARIA_SELECTED, k as ATTRIBUT_HIDDEN, D as ATTRIBUT_DESACTIVE, _ as ATTRIBUT_PRIX } from "./dom.js";
|
||||
import { M as SELECTEUR_BOUTON_AJOUT_PANIER, N as SELECTEUR_SELECTEUR_QUANTITE, O as SELECTEUR_LIENS_ONGLETS, P as SELECTEUR_SECTIONS_CONTENUS, Q as SELECTEUR_PRIX_PRODUIT, R as SELECTEUR_CONTENEUR_FLECHES_DEFILEMENT, T as SELECTEUR_FLECHE_DEFILEMENT_GAUCHE, U as SELECTEUR_FLECHE_DEFILEMENT_DROITE, V as SELECTEUR_PHOTOS_PRODUIT, W as SELECTEUR_IMAGE_COLONNE_GAUCHE, X as SELECTEUR_IMAGES_COLONNE_DROITE, Y as ATTRIBUT_INDEX_IMAGE_ACTIVE, Z as ATTRIBUT_ARIA_SELECTED, k as ATTRIBUT_HIDDEN, E as ATTRIBUT_DESACTIVE, _ as ATTRIBUT_PRIX } from "./dom.js";
|
||||
import { r as recupereElementOuLeve, f as recupereElementsOuLeve, R as Ra } from "./dom2.js";
|
||||
import { l as leveServerError, r as reporteErreur } from "./erreurs2.js";
|
||||
import { b as estHTMLSelectElement, e as estReponse500, a as estError } from "./gardes.js";
|
||||
|
|
|
|||
|
|
@ -31,15 +31,30 @@ if (!$possede_session_wc) {
|
|||
return;
|
||||
}
|
||||
|
||||
/** @var bool $est_panier__vide */
|
||||
$est_panier_vide = WC()->cart->is_empty();
|
||||
|
||||
// Redirige à la page d'accueil si le Panier est vide
|
||||
if ($est_panier_vide) {
|
||||
if (WC()->cart->is_empty()) {
|
||||
header("Location: $url_accueil");
|
||||
return;
|
||||
}
|
||||
|
||||
// Vérifie que les paramètres d'URLs nécessaires soient présents
|
||||
/** @var string $order_id */
|
||||
$order_id = $_GET["order_id"];
|
||||
if (!$order_id) {
|
||||
$reponse = ["succes" => false, "status" => "order_key is missing"];
|
||||
echo json_encode($reponse);
|
||||
http_response_code(400);
|
||||
return;
|
||||
}
|
||||
/** @var string $order_key */
|
||||
$order_key = $_GET["order_key"];
|
||||
if (!$order_key) {
|
||||
$reponse = ["succes" => false, "status" => "order_key is missing"];
|
||||
echo json_encode($reponse);
|
||||
http_response_code(400);
|
||||
return;
|
||||
}
|
||||
|
||||
// Récupère le Panier et l'Email du Client
|
||||
/** @var WC_Cart $panier */
|
||||
$panier = WC()->cart;
|
||||
|
|
@ -49,7 +64,6 @@ $email_client = WC()->session->get("customer")["email"];
|
|||
$articles = [];
|
||||
|
||||
// TODO: Cas des Produits Simples : Pas de Attribute Summary !
|
||||
|
||||
foreach ($panier->get_cart() as $cle_panier => $article_panier) {
|
||||
$titre_produit = $article_panier["data"]?->get_title();
|
||||
$est_variation = $article_panier["variation_id"] !== null;
|
||||
|
|
@ -69,40 +83,47 @@ foreach ($panier->get_cart() as $cle_panier => $article_panier) {
|
|||
]);
|
||||
}
|
||||
|
||||
/** @var string $order_id */
|
||||
$order_id = $_GET["order_id"];
|
||||
if (!$order_id) {
|
||||
$reponse = ["succes" => false, "status" => "order_key is missing"];
|
||||
echo json_encode($reponse);
|
||||
http_response_code(400);
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var string $order_key */
|
||||
$order_key = $_GET["order_key"];
|
||||
if (!$order_key) {
|
||||
$reponse = ["succes" => false, "status" => "order_key is missing"];
|
||||
echo json_encode($reponse);
|
||||
http_response_code(400);
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var WC_Order $order */
|
||||
$order = wc_get_order($order_id);
|
||||
// Récupère la Commande et la Méthode de Livraison
|
||||
/** @var WC_Order $commande */
|
||||
$commande = wc_get_order($order_id);
|
||||
/** @var mixed $methode_livraison */
|
||||
$methode_livraison = [
|
||||
"nom" => $order->get_shipping_method(),
|
||||
"cout" => $order->get_shipping_total(),
|
||||
"nom" => $commande->get_shipping_method(),
|
||||
"cout" => $commande->get_shipping_total(),
|
||||
];
|
||||
|
||||
// Sélectionne la clé API Stripe
|
||||
\Stripe\Stripe::setApiKey(Config::get("STRIPE_API_SECRET"));
|
||||
|
||||
// Met à jour les Codes promos
|
||||
$coupons_stripe = collect(\Stripe\Coupon::all()->data);
|
||||
$coupons_wc = collect(WC()->cart->get_coupons())
|
||||
->map(function (WC_Coupon $coupon) {
|
||||
return [
|
||||
"duration" => "forever",
|
||||
"id" => $coupon->get_code(),
|
||||
"name" => $coupon->get_code(),
|
||||
$coupon->get_discount_type() == "fixed_cart" ? "amount_off" : "percent_off" => $coupon->get_amount(),
|
||||
];
|
||||
})
|
||||
->each(function (array $item) use ($coupons_stripe) {
|
||||
// Si le code promo n'existe, le créé
|
||||
if (!$coupons_stripe->contains("name", $item["name"])) {
|
||||
\Stripe\Coupon::create($item);
|
||||
}
|
||||
});
|
||||
$reductions_stripe = $coupons_wc
|
||||
->map(function (array $coupon) {
|
||||
return ["coupon" => $coupon["name"]];
|
||||
})
|
||||
->values()
|
||||
->toArray();
|
||||
/** @var Session $session_checkout_stripe */
|
||||
$session_checkout_stripe = \Stripe\Checkout\Session::create(
|
||||
[
|
||||
"cancel_url" => "$url_accueil",
|
||||
"customer_email" => $email_client,
|
||||
"discounts" => $reductions_stripe,
|
||||
"line_items" => $articles,
|
||||
"mode" => "payment",
|
||||
"success_url" => "$url_succes_commande?session_id={CHECKOUT_SESSION_ID}",
|
||||
|
|
@ -131,5 +152,6 @@ $session_checkout_stripe = \Stripe\Checkout\Session::create(
|
|||
// echo json_encode($session_checkout_stripe);
|
||||
header("HTTP/1.1 303 See Other");
|
||||
header("Location: " . $session_checkout_stripe->url);
|
||||
// contact@gcch.fr
|
||||
|
||||
exit();
|
||||
|
|
|
|||
|
|
@ -92,7 +92,8 @@
|
|||
border: initial;
|
||||
border-top: 1px solid var(--couleur-noir);
|
||||
|
||||
&::-webkit-outer-spin-button, &::-webkit-inner-spin-button {
|
||||
&::-webkit-outer-spin-button,
|
||||
&::-webkit-inner-spin-button {
|
||||
margin: 0; /* 2 */
|
||||
appearance: none; /* 2 */
|
||||
}
|
||||
|
|
@ -150,10 +151,6 @@
|
|||
place-content: center;
|
||||
margin: auto;
|
||||
|
||||
input {
|
||||
width: 20rem;
|
||||
}
|
||||
|
||||
/*
|
||||
* 1. Longueur minimale pour le Bouton n'ait pas à changer de taille quel que soit son texte
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
/** Fonctions pour la création de simples animations JavaScript. */
|
||||
|
||||
// Types
|
||||
interface AnimationCycleTexte {
|
||||
callback: () => void;
|
||||
etapes: Array<string>;
|
||||
index: number;
|
||||
interval: NodeJS.Timeout;
|
||||
}
|
||||
|
||||
interface ParametresAnimationCycleTexte {
|
||||
attribut: string;
|
||||
element: HTMLElement;
|
||||
etapes: Array<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Créer le nécessaire pour une animation s'exécutant jusqu'à ce que un interval soit manuellement arrêté. L'animation
|
||||
* consiste en la mise à jour d'un texte avec l'utilisation de toutes les valeurs d'un tableau, une par une.
|
||||
*
|
||||
* @param args Les paramètres nécessaires pour la création de l'animation.
|
||||
* @returns Un objet contenant les informations de l'animation, notamment l'interval utilisable pour son arrêt.
|
||||
*/
|
||||
export const lanceAnimationCycleTexte = (args: ParametresAnimationCycleTexte): AnimationCycleTexte => {
|
||||
const animation: AnimationCycleTexte = {
|
||||
callback: (): void => {
|
||||
// Arrête le cycle quand l'Attribut de chargement n'est plus présent
|
||||
if (!args.element.hasAttribute(args.attribut)) {
|
||||
clearInterval(animation.interval);
|
||||
return;
|
||||
}
|
||||
|
||||
// Change le texte
|
||||
args.element.textContent = animation.etapes.at(animation.index) ?? "Loading...";
|
||||
// Incrémente ou réinitialise l'index
|
||||
animation.index = animation.index + 1 > animation.etapes.length - 1 ? 0 : animation.index + 1;
|
||||
},
|
||||
etapes: args.etapes,
|
||||
index: 0,
|
||||
interval: setInterval(() => {}, 2147483647),
|
||||
};
|
||||
|
||||
return animation;
|
||||
};
|
||||
|
|
@ -129,7 +129,7 @@ export const eitherJsonParse = (chaine: string): Either<SyntaxError, JSONValue>
|
|||
Either.encase(() => JSON.parse(chaine));
|
||||
|
||||
/** TODO */
|
||||
export const correspondCibleSelecteur = <E extends HTMLElement = HTMLElement>(
|
||||
export const accorderCibleASelecteur = <E extends HTMLElement = HTMLElement>(
|
||||
cible: EventTarget | null,
|
||||
selecteur: string,
|
||||
): cible is E => cible !== null && (cible as HTMLElement).matches(selecteur);
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ import type {
|
|||
MessageMajContenuPanier,
|
||||
MessageMajContenuPanierDonnees,
|
||||
} from "./types/messages";
|
||||
import type { ReponseSimplifiee } from "./types/reseau";
|
||||
|
||||
import { NOM_CANAL_BOUTON_PANIER, NOM_CANAL_CONTENU_PANIER, TYPES_MESSAGES } from "../constantes/messages.ts";
|
||||
import { reporteErreur } from "./erreurs.ts";
|
||||
import { WCErrorSchema } from "./schemas/api/erreurs.ts";
|
||||
import { MessageMajBoutonPanierSchema, MessageMajContenuPanierSchema } from "./schemas/messages.ts";
|
||||
import { ReponseSimplifiee } from "./types/reseau";
|
||||
import { eitherParse } from "./validation.ts";
|
||||
|
||||
export const canalPostMessage = (canal: BroadcastChannel, message: any): BroadcastChannel => {
|
||||
|
|
@ -38,7 +38,8 @@ export const emetMessageMajContenuPanier = (args: MessageMajContenuPanierDonnees
|
|||
canal.postMessage({
|
||||
donnees: {
|
||||
produits: args.produits,
|
||||
sousTotalPanier: args.sousTotalPanier,
|
||||
sousTotalProduits: args.sousTotalProduits,
|
||||
sousTotalReduction: args.sousTotalReduction,
|
||||
totalPanier: args.totalPanier,
|
||||
},
|
||||
type: TYPES_MESSAGES.MajContenuPanier,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ export const MessageMajBoutonPanierSchema = v.object({
|
|||
|
||||
export const MessageMajContenuPanierDonneesSchema = v.object({
|
||||
produits: v.array(WCStoreCartItemSchema),
|
||||
sousTotalPanier: v.number(),
|
||||
sousTotalProduits: v.number(),
|
||||
sousTotalReduction: v.number(),
|
||||
totalPanier: v.number(),
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ import {
|
|||
SELECTEUR_TOTAL_REDUCTION_VALEUR,
|
||||
} from "./constantes/dom";
|
||||
import { ERREUR_CODE_PROMO_INVALIDE } from "./constantes/erreurs";
|
||||
import { correspondCibleSelecteur } from "./lib/dom";
|
||||
import { lanceAnimationCycleTexte } from "./lib/animations";
|
||||
import { accorderCibleASelecteur } from "./lib/dom";
|
||||
import { ServerError } from "./lib/erreurs";
|
||||
import { ErreurCodePromoInvalide } from "./lib/erreurs/codes-promo";
|
||||
import { estReponse500 } from "./lib/gardes";
|
||||
|
|
@ -45,7 +46,6 @@ type EtatsPage = {
|
|||
/** Un nonce pour l'authentification de requêtes API vers le backend WooCommerce. */
|
||||
nonce: string;
|
||||
};
|
||||
|
||||
// @ts-expect-error -- États injectés par le modèle PHP
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- États injectés par le modèle PHP
|
||||
const ETATS_PAGE: EtatsPage = _etats;
|
||||
|
|
@ -61,7 +61,6 @@ const ELEMENTS = {
|
|||
};
|
||||
|
||||
export const initialiseElementsCodePromo = (): void => {
|
||||
// Récupère le code promo s'il existe
|
||||
const recupereValeurCodePromo = (): null | string =>
|
||||
Maybe.fromFalsy(ELEMENTS.CHAMP_CODE_PROMO.value.trim()).extractNullable();
|
||||
const recuperePresenceCodePromo = (): boolean =>
|
||||
|
|
@ -75,44 +74,37 @@ export const initialiseElementsCodePromo = (): void => {
|
|||
valeurCodePromo: recupereValeurCodePromo(),
|
||||
})
|
||||
// Un code promo doit être ajouté
|
||||
// Aucun code promo n'est déjà présent et une valeur acceptable existe
|
||||
.with(
|
||||
{
|
||||
cible: P.when((cible: EventTarget | null) =>
|
||||
correspondCibleSelecteur<HTMLButtonElement>(cible, SELECTEUR_BOUTON_CODE_PROMO)
|
||||
accorderCibleASelecteur<HTMLButtonElement>(cible, SELECTEUR_BOUTON_CODE_PROMO)
|
||||
),
|
||||
codePromoPresent: false,
|
||||
valeurCodePromo: P.string,
|
||||
},
|
||||
({ valeurCodePromo }) =>
|
||||
void EitherAsync
|
||||
// Vérifie le Schéma des arguments
|
||||
.liftEither(eitherParse({ code: valeurCodePromo }, WCStoreCartApplyCouponArgsSchema))
|
||||
.ifRight(() => {
|
||||
// Désactive le Bouton pour empêcher des requêtes concurrentes
|
||||
ELEMENTS.BOUTON_CODE_PROMO.setAttribute(ATTRIBUT_DESACTIVE, "");
|
||||
ELEMENTS.BOUTON_CODE_PROMO.setAttribute(ATTRIBUT_CHARGEMENT, "");
|
||||
// Réinitialise le Message à l'Utilisateur
|
||||
ELEMENTS.MESSAGE_CODE_PROMO.textContent = "";
|
||||
|
||||
// Lance un cycle d'animation sur le texte de chargement
|
||||
const animation = {
|
||||
callback: () => {
|
||||
if (!ELEMENTS.BOUTON_CODE_PROMO.hasAttribute(ATTRIBUT_CHARGEMENT)) {
|
||||
clearInterval(animation.interval);
|
||||
return;
|
||||
}
|
||||
|
||||
ELEMENTS.BOUTON_CODE_PROMO.textContent = animation.etapes.at(animation.index)
|
||||
?? "Loading...";
|
||||
animation.index = animation.index + 1 > animation.etapes.length - 1 ? 0 : animation.index + 1;
|
||||
},
|
||||
const animation = lanceAnimationCycleTexte({
|
||||
attribut: ATTRIBUT_CHARGEMENT,
|
||||
element: ELEMENTS.BOUTON_CODE_PROMO,
|
||||
etapes: [
|
||||
"Loading",
|
||||
"Loading.",
|
||||
"Loading..",
|
||||
"Loading...",
|
||||
],
|
||||
index: 0,
|
||||
interval: 0,
|
||||
};
|
||||
});
|
||||
animation.callback();
|
||||
animation.interval = setInterval(animation.callback, 500);
|
||||
})
|
||||
|
|
@ -127,14 +119,13 @@ export const initialiseElementsCodePromo = (): void => {
|
|||
// Traite les cas d'Erreur
|
||||
.chain((reponse: Response) =>
|
||||
EitherAsync<ErreurCodePromoInvalide | ServerError, unknown>(async ({ throwE }) => {
|
||||
if (estReponse500(reponse)) throwE(new ServerError("500 Server Error"));
|
||||
|
||||
const reponseSimplifiee: ReponseSimplifiee = {
|
||||
body: await reponse.json(),
|
||||
status: reponse.status,
|
||||
};
|
||||
|
||||
return match(reponseSimplifiee)
|
||||
.with({ status: 500 }, () => throwE(new ServerError("500 Server Error")))
|
||||
.with({
|
||||
body: P.when(() => reponseEstCodeErreurWC(reponseSimplifiee, ERREUR_CODE_PROMO_INVALIDE)),
|
||||
status: 400,
|
||||
|
|
@ -162,14 +153,24 @@ export const initialiseElementsCodePromo = (): void => {
|
|||
.ifLeft(erreur => {
|
||||
// Rétablis le texte d'origine
|
||||
ELEMENTS.BOUTON_CODE_PROMO.textContent = "Apply";
|
||||
|
||||
// Traite les Erreurs et affiche un Message à l'Utilisateur
|
||||
match(erreur)
|
||||
.with(P.instanceOf(ValiError), e => console.error("ValiError", e.issues))
|
||||
.with(P.instanceOf(ErreurCodePromoInvalide), e => {
|
||||
ELEMENTS.MESSAGE_CODE_PROMO.textContent = "This promo code does not exist.";
|
||||
console.error(e);
|
||||
})
|
||||
.with(P.instanceOf(ServerError), e => console.error(e))
|
||||
.with(P.instanceOf(TypeError), e => console.error(e))
|
||||
.with(P.instanceOf(ServerError), e => {
|
||||
ELEMENTS.MESSAGE_CODE_PROMO.textContent =
|
||||
"Sorry, something went wrong! Please refresh the page and try again.";
|
||||
console.error(e);
|
||||
})
|
||||
.with(P.instanceOf(TypeError), e => {
|
||||
ELEMENTS.MESSAGE_CODE_PROMO.textContent =
|
||||
"Sorry, something went wrong! Please refresh the page and try again.";
|
||||
console.error(e);
|
||||
})
|
||||
.exhaustive();
|
||||
})
|
||||
.finally(() => {
|
||||
|
|
@ -180,9 +181,10 @@ export const initialiseElementsCodePromo = (): void => {
|
|||
.run(),
|
||||
)
|
||||
// Un code promo doit être retiré
|
||||
// Un code promo est présent sous forme de chaîne
|
||||
.with(
|
||||
{
|
||||
cible: P.when(cible => correspondCibleSelecteur<HTMLButtonElement>(cible, SELECTEUR_BOUTON_CODE_PROMO)),
|
||||
cible: P.when(cible => accorderCibleASelecteur<HTMLButtonElement>(cible, SELECTEUR_BOUTON_CODE_PROMO)),
|
||||
codePromoPresent: true,
|
||||
valeurCodePromo: P.string,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import {
|
|||
SELECTEUR_SOUS_TOTAL_LIVRAISON_PRESTATAIRE,
|
||||
SELECTEUR_SOUS_TOTAL_PRODUITS,
|
||||
SELECTEUR_TOTAL_PANIER,
|
||||
SELECTEUR_TOTAL_REDUCTION_VALEUR,
|
||||
} from "./constantes/dom.ts";
|
||||
import { NOM_CANAL_BOUTON_PANIER, NOM_CANAL_CONTENU_PANIER } from "./constantes/messages.ts";
|
||||
import {
|
||||
|
|
@ -109,6 +110,9 @@ const SOUS_TOTAL_LIVRAISON_PRESTATAIRE: HTMLSpanElement = pipe(
|
|||
recupereElementDocumentEither<HTMLSpanElement>(SELECTEUR_SOUS_TOTAL_LIVRAISON_PRESTATAIRE),
|
||||
recupereElementOuLeve,
|
||||
);
|
||||
const SOUS_TOTAL_REDUCTION: HTMLSpanElement = recupereElementDansDocumentOuLeve<HTMLSpanElement>(
|
||||
SELECTEUR_TOTAL_REDUCTION_VALEUR,
|
||||
);
|
||||
const INSTRUCTIONS_CLIENT: HTMLTextAreaElement = recupereElementDansDocumentOuLeve(
|
||||
SELECTEUR_INSTRUCTIONS_CLIENT,
|
||||
);
|
||||
|
|
@ -238,7 +242,8 @@ const initialiseMajEntreesPanier = (): void => {
|
|||
// Émet un Message avec le nouveau contenu du Panier
|
||||
emetMessageMajContenuPanier({
|
||||
produits: panier.items,
|
||||
sousTotalPanier: Number(panier.totals.total_items) / 100,
|
||||
sousTotalProduits: Number(panier.totals.total_items) / 100,
|
||||
sousTotalReduction: Number(panier.totals.total_discount) / 100,
|
||||
totalPanier: Number(panier.totals.total_price) / 100,
|
||||
});
|
||||
// Retire l'entrée du Panier du DOM
|
||||
|
|
@ -297,7 +302,8 @@ const initialiseMajEntreesPanier = (): void => {
|
|||
// Émet un Message avec le nouveau contenu du Panier
|
||||
emetMessageMajContenuPanier({
|
||||
produits: panier.items,
|
||||
sousTotalPanier: Number(panier.totals.total_items) / 100,
|
||||
sousTotalProduits: Number(panier.totals.total_items) / 100,
|
||||
sousTotalReduction: Number(panier.totals.total_discount) / 100,
|
||||
totalPanier: Number(panier.totals.total_price) / 100,
|
||||
});
|
||||
}),
|
||||
|
|
@ -353,7 +359,8 @@ const initialiseMajEntreesPanier = (): void => {
|
|||
// Émet un Message avec le nouveau contenu du Panier
|
||||
emetMessageMajContenuPanier({
|
||||
produits: panier.items,
|
||||
sousTotalPanier: Number(panier.totals.total_items) / 100,
|
||||
sousTotalProduits: Number(panier.totals.total_items) / 100,
|
||||
sousTotalReduction: Number(panier.totals.total_discount) / 100,
|
||||
totalPanier: Number(panier.totals.total_price) / 100,
|
||||
});
|
||||
}),
|
||||
|
|
@ -418,7 +425,8 @@ const initialiseMajContenuPanier = (): void => {
|
|||
});
|
||||
|
||||
// Met à jour les totaux du Panier
|
||||
SOUS_TOTAL_PRODUITS.textContent = `${String(donnees.sousTotalPanier)}€`;
|
||||
SOUS_TOTAL_REDUCTION.textContent = `-${String(donnees.sousTotalReduction)}€`;
|
||||
SOUS_TOTAL_PRODUITS.textContent = `${String(donnees.sousTotalProduits)}€`;
|
||||
TOTAL_PANIER.textContent = `${String(donnees.totalPanier)}€`;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
BIN
web/app/uploads/2024/11/DSC0240-300x300.jpg
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
web/app/uploads/2024/11/DSC0240.jpg
Normal file
|
After Width: | Height: | Size: 716 KiB |
BIN
web/app/uploads/2024/11/DSC0242-300x300.jpg
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
web/app/uploads/2024/11/DSC0242.jpg
Normal file
|
After Width: | Height: | Size: 659 KiB |
BIN
web/app/uploads/2024/11/DSC0249-300x300.jpg
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
web/app/uploads/2024/11/DSC0249.jpg
Normal file
|
After Width: | Height: | Size: 545 KiB |
BIN
web/app/uploads/2024/11/DSC0251-300x300.jpg
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
web/app/uploads/2024/11/DSC0251.jpg
Normal file
|
After Width: | Height: | Size: 600 KiB |
BIN
web/app/uploads/2024/11/FUYOU-B0-s-300x300.jpg
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
web/app/uploads/2024/11/FUYOU-B0-s.jpg
Normal file
|
After Width: | Height: | Size: 452 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.6 KiB |