2024-10-02

This commit is contained in:
gcch 2024-10-02 15:44:13 +02:00
commit 59a236f0fa
45 changed files with 230 additions and 106 deletions

View file

@ -1,5 +1,6 @@
{ {
"$schema": "/phpactor.schema.json", "$schema": "/phpactor.schema.json",
"php_code_sniffer.enabled": false, "php_code_sniffer.enabled": false,
"language_server_psalm.enabled": false "language_server_psalm.enabled": false,
"language_server_phpstan.enabled": true
} }

View file

@ -14,6 +14,7 @@
"glitchtip", "glitchtip",
"GLITCHTIP", "GLITCHTIP",
"leve", "leve",
"phpstan",
"Proprietes", "Proprietes",
"reponse", "reponse",
"requete", "requete",
@ -26,6 +27,7 @@
"tabpanel", "tabpanel",
"tete", "tete",
"tseslint", "tseslint",
"Vali",
"validite" "validite"
], ],
"djlint.pythonPath": "/home/gcch/.local/share/pipxu/venvs/8/bin/python", "djlint.pythonPath": "/home/gcch/.local/share/pipxu/venvs/8/bin/python",

View file

@ -61,8 +61,9 @@
"wpackagist-theme/twentytwentyfour": "^1.0" "wpackagist-theme/twentytwentyfour": "^1.0"
}, },
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": "^3.7.1", "phpstan/phpstan": "^1.12",
"roave/security-advisories": "dev-latest", "roave/security-advisories": "dev-latest",
"squizlabs/php_codesniffer": "^3.7.1",
"vimeo/psalm": "^5.25" "vimeo/psalm": "^5.25"
}, },
"config": { "config": {

60
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "9680ce236cff6786f09ed3d599b59f5d", "content-hash": "880c2b87f8157527e37d8d8b87344c62",
"packages": [ "packages": [
{ {
"name": "composer/installers", "name": "composer/installers",
@ -2917,6 +2917,64 @@
}, },
"time": "2024-09-26T07:23:32+00:00" "time": "2024-09-26T07:23:32+00:00"
}, },
{
"name": "phpstan/phpstan",
"version": "1.12.5",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17",
"reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
},
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"keywords": [
"dev",
"static analysis"
],
"support": {
"docs": "https://phpstan.org/user-guide/getting-started",
"forum": "https://github.com/phpstan/phpstan/discussions",
"issues": "https://github.com/phpstan/phpstan/issues",
"security": "https://github.com/phpstan/phpstan/security/policy",
"source": "https://github.com/phpstan/phpstan-src"
},
"funding": [
{
"url": "https://github.com/ondrejmirtes",
"type": "github"
},
{
"url": "https://github.com/phpstan",
"type": "github"
}
],
"time": "2024-09-26T12:45:22+00:00"
},
{ {
"name": "psr/container", "name": "psr/container",
"version": "2.0.2", "version": "2.0.2",

9
phpstan.neon Normal file
View file

@ -0,0 +1,9 @@
parameters:
level: 6
paths:
- web/app/themes/haiku-atelier-2024
scanDirectories:
- web/wp
- web/app/plugins
typeAliases:
InformationsProduitShop: 'array{id: int, nom: string, prix: string, photo_repos: string, photo_survol: string, url: string}'

View file

@ -13,13 +13,13 @@ require_once __DIR__ . "/src/inc/TraitementInformations.php";
$contexte = Timber::context(); $contexte = Timber::context();
$modeles = ["boutique.twig"]; $modeles = ["boutique.twig"];
// Informations brutes des Produits /** @var array<WC_Product> $informations_produits Les informations brutes des Produits. */
$informations_produits = wc_get_products([ $informations_produits = wc_get_products([
"orderby" => "date", "orderby" => "date",
"order" => "DESC", "order" => "DESC",
]); ]);
// Informations nécessaires pour la grille des Produits /** @var InformationsProduitShop $produits Les informations strictement nécessaires pour la grille des Produits. */
$produits = array_map($callback = "recupere_informations_produit_shop", $array = $informations_produits); $produits = array_map(callback: "recupere_informations_produit_shop", array: $informations_produits);
$contexte["produits"] = $produits; $contexte["produits"] = $produits;
// Rendu // Rendu

View file

@ -7,17 +7,6 @@
"file": "chunk-7BKSRZNG.js", "file": "chunk-7BKSRZNG.js",
"name": "chunk-7BKSRZNG" "name": "chunk-7BKSRZNG"
}, },
"_chunk-RU7WR4KH.js": {
"file": "chunk-RU7WR4KH.js",
"name": "chunk-RU7WR4KH"
},
"_chunk-VROY5Y5B.js": {
"file": "chunk-VROY5Y5B.js",
"name": "chunk-VROY5Y5B",
"imports": [
"_chunk-RU7WR4KH.js"
]
},
"_exports.js": { "_exports.js": {
"file": "exports.js", "file": "exports.js",
"name": "exports" "name": "exports"
@ -43,7 +32,7 @@
"isEntry": true "isEntry": true
}, },
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/messages.ts": { "web/app/themes/haiku-atelier-2024/src/scripts/constantes/messages.ts": {
"file": "messages2.js", "file": "messages3.js",
"name": "messages", "name": "messages",
"src": "web/app/themes/haiku-atelier-2024/src/scripts/constantes/messages.ts", "src": "web/app/themes/haiku-atelier-2024/src/scripts/constantes/messages.ts",
"isEntry": true "isEntry": true
@ -106,19 +95,27 @@
"_Either.js" "_Either.js"
] ]
}, },
"web/app/themes/haiku-atelier-2024/src/scripts/lib/messages.ts": {
"file": "messages.js",
"name": "messages",
"src": "web/app/themes/haiku-atelier-2024/src/scripts/lib/messages.ts",
"isEntry": true,
"imports": [
"_index.js",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/messages.ts",
"_Either.js",
"_exports.js",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/messages.ts"
]
},
"web/app/themes/haiku-atelier-2024/src/scripts/lib/reseau.ts": { "web/app/themes/haiku-atelier-2024/src/scripts/lib/reseau.ts": {
"file": "reseau.js", "file": "reseau.js",
"name": "reseau", "name": "reseau",
"src": "web/app/themes/haiku-atelier-2024/src/scripts/lib/reseau.ts", "src": "web/app/themes/haiku-atelier-2024/src/scripts/lib/reseau.ts",
"isEntry": true, "isEntry": true,
"imports": [ "imports": [
"_chunk-7BKSRZNG.js", "web/app/themes/haiku-atelier-2024/src/scripts/constantes/api.ts"
"_index2.js",
"_index.js",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/api.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/erreurs.ts",
"_exports.js"
] ]
}, },
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/cart-add-item.ts": { "web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/cart-add-item.ts": {
@ -158,7 +155,7 @@
] ]
}, },
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/messages.ts": { "web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/messages.ts": {
"file": "messages.js", "file": "messages2.js",
"name": "messages", "name": "messages",
"src": "web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/messages.ts", "src": "web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/messages.ts",
"isEntry": true, "isEntry": true,
@ -186,18 +183,17 @@
"src": "web/app/themes/haiku-atelier-2024/src/scripts/scripts-bouton-panier.ts", "src": "web/app/themes/haiku-atelier-2024/src/scripts/scripts-bouton-panier.ts",
"isEntry": true, "isEntry": true,
"imports": [ "imports": [
"_chunk-RU7WR4KH.js",
"_chunk-VROY5Y5B.js",
"_chunk-7BKSRZNG.js", "_chunk-7BKSRZNG.js",
"_index.js",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/dom.ts", "web/app/themes/haiku-atelier-2024/src/scripts/constantes/dom.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/messages.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/dom.ts", "web/app/themes/haiku-atelier-2024/src/scripts/lib/dom.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/messages.ts", "web/app/themes/haiku-atelier-2024/src/scripts/lib/messages.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/utils.ts", "web/app/themes/haiku-atelier-2024/src/scripts/lib/utils.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts", "web/app/themes/haiku-atelier-2024/src/scripts/lib/erreurs.ts",
"_exports.js", "_exports.js",
"_Either.js", "_Either.js",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/messages.ts" "_index.js",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/messages.ts"
] ]
}, },
"web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-panier.ts": { "web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-panier.ts": {
@ -206,22 +202,24 @@
"src": "web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-panier.ts", "src": "web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-panier.ts",
"isEntry": true, "isEntry": true,
"imports": [ "imports": [
"_chunk-RU7WR4KH.js", "_index2.js",
"_chunk-7BKSRZNG.js", "_chunk-7BKSRZNG.js",
"_index.js", "_index.js",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/api.ts", "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/dom.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/messages.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/dom.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.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/gardes.ts", "web/app/themes/haiku-atelier-2024/src/scripts/lib/gardes.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/messages.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/reseau.ts", "web/app/themes/haiku-atelier-2024/src/scripts/lib/reseau.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/cart-remove-item.ts", "web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/cart-remove-item.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/cart.ts", "web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/cart.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/erreurs.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/utils.ts", "web/app/themes/haiku-atelier-2024/src/scripts/lib/utils.ts",
"_Either.js", "_Either.js",
"_exports.js", "_exports.js",
"_index2.js", "web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/messages.ts"
"web/app/themes/haiku-atelier-2024/src/scripts/lib/schemas/erreurs.ts"
] ]
}, },
"web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-produit.ts": { "web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-produit.ts": {
@ -230,13 +228,12 @@
"src": "web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-produit.ts", "src": "web/app/themes/haiku-atelier-2024/src/scripts/scripts-page-produit.ts",
"isEntry": true, "isEntry": true,
"imports": [ "imports": [
"_chunk-RU7WR4KH.js",
"_chunk-VROY5Y5B.js",
"_chunk-7BKSRZNG.js",
"_index2.js", "_index2.js",
"_chunk-7BKSRZNG.js",
"_index.js", "_index.js",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/api.ts", "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/dom.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/constantes/messages.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/dom.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.ts",
"web/app/themes/haiku-atelier-2024/src/scripts/lib/gardes.ts", "web/app/themes/haiku-atelier-2024/src/scripts/lib/gardes.ts",

View file

@ -1,2 +1,2 @@
import{o as s,a as t,p as o,n as a,b as m,c as r}from"./index.js";const n=s({attribute:r(),value:r()}),i=s({id:t(a()),quantity:t(a()),variation:t(m(n))}),d=e=>o(i,e);export{d as p}; import{o as s,a as t,p as o,n as a,b as m,s as r}from"./index.js";const n=s({attribute:r(),value:r()}),i=s({id:t(a()),quantity:t(a()),variation:t(m(n))}),p=e=>o(i,e);export{p};
//# sourceMappingURL=cart-add-item.js.map //# sourceMappingURL=cart-add-item.js.map

View file

@ -1,2 +1,2 @@
import{o as e,c as o}from"./index.js";const r=e({key:o()});export{r as W}; import{o as e,s as o}from"./index.js";const r=e({key:o()});export{r as W};
//# sourceMappingURL=cart-remove-item.js.map //# sourceMappingURL=cart-remove-item.js.map

View file

@ -1,2 +1,2 @@
import{o as a,c as e,u as i,n,d as s,b as t,e as r,i as o}from"./index.js";a({name:e(),package_id:i([n(),e()])});const m=a({billing_address:s(),coupons:s(),cross_sells:s(),errors:s(),extensions:s(),fees:s(),has_calculated_shipping:s(),items:t(s()),items_count:r(n(),o()),items_weight:s(),needs_payment:s(),needs_shipping:s(),payment_methods:s(),payment_requirements:s(),shipping_address:s(),shipping_rates:s(),totals:s()});export{m as W}; import{o as a,s as e,u as i,n,c as s,b as t,d as r,i as o}from"./index.js";a({name:e(),package_id:i([n(),e()])});const m=a({billing_address:s(),coupons:s(),cross_sells:s(),errors:s(),extensions:s(),fees:s(),has_calculated_shipping:s(),items:t(s()),items_count:r(n(),o()),items_weight:s(),needs_payment:s(),needs_shipping:s(),payment_methods:s(),payment_requirements:s(),shipping_address:s(),shipping_rates:s(),totals:s()});export{m as W};
//# sourceMappingURL=cart.js.map //# sourceMappingURL=cart.js.map

View file

@ -1,2 +0,0 @@
function o(r,t,e){let n=u=>r(u,...t);return e===void 0?n:Object.assign(n,{lazy:e,lazyArgs:t})}function i(r,t,e){let n=r.length-t.length;if(n===0)return r(...t);if(n===1)return o(r,t,e);throw new Error("Wrong number of arguments")}function g(...r){return i(f,r)}function f(r,t){return t(r),r}export{g as r,i as u};
//# sourceMappingURL=chunk-RU7WR4KH.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"chunk-RU7WR4KH.js","sources":["../../../../../../node_modules/.pnpm/remeda@2.14.0/node_modules/remeda/dist/chunk-K26VP6CL.js","../../../../../../node_modules/.pnpm/remeda@2.14.0/node_modules/remeda/dist/chunk-RAAYCPUM.js","../../../../../../node_modules/.pnpm/remeda@2.14.0/node_modules/remeda/dist/chunk-RU7WR4KH.js"],"sourcesContent":["function u(t,n,a){let o=r=>t(r,...n);return a===void 0?o:Object.assign(o,{lazy:a,lazyArgs:n})}export{u as a};\n","import{a as t}from\"./chunk-K26VP6CL.js\";function u(r,n,a){let o=r.length-n.length;if(o===0)return r(...n);if(o===1)return t(r,n,a);throw new Error(\"Wrong number of arguments\")}export{u as a};\n","import{a as t}from\"./chunk-RAAYCPUM.js\";function r(...n){return t(e,n)}function e(n,o){return o(n),n}export{r as a};\n"],"names":["u","t","n","a","o","r","e"],"mappings":"AAAA,SAASA,EAAEC,EAAEC,EAAEC,EAAE,CAAC,IAAIC,EAAEC,GAAGJ,EAAEI,EAAE,GAAGH,CAAC,EAAE,OAAOC,IAAI,OAAOC,EAAE,OAAO,OAAOA,EAAE,CAAC,KAAKD,EAAE,SAASD,CAAC,CAAC,CAAC,CCArD,SAASF,EAAE,EAAEE,EAAEC,EAAE,CAAC,IAAIC,EAAE,EAAE,OAAOF,EAAE,OAAO,GAAGE,IAAI,EAAE,OAAO,EAAE,GAAGF,CAAC,EAAE,GAAGE,IAAI,EAAE,OAAOH,EAAE,EAAEC,EAAEC,CAAC,EAAE,MAAM,IAAI,MAAM,2BAA2B,CAAC,CCAvI,SAASE,KAAKH,EAAE,CAAC,OAAOD,EAAEK,EAAEJ,CAAC,CAAC,CAAC,SAASI,EAAEJ,EAAEE,EAAE,CAAC,OAAOA,EAAEF,CAAC,EAAEA,CAAC","x_google_ignoreList":[0,1,2]}

View file

@ -1,2 +0,0 @@
import{u as o}from"./chunk-RU7WR4KH.js";function u(...r){return o(n,r)}var n=(r,t)=>r[t];export{u as p};
//# sourceMappingURL=chunk-VROY5Y5B.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"chunk-VROY5Y5B.js","sources":["../../../../../../node_modules/.pnpm/remeda@2.14.0/node_modules/remeda/dist/chunk-VROY5Y5B.js"],"sourcesContent":["import{a as n}from\"./chunk-RAAYCPUM.js\";function p(...o){return n(t,o)}var t=(o,e)=>o[e];export{p as a,t as b};\n"],"names":["p","o","n","t","e"],"mappings":"wCAAwC,SAASA,KAAKC,EAAE,CAAC,OAAOC,EAAEC,EAAEF,CAAC,CAAC,CAAC,IAAIE,EAAE,CAACF,EAAEG,IAAIH,EAAEG,CAAC","x_google_ignoreList":[0]}

View file

@ -1,2 +1,2 @@
const E="aria-selected",T="hidden",a="data-contient-articles",t="disabled",s="data-cle-panier",_=".compte-panier a[rel='cart']",o="#selecteur-variation",e="#bouton-ajout-panier",n="a[role='tab']",c="section[role='tabpanel']",R="article",S="button.detail-produit__actions__suppression";export{a as A,_ as S,R as a,s as b,S as c,e as d,o as e,n as f,c as g,E as h,T as i,t as j}; const E="aria-selected",T="hidden",a="data-contient-articles",s="disabled",t="data-cle-panier",_="#page-panier",e=".compte-panier a[rel='cart']",n="#selecteur-variation",o="#bouton-ajout-panier",R="a[role='tab']",c="section[role='tabpanel']",N="article",S="button.detail-produit__actions__suppression";export{a as A,e as S,N as a,_ as b,t as c,S as d,o as e,n as f,R as g,c as h,E as i,T as j,s as k};
//# sourceMappingURL=dom.js.map //# sourceMappingURL=dom.js.map

View file

@ -1 +1 @@
{"version":3,"file":"dom.js","sources":["../../src/scripts/constantes/dom.ts"],"sourcesContent":["/** Constantes de valeurs pour la manipulation du DOM : sélecteurs et attributs. */\n\nexport const ATTRIBUT_ARIA_SELECTED = \"aria-selected\";\nexport const ATTRIBUT_ARIA_HIDDEN = \"aria-hidden\";\nexport const ATTRIBUT_HIDDEN = \"hidden\";\nexport const ATTRIBUT_CONTIENT_ARTICLES = \"data-contient-articles\";\nexport const ATTRIBUT_DESACTIVE = \"disabled\";\nexport const ATTRIBUT_CLE_PANIER = \"data-cle-panier\";\n\nexport const SELECTEUR_BOUTON_PANIER = \".compte-panier a[rel='cart']\";\nexport const SELECTEUR_SELECTEUR_QUANTITE = \"#selecteur-variation\";\nexport const SELECTEUR_BOUTON_AJOUT_PANIER = \"#bouton-ajout-panier\";\nexport const SELECTEUR_LIENS_ONGLETS = \"a[role='tab']\";\nexport const SELECTEUR_SECTIONS_CONTENUS = \"section[role='tabpanel']\";\n\n// Panier\nexport const SELECTEUR_ENTREES_PANIER = \"article\";\nexport const SELECTEUR_BOUTON_SUPPRESSION_PANIER = \"button.detail-produit__actions__suppression\";\n"],"names":["ATTRIBUT_ARIA_SELECTED","ATTRIBUT_HIDDEN","ATTRIBUT_CONTIENT_ARTICLES","ATTRIBUT_DESACTIVE","ATTRIBUT_CLE_PANIER","SELECTEUR_BOUTON_PANIER","SELECTEUR_SELECTEUR_QUANTITE","SELECTEUR_BOUTON_AJOUT_PANIER","SELECTEUR_LIENS_ONGLETS","SELECTEUR_SECTIONS_CONTENUS","SELECTEUR_ENTREES_PANIER","SELECTEUR_BOUTON_SUPPRESSION_PANIER"],"mappings":"AAEO,MAAMA,EAAyB,gBAEzBC,EAAkB,SAClBC,EAA6B,yBAC7BC,EAAqB,WACrBC,EAAsB,kBAEtBC,EAA0B,+BAC1BC,EAA+B,uBAC/BC,EAAgC,uBAChCC,EAA0B,gBAC1BC,EAA8B,2BAG9BC,EAA2B,UAC3BC,EAAsC"} {"version":3,"file":"dom.js","sources":["../../src/scripts/constantes/dom.ts"],"sourcesContent":["/** Constantes de valeurs pour la manipulation du DOM : sélecteurs et attributs. */\n\nexport const ATTRIBUT_ARIA_SELECTED = \"aria-selected\";\nexport const ATTRIBUT_ARIA_HIDDEN = \"aria-hidden\";\nexport const ATTRIBUT_HIDDEN = \"hidden\";\nexport const ATTRIBUT_CONTIENT_ARTICLES = \"data-contient-articles\";\nexport const ATTRIBUT_DESACTIVE = \"disabled\";\nexport const ATTRIBUT_CLE_PANIER = \"data-cle-panier\";\n\nexport const SELECTEUR_CONTENEUR_PANIER = \"#page-panier\";\nexport const SELECTEUR_BOUTON_PANIER = \".compte-panier a[rel='cart']\";\nexport const SELECTEUR_SELECTEUR_QUANTITE = \"#selecteur-variation\";\nexport const SELECTEUR_BOUTON_AJOUT_PANIER = \"#bouton-ajout-panier\";\nexport const SELECTEUR_LIENS_ONGLETS = \"a[role='tab']\";\nexport const SELECTEUR_SECTIONS_CONTENUS = \"section[role='tabpanel']\";\n\n// Panier\nexport const SELECTEUR_ENTREES_PANIER = \"article\";\nexport const SELECTEUR_BOUTON_SUPPRESSION_PANIER = \"button.detail-produit__actions__suppression\";\n"],"names":["ATTRIBUT_ARIA_SELECTED","ATTRIBUT_HIDDEN","ATTRIBUT_CONTIENT_ARTICLES","ATTRIBUT_DESACTIVE","ATTRIBUT_CLE_PANIER","SELECTEUR_CONTENEUR_PANIER","SELECTEUR_BOUTON_PANIER","SELECTEUR_SELECTEUR_QUANTITE","SELECTEUR_BOUTON_AJOUT_PANIER","SELECTEUR_LIENS_ONGLETS","SELECTEUR_SECTIONS_CONTENUS","SELECTEUR_ENTREES_PANIER","SELECTEUR_BOUTON_SUPPRESSION_PANIER"],"mappings":"AAEO,MAAMA,EAAyB,gBAEzBC,EAAkB,SAClBC,EAA6B,yBAC7BC,EAAqB,WACrBC,EAAsB,kBAEtBC,EAA6B,eAC7BC,EAA0B,+BAC1BC,EAA+B,uBAC/BC,EAAgC,uBAChCC,EAA0B,gBAC1BC,EAA8B,2BAG9BC,EAA2B,UAC3BC,EAAsC"}

View file

@ -1,2 +1,2 @@
import{f as t,o as s,n as r,c as o}from"./index.js";const c=s({code:o(),data:s({status:r()}),message:o()}),e=s({body:c,status:r()}),n=a=>t(e,a);export{n as i}; import{e as t,o as s,n as r,s as o}from"./index.js";const e=s({code:o(),data:s({status:r()}),message:o()}),c=s({body:e,status:r()}),n=a=>t(c,a);export{n as i};
//# sourceMappingURL=erreurs2.js.map //# sourceMappingURL=erreurs2.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,2 +1,2 @@
import{g as s,o as a,n as o,e as r,v as n,c as i}from"./index.js";import{T as e}from"./messages2.js";s(e);const p=a({donnees:o(),type:r(i(),n(e.MiseAJourPanier))});export{p as M}; import{p as a}from"./index.js";import{r as o}from"./erreurs.js";import{M as i}from"./messages2.js";import{E as s}from"./Either.js";import"./exports.js";import"./messages3.js";const E=r=>s.of(a(i,r.data)).ifLeft(e=>{o(e)});export{E as v};
//# sourceMappingURL=messages.js.map //# sourceMappingURL=messages.js.map

View file

@ -1 +1 @@
{"version":3,"file":"messages.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\";\n\nexport const TypesMessagesSchema = v.enum(TYPES_MESSAGES);\n\nexport const MiseAJourPanierMessageSchema = v.object({\n donnees: v.number(),\n type: v.pipe(v.string(), v.value(TYPES_MESSAGES.MiseAJourPanier)),\n});\n"],"names":["v.enum","TYPES_MESSAGES","MiseAJourPanierMessageSchema","v.object","v.number","v.pipe","v.string","v.value"],"mappings":"qGAQmCA,EAAOC,CAAc,EAE3C,MAAAC,EAA+BC,EAAS,CACnD,QAASC,EAAS,EAClB,KAAMC,EAAOC,EAAE,EAAUC,EAAQN,EAAe,eAAe,CAAC,CAClE,CAAC"} {"version":3,"file":"messages.js","sources":["../../src/scripts/lib/messages.ts"],"sourcesContent":["import { Either } from \"purify-ts\";\nimport { parse, type ValiError } from \"valibot\";\n\nimport type { MiseAJourPanierMessage } from \"./types/messages\";\n\nimport { reporteErreur } from \"./erreurs.ts\";\nimport { MiseAJourPanierMessageSchema } from \"./schemas/messages.ts\";\n\nexport const valideMessageMajPanier = (\n evenementMessage: MessageEvent<unknown>,\n): Either<ValiError<typeof MiseAJourPanierMessageSchema>, MiseAJourPanierMessage> =>\n Either\n .of<ValiError<typeof MiseAJourPanierMessageSchema>, MiseAJourPanierMessage>(\n parse(MiseAJourPanierMessageSchema, evenementMessage.data),\n )\n .ifLeft(erreur => {\n reporteErreur(erreur);\n });\n"],"names":["parse","reporteErreur","MiseAJourPanierMessageSchema","Either","valideMessageMajPanier","evenementMessage","erreur"],"mappings":"AAQa,OAAA,KAAAA,MAAA,aAAA,OAAA,KAAAC,MAAA,eAAA,OAAA,KAAAC,MAAA,iBAAA,OAAA,KAAAC,MAAA,cAAA,MAAA,eAAA,MAAA,iBAAA,MAAAC,EACXC,GAEAF,EACG,GACCH,EAAME,EAA8BG,EAAiB,IAAI,CAC3D,EACC,OAAiBC,GAAA,CAChBL,EAAcK,CAAM,CACtB,CAAC"}

View file

@ -1,2 +1,2 @@
const a={MiseAJourPanier:"maj_panier"};export{a as T}; import{f as s,o as a,n as o,d as r,v as n,s as i}from"./index.js";import{T as e}from"./messages3.js";s(e);const p=a({donnees:o(),type:r(i(),n(e.MiseAJourPanier))});export{p as M};
//# sourceMappingURL=messages2.js.map //# sourceMappingURL=messages2.js.map

View file

@ -1 +1 @@
{"version":3,"file":"messages2.js","sources":["../../src/scripts/constantes/messages.ts"],"sourcesContent":["/**\n * Constantes liées aux Messages passés par BroadcastChannel.\n */\n\nexport const TYPES_MESSAGES = {\n MiseAJourPanier: \"maj_panier\",\n} as const;\n"],"names":["TYPES_MESSAGES"],"mappings":"AAIO,MAAMA,EAAiB,CAC5B,gBAAiB,YACnB"} {"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\";\n\nexport const TypesMessagesSchema = v.enum(TYPES_MESSAGES);\n\nexport const MiseAJourPanierMessageSchema = v.object({\n donnees: v.number(),\n type: v.pipe(v.string(), v.value(TYPES_MESSAGES.MiseAJourPanier)),\n});\n"],"names":["v.enum","TYPES_MESSAGES","MiseAJourPanierMessageSchema","v.object","v.number","v.pipe","v.string","v.value"],"mappings":"qGAQmCA,EAAOC,CAAc,EAE3C,MAAAC,EAA+BC,EAAS,CACnD,QAASC,EAAS,EAClB,KAAMC,EAAOC,EAAE,EAAUC,EAAQN,EAAe,eAAe,CAAC,CAClE,CAAC"}

View file

@ -0,0 +1,2 @@
const a="bouton_panier",n={MiseAJourPanier:"maj_panier"};export{a as N,n as T};
//# sourceMappingURL=messages3.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"messages3.js","sources":["../../src/scripts/constantes/messages.ts"],"sourcesContent":["/**\n * Constantes liées aux Messages passés par BroadcastChannel.\n */\n\nexport const NOM_CANAL_BOUTON_PANIER = \"bouton_panier\";\n\nexport const TYPES_MESSAGES = {\n MiseAJourPanier: \"maj_panier\",\n} as const;\n"],"names":["NOM_CANAL_BOUTON_PANIER","TYPES_MESSAGES"],"mappings":"AAIO,MAAMA,EAA0B,gBAE1BC,EAAiB,CAC5B,gBAAiB,YACnB"}

View file

@ -1,2 +1,2 @@
import{x as a}from"./chunk-7BKSRZNG.js";import{z as i,N as o}from"./index2.js";import{p as n}from"./index.js";import{c as p}from"./api2.js";import{a as c,b as m,c as d,d as l,E as u}from"./erreurs.js";import{i as r}from"./erreurs2.js";import"./exports.js";const y=e=>fetch(e.route,{body:e.corps,credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json",[p]:e.nonce},method:"POST",mode:"same-origin",signal:AbortSignal.timeout(5e3)}),N=(e,s)=>i(e).with({body:o.select(),status:400},r,c).with({body:o.select(),status:401},r,m).with({body:o.select(),status:404},r,d).with(o._,t=>n(s,t)).otherwise(t=>a(t,u,l));export{y as p,N as t}; import{c as e}from"./api2.js";const n=o=>fetch(o.route,{body:o.corps,credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json",[e]:o.nonce},method:"POST",mode:"same-origin",signal:AbortSignal.timeout(5e3)});export{n as p};
//# sourceMappingURL=reseau.js.map //# sourceMappingURL=reseau.js.map

View file

@ -1 +1 @@
{"version":3,"file":"reseau.js","sources":["../../src/scripts/lib/reseau.ts"],"sourcesContent":["import { pipe } from \"remeda\";\nimport { match, P } from \"ts-pattern\";\nimport { type GenericSchema, parse } from \"valibot\";\n\nimport { ENTETE_WC_NONCE } from \"../constantes/api.ts\";\nimport {\n ErreurInconnue,\n leveBadRequestError,\n leveErreur,\n leveNotFoundError,\n leveUnauthorizedError,\n type UnknownError,\n} from \"./erreurs.ts\";\nimport { isWCError } from \"./schemas/erreurs.ts\";\n\ntype ArgumentsPostBackendWC = {\n corps: BodyInit;\n nonce: string;\n route: string;\n};\n\nexport const postBackendWC = (args: ArgumentsPostBackendWC) =>\n fetch(\n args.route,\n {\n body: args.corps,\n credentials: \"same-origin\",\n headers: {\n \"Accept\": \"application/json\",\n \"Content-Type\": \"application/json\",\n [ENTETE_WC_NONCE]: args.nonce,\n },\n method: \"POST\",\n mode: \"same-origin\",\n signal: AbortSignal.timeout(5000),\n },\n );\n\nexport const traiteReponseBackendWCSelonCodesHTTP = (corpsReponse: unknown, schemaReponse: GenericSchema) =>\n match(corpsReponse)\n // Réponses problématiques\n .with({ body: P.select(), status: 400 }, isWCError, leveBadRequestError)\n .with({ body: P.select(), status: 401 }, isWCError, leveUnauthorizedError)\n .with({ body: P.select(), status: 404 }, isWCError, leveNotFoundError)\n // Réponse OK (201)\n .with(P._, corpsOkInconnu => parse(schemaReponse, corpsOkInconnu))\n // Réponses inconnues\n .otherwise(e => pipe(e, ErreurInconnue, leveErreur<UnknownError>));\n"],"names":["x","z","N","parse","ENTETE_WC_NONCE","leveBadRequestError","leveUnauthorizedError","leveNotFoundError","leveErreur","ErreurInconnue","isWCError","postBackendWC","args","traiteReponseBackendWCSelonCodesHTTP","corpsReponse","schemaReponse","match","P","corpsOkInconnu","e","pipe"],"mappings":"AAqBa,OAAA,KAAAA,MAAA,sBAAA,OAAA,KAAAC,EAAA,KAAAC,MAAA,cAAA,OAAA,KAAAC,MAAA,aAAA,OAAA,KAAAC,MAAA,YAAA,OAAA,KAAAC,EAAA,KAAAC,EAAA,KAAAC,EAAA,KAAAC,EAAA,KAAAC,MAAA,eAAA,OAAA,KAAAC,MAAA,gBAAA,MAAA,eAAA,MAAAC,EAAiBC,GAC5B,MACEA,EAAK,MACL,CACE,KAAMA,EAAK,MACX,YAAa,cACb,QAAS,CACP,OAAU,mBACV,eAAgB,mBAChB,CAACR,CAAe,EAAGQ,EAAK,KAC1B,EACA,OAAQ,OACR,KAAM,cACN,OAAQ,YAAY,QAAQ,GAAI,CAClC,CACF,EAEWC,EAAuC,CAACC,EAAuBC,IAC1EC,EAAMF,CAAY,EAEf,KAAK,CAAE,KAAMG,EAAE,OAAO,EAAG,OAAQ,GAAO,EAAAP,EAAWL,CAAmB,EACtE,KAAK,CAAE,KAAMY,EAAE,SAAU,OAAQ,GAAA,EAAOP,EAAWJ,CAAqB,EACxE,KAAK,CAAE,KAAMW,EAAE,OAAA,EAAU,OAAQ,GAAI,EAAGP,EAAWH,CAAiB,EAEpE,KAAKU,EAAE,EAAqBC,GAAAf,EAAMY,EAAeG,CAAc,CAAC,EAEhE,UAAUC,GAAKC,EAAKD,EAAGV,EAAgBD,CAAwB,CAAC"} {"version":3,"file":"reseau.js","sources":["../../src/scripts/lib/reseau.ts"],"sourcesContent":["import { pipe } from \"remeda\";\nimport { match, P } from \"ts-pattern\";\nimport { type GenericSchema, parse } from \"valibot\";\n\nimport { ENTETE_WC_NONCE } from \"../constantes/api.ts\";\nimport {\n ErreurInconnue,\n leveBadRequestError,\n leveErreur,\n leveNotFoundError,\n leveUnauthorizedError,\n type UnknownError,\n} from \"./erreurs.ts\";\nimport { isWCError } from \"./schemas/erreurs.ts\";\n\ntype ArgumentsPostBackendWC = {\n corps: BodyInit;\n nonce: string;\n route: string;\n};\n\nexport const postBackendWC = (args: ArgumentsPostBackendWC) =>\n fetch(\n args.route,\n {\n body: args.corps,\n credentials: \"same-origin\",\n headers: {\n \"Accept\": \"application/json\",\n \"Content-Type\": \"application/json\",\n [ENTETE_WC_NONCE]: args.nonce,\n },\n method: \"POST\",\n mode: \"same-origin\",\n signal: AbortSignal.timeout(5000),\n },\n );\n\nexport const traiteReponseBackendWCSelonCodesHTTP = (corpsReponse: unknown, schemaReponse: GenericSchema) =>\n match(corpsReponse)\n // Réponses problématiques\n .with({ body: P.select(), status: 400 }, isWCError, leveBadRequestError)\n .with({ body: P.select(), status: 401 }, isWCError, leveUnauthorizedError)\n .with({ body: P.select(), status: 404 }, isWCError, leveNotFoundError)\n // Réponse OK (201)\n .with(P._, corpsOkInconnu => parse(schemaReponse, corpsOkInconnu))\n // Réponses inconnues\n .otherwise(e => pipe(e, ErreurInconnue, leveErreur<UnknownError>));\n"],"names":["ENTETE_WC_NONCE","postBackendWC","args"],"mappings":"AAqBa,OAAA,KAAAA,MAAA,YAAA,MAAAC,EAAiBC,GAC5B,MACEA,EAAK,MACL,CACE,KAAMA,EAAK,MACX,YAAa,cACb,QAAS,CACP,OAAU,mBACV,eAAgB,mBAChB,CAACF,CAAe,EAAGE,EAAK,KAC1B,EACA,OAAQ,OACR,KAAM,cACN,OAAQ,YAAY,QAAQ,GAAI,CAClC,CACF"}

View file

@ -1,2 +1,2 @@
import{r as s}from"./chunk-RU7WR4KH.js";import{p as a}from"./chunk-VROY5Y5B.js";import{x as r}from"./chunk-7BKSRZNG.js";import{s as p}from"./index.js";import{S as u,A as c}from"./dom.js";import{r as f}from"./dom2.js";import{M as E}from"./messages.js";import{r as d}from"./utils.js";import"./erreurs.js";import"./exports.js";import"./Either.js";import"./messages2.js";function T(...t){return t.length===2?(n,...o)=>m(n,...t,...o):m(...t)}var m=(t,n,o,...e)=>n(t,...e)?typeof o=="function"?o(t,...e):o.onTrue(t,...e):typeof o=="function"?t:o.onFalse(t,...e);const l=()=>{const t=r(d(u),f),n=new BroadcastChannel("bouton_panier");n.onmessage=o=>{r(p(E,o.data),T(e=>e.success,e=>r(a(e,"output"),s(i=>{t.textContent=`cart (${String(i.donnees)})`,t.setAttribute(c,String(i.donnees>0))}))))}};document.addEventListener("DOMContentLoaded",()=>{l()}); import{x as n}from"./chunk-7BKSRZNG.js";import{S as i,A as m}from"./dom.js";import{N as a}from"./messages3.js";import{r as s}from"./dom2.js";import{v as N}from"./messages.js";import{r as p}from"./utils.js";import"./erreurs.js";import"./exports.js";import"./Either.js";import"./index.js";import"./messages2.js";const E=()=>{const t=n(p(i),s),r=new BroadcastChannel(a);r.onmessage=o=>{N(o).ifRight(e=>{t.textContent=`cart (${String(e.donnees)})`,t.setAttribute(m,String(e.donnees>0))})}};document.addEventListener("DOMContentLoaded",()=>{E()});
//# sourceMappingURL=scripts-bouton-panier.js.map //# sourceMappingURL=scripts-bouton-panier.js.map

View file

@ -1 +1 @@
{"version":3,"file":"scripts-bouton-panier.js","sources":["../../../../../../node_modules/.pnpm/remeda@2.14.0/node_modules/remeda/dist/chunk-NJXNQM3G.js","../../src/scripts/scripts-bouton-panier.ts"],"sourcesContent":["function d(...e){return e.length===2?(n,...r)=>t(n,...e,...r):t(...e)}var t=(e,n,r,...a)=>n(e,...a)?typeof r==\"function\"?r(e,...a):r.onTrue(e,...a):typeof r==\"function\"?e:r.onFalse(e,...a);export{d as a};\n","/**\n * Scripts pour la mise à jour trans-fenêtres/trans-onglets du Bouton du Panier.\n */\n\nimport { identity, pipe, prop, tap, when } from \"remeda\";\nimport { safeParse } from \"valibot\";\n\nimport type { MiseAJourPanierMessage } from \"./lib/types/messages\";\n\nimport { ATTRIBUT_CONTIENT_ARTICLES, SELECTEUR_BOUTON_PANIER } from \"./constantes/dom.ts\";\nimport { recupereElementOuLeve } from \"./lib/dom.ts\";\nimport { MiseAJourPanierMessageSchema } from \"./lib/schemas/messages.ts\";\nimport { recupereElementDocumentEither } from \"./lib/utils.ts\";\n\nconst initialiseBoutonPanier = (): void => {\n /** Le « Bouton » vers le Panier dont le texte est un indicateur du nombre de Produits dedans. */\n const BOUTON_PANIER: HTMLAnchorElement = pipe(\n recupereElementDocumentEither<HTMLAnchorElement>(SELECTEUR_BOUTON_PANIER),\n recupereElementOuLeve,\n );\n\n const canalBoutonPanier: BroadcastChannel = new BroadcastChannel(\"bouton_panier\");\n\n canalBoutonPanier.onmessage = (evenementMessage: MessageEvent<unknown>) => {\n pipe(\n safeParse(MiseAJourPanierMessageSchema, evenementMessage.data),\n when(validation => validation.success, (messageValide) =>\n pipe(\n prop(messageValide, \"output\"),\n tap((message: MiseAJourPanierMessage) => {\n BOUTON_PANIER.textContent = `cart (${String(message.donnees)})`;\n BOUTON_PANIER.setAttribute(ATTRIBUT_CONTIENT_ARTICLES, String(message.donnees > 0));\n }),\n )),\n );\n };\n};\n\ndocument.addEventListener(\"DOMContentLoaded\", () => {\n initialiseBoutonPanier();\n});\n"],"names":["d","e","r","t","a","initialiseBoutonPanier","BOUTON_PANIER","pipe","recupereElementDocumentEither","SELECTEUR_BOUTON_PANIER","recupereElementOuLeve","canalBoutonPanier","evenementMessage","safeParse","MiseAJourPanierMessageSchema","when","validation","messageValide","prop","tap","message","ATTRIBUT_CONTIENT_ARTICLES"],"mappings":"+WAAA,SAASA,KAAKC,EAAE,CAAC,OAAOA,EAAE,SAAS,EAAE,CAAC,KAAKC,IAAIC,EAAE,EAAE,GAAGF,EAAE,GAAGC,CAAC,EAAEC,EAAE,GAAGF,CAAC,CAAC,CAAC,IAAIE,EAAE,CAACF,EAAE,EAAEC,KAAKE,IAAI,EAAEH,EAAE,GAAGG,CAAC,EAAE,OAAOF,GAAG,WAAWA,EAAED,EAAE,GAAGG,CAAC,EAAEF,EAAE,OAAOD,EAAE,GAAGG,CAAC,EAAE,OAAOF,GAAG,WAAWD,EAAEC,EAAE,QAAQD,EAAE,GAAGG,CAAC,ECc3L,MAAMC,EAAyB,IAAY,CAEzC,MAAMC,EAAmCC,EACvCC,EAAiDC,CAAuB,EACxEC,CAAA,EAGIC,EAAsC,IAAI,iBAAiB,eAAe,EAE9DA,EAAA,UAAaC,GAA4C,CACzEL,EACEM,EAAUC,EAA8BF,EAAiB,IAAI,EAC7DG,EAAKC,GAAcA,EAAW,QAAUC,GACtCV,EACEW,EAAKD,EAAe,QAAQ,EAC5BE,EAAKC,GAAoC,CACvCd,EAAc,YAAc,SAAS,OAAOc,EAAQ,OAAO,CAAC,IAC5Dd,EAAc,aAAae,EAA4B,OAAOD,EAAQ,QAAU,CAAC,CAAC,CAAA,CACnF,CAAA,CACF,CAAA,CACL,CAEJ,EAEA,SAAS,iBAAiB,mBAAoB,IAAM,CAC3Bf,GACzB,CAAC","x_google_ignoreList":[0]} {"version":3,"file":"scripts-bouton-panier.js","sources":["../../src/scripts/scripts-bouton-panier.ts"],"sourcesContent":["/**\n * Scripts pour la mise à jour trans-fenêtres/trans-onglets du Bouton du Panier.\n */\n\nimport { pipe } from \"remeda\";\n\nimport type { MiseAJourPanierMessage } from \"./lib/types/messages\";\n\nimport { ATTRIBUT_CONTIENT_ARTICLES, SELECTEUR_BOUTON_PANIER } from \"./constantes/dom.ts\";\nimport { NOM_CANAL_BOUTON_PANIER } from \"./constantes/messages.ts\";\nimport { recupereElementOuLeve } from \"./lib/dom.ts\";\nimport { valideMessageMajPanier } from \"./lib/messages.ts\";\nimport { recupereElementDocumentEither } from \"./lib/utils.ts\";\n\nconst initialiseBoutonPanier = (): void => {\n /** Le « Bouton » vers le Panier dont le texte est un indicateur du nombre de Produits dedans. */\n const BOUTON_PANIER: HTMLAnchorElement = pipe(\n recupereElementDocumentEither<HTMLAnchorElement>(SELECTEUR_BOUTON_PANIER),\n recupereElementOuLeve,\n );\n const CANAL_BOUTON_PANIER: BroadcastChannel = new BroadcastChannel(NOM_CANAL_BOUTON_PANIER);\n\n CANAL_BOUTON_PANIER.onmessage = (evenementMessage: MessageEvent<unknown>): void => {\n valideMessageMajPanier(evenementMessage)\n // Met à jour le Bouton du Panier\n .ifRight((message: MiseAJourPanierMessage) => {\n BOUTON_PANIER.textContent = `cart (${String(message.donnees)})`;\n BOUTON_PANIER.setAttribute(ATTRIBUT_CONTIENT_ARTICLES, String(message.donnees > 0));\n });\n };\n};\n\ndocument.addEventListener(\"DOMContentLoaded\", () => {\n initialiseBoutonPanier();\n});\n"],"names":["initialiseBoutonPanier","BOUTON_PANIER","pipe","recupereElementDocumentEither","SELECTEUR_BOUTON_PANIER","recupereElementOuLeve","CANAL_BOUTON_PANIER","NOM_CANAL_BOUTON_PANIER","evenementMessage","valideMessageMajPanier","message","ATTRIBUT_CONTIENT_ARTICLES"],"mappings":"sTAcA,MAAMA,EAAyB,IAAY,CAEzC,MAAMC,EAAmCC,EACvCC,EAAiDC,CAAuB,EACxEC,CAAA,EAEIC,EAAwC,IAAI,iBAAiBC,CAAuB,EAEtED,EAAA,UAAaE,GAAkD,CACjFC,EAAuBD,CAAgB,EAEpC,QAASE,GAAoC,CAC5CT,EAAc,YAAc,SAAS,OAAOS,EAAQ,OAAO,CAAC,IAC5DT,EAAc,aAAaU,EAA4B,OAAOD,EAAQ,QAAU,CAAC,CAAC,CAAA,CACnF,CAAA,CAEP,EAEA,SAAS,iBAAiB,mBAAoB,IAAM,CAC3BV,GACzB,CAAC"}

View file

@ -1,2 +1,2 @@
import{r as E}from"./chunk-RU7WR4KH.js";import{x as t}from"./chunk-7BKSRZNG.js";import{p}from"./index.js";import{R as f}from"./api2.js";import{a as l,b as R,c as C}from"./dom.js";import{a as S,b as u}from"./dom2.js";import{r as n,D as T,l as A}from"./erreurs.js";import{e as N,a as _}from"./gardes.js";import{p as I,t as P}from"./reseau.js";import{W as d}from"./cart-remove-item.js";import{W as L}from"./cart.js";import{a as v}from"./utils.js";import{M as h,E as b}from"./Either.js";import"./exports.js";import"./index2.js";import"./erreurs2.js";const m=_etats,g=t(v(l),S),O=()=>{console.debug(m),g.forEach(r=>{const s=h.fromNullable(r.getAttribute(R));u(r)(C).ifLeft(()=>t(new T(`L'entrée « ${s.orDefault("CLE_PANIER_INEXISTANTE")} » n'a pas de Bouton de suppression.`),n)).ifRight(a=>{a.addEventListener("click",()=>{const i=s.ifNothing(()=>{r.remove()}).orDefault("CLE_PANIER_INEXISTANTE");a.textContent="C= C= C= C= C=┌(;・ω・)┘",b.encase(()=>p(d,{key:i})).map(c=>{I({corps:JSON.stringify(c),nonce:m.nonce,route:f}).then(async e=>{N(e)&&A("500 Server Error"),t(await e.json(),E(o=>console.debug(o)),o=>P(o,L),E(()=>r.remove()))}).catch(e=>{_(e)?(n(e),console.error(e)):console.error("e n'est pas une Erreur ?!",e)})})})})})};document.addEventListener("DOMContentLoaded",()=>{O()}); import{r as _,p as R,z as u,N as E}from"./index2.js";import{x as t}from"./chunk-7BKSRZNG.js";import{p as m}from"./index.js";import{R as l}from"./api2.js";import{a as T,b as C,c as f,d as I,A as S}from"./dom.js";import{N,T as P}from"./messages3.js";import{a as d,r as O,b as h}from"./dom2.js";import{r as c,D as L,l as v,a as U,b as g,c as B,E as b,d as M}from"./erreurs.js";import{e as w,a as y}from"./gardes.js";import{v as D}from"./messages.js";import{p as W}from"./reseau.js";import{W as k}from"./cart-remove-item.js";import{W as j}from"./cart.js";import{i}from"./erreurs2.js";import{a as x,r as z}from"./utils.js";import{M as G,E as J}from"./Either.js";import"./exports.js";import"./messages2.js";const X=_etats,q=t(x(T),d),F=t(z(C),O),Y=()=>{q.forEach(r=>{const o=G.fromNullable(r.getAttribute(f));h(r)(I).ifLeft(()=>t(new L(`L'entrée « ${o.orDefault("CLE_PANIER_INEXISTANTE")} » n'a pas de Bouton de suppression.`),c)).ifRight(s=>{s.addEventListener("click",()=>{const p=o.ifNothing(()=>{r.remove()}).orDefault("CLE_PANIER_INEXISTANTE");s.textContent="C= C= C= C= C=┌(;・ω・)┘",J.encase(()=>m(k,{key:p})).map(A=>{W({corps:JSON.stringify(A),nonce:X.nonce,route:l}).then(async e=>{w(e)&&v("500 Server Error"),t(await e.json(),n=>u(n).with({body:E.select(),status:400},i,U).with({body:E.select(),status:401},i,g).with({body:E.select(),status:404},i,B).with(E._,a=>m(j,a)).otherwise(a=>t(a,b,M)),R("items_count"),_(n=>{new BroadcastChannel(N).postMessage({donnees:n,type:P.MiseAJourPanier}),r.remove()}))}).catch(e=>{y(e)?(c(e),console.error(e)):console.error("e n'est pas une Erreur ?!",e)})})})})})},$=()=>{const r=new BroadcastChannel(N);r.onmessage=o=>{D(o).ifRight(s=>{F.setAttribute(S,String(s.donnees!==0))})}};document.addEventListener("DOMContentLoaded",()=>{Y(),$()});
//# sourceMappingURL=scripts-page-panier.js.map //# sourceMappingURL=scripts-page-panier.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,2 +1,2 @@
import{r as p}from"./chunk-RU7WR4KH.js";import{p as l}from"./chunk-VROY5Y5B.js";import{x as o}from"./chunk-7BKSRZNG.js";import{z as N,N as i}from"./index2.js";import{p as O}from"./index.js";import{b as g,c as h}from"./api2.js";import{S as I,d as L,e as v,f as U,g as b,h as m,i as T,j as A}from"./dom.js";import{r as u,a as f}from"./dom2.js";import{l as R,a as w,b as y,c as P,E as B,d as D,r as j}from"./erreurs.js";import{b as M,e as x,a as J}from"./gardes.js";import{p as W}from"./cart-add-item.js";import{W as G}from"./cart.js";import{i as c}from"./erreurs2.js";import{r as d,a as _}from"./utils.js";import{M as k,E as q}from"./Either.js";import"./exports.js";const z=_etats,H=n=>{n.forEach(t=>{t[0].setAttribute(m,"false"),t[1].setAttribute(T,"true")})};o(d(I),u);const a=o(d(L),u),E=o(d(v),u),V=o(_(U),f),F=o(_(b),f),Q=()=>{const n=new Map;V.forEach((t,e)=>{const r=t.getAttribute("id"),s=F[e];if(!r)throw new Error("Le lien ne dispose pas d'ID !");if(!s)throw new Error("Le lien ne dispose pas de section correspondante !");n.set(r,[t,s]),t.addEventListener("click",S=>{S.preventDefault();const C=t.getAttribute(m)==="true";H(o(n.values(),Array.from)),!C&&(t.setAttribute(m,"true"),s.removeAttribute(T))})}),E.addEventListener("change",t=>{o(t.target,k.fromNullable,e=>e.filter(M),e=>e.map(r=>r.validity.valid),e=>e.ifJust(r=>a.toggleAttribute(A,!r)))}),a.addEventListener("click",t=>K())},K=()=>{a.textContent="Adding...";const n=new BroadcastChannel("bouton_panier");q.encase(()=>W({id:Number(E.value),quantity:1})).map(t=>{fetch(g,{body:JSON.stringify(t),credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json",[h]:z.nonce},method:"POST",mode:"same-origin",signal:AbortSignal.timeout(5e3)}).then(async e=>{x(e)&&R("500 Server Error"),o(await e.json(),r=>N(r).with({body:i.select(),status:400},c,w).with({body:i.select(),status:401},c,y).with({body:i.select(),status:404},c,P).with(i._,s=>O(G,s)).otherwise(s=>o(s,B,D)),p(r=>console.debug("Panier",r)),l("items"),l("length"),p(r=>{a.textContent="Added to cart!",n.postMessage({donnees:r,type:"maj_panier"}),setTimeout(()=>{E.value=E.options.item(0)?.value??"--",a.toggleAttribute(A,!0),a.textContent="Add to cart"},3e3)}))}).catch(e=>{J(e)?(j(e),console.error(e)):console.error("e n'est pas une Erreur ?!",e),a.textContent="Add to cart"})})};document.addEventListener("DOMContentLoaded",()=>{Q()}); import{r as A,p as C,z as O,N as n}from"./index2.js";import{x as o}from"./chunk-7BKSRZNG.js";import{p as f}from"./index.js";import{b as I,c as L}from"./api2.js";import{S as U,e as R,f as g,g as h,h as v,i as u,j as T,k as p}from"./dom.js";import{N as b,T as P}from"./messages3.js";import{r as m,a as l}from"./dom2.js";import{l as w,a as y,b as B,c as D,E as M,d as J,r as j}from"./erreurs.js";import{b as x,e as W,a as G}from"./gardes.js";import{p as k}from"./cart-add-item.js";import{W as q}from"./cart.js";import{i as c}from"./erreurs2.js";import{r as d,a as N}from"./utils.js";import{M as z,E as H}from"./Either.js";import"./exports.js";const V=_etats,F=a=>{a.forEach(e=>{e[0].setAttribute(u,"false"),e[1].setAttribute(T,"true")})};o(d(U),m);const s=o(d(R),m),i=o(d(g),m),Q=o(N(h),l),Y=o(N(v),l),K=()=>{const a=new Map;Q.forEach((e,t)=>{const r=e.getAttribute("id"),E=Y[t];if(!r)throw new Error("Le lien ne dispose pas d'ID !");if(!E)throw new Error("Le lien ne dispose pas de section correspondante !");a.set(r,[e,E]),e.addEventListener("click",_=>{_.preventDefault();const S=e.getAttribute(u)==="true";F(o(a.values(),Array.from)),!S&&(e.setAttribute(u,"true"),E.removeAttribute(T))})}),i.addEventListener("change",e=>{o(e.target,z.fromNullable,t=>t.filter(x),t=>t.map(r=>r.validity.valid),t=>t.ifJust(r=>s.toggleAttribute(p,!r)))}),s.addEventListener("click",e=>X())},X=()=>{s.textContent="Adding...",H.encase(()=>k({id:Number(i.value),quantity:1})).map(a=>{fetch(I,{body:JSON.stringify(a),credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json",[L]:V.nonce},method:"POST",mode:"same-origin",signal:AbortSignal.timeout(5e3)}).then(async e=>{W(e)&&w("500 Server Error"),o(await e.json(),t=>O(t).with({body:n.select(),status:400},c,y).with({body:n.select(),status:401},c,B).with({body:n.select(),status:404},c,D).with(n._,r=>f(q,r)).otherwise(r=>o(r,M,J)),A(t=>console.debug("Panier",t)),C("items_count"),A(t=>{s.textContent="Added to cart!",new BroadcastChannel(b).postMessage({donnees:t,type:P.MiseAJourPanier}),setTimeout(()=>{i.value=i.options.item(0)?.value??"--",s.toggleAttribute(p,!0),s.textContent="Add to cart"},3e3)}))}).catch(e=>{G(e)?(j(e),console.error(e)):console.error("e n'est pas une Erreur ?!",e),s.textContent="Add to cart"})})};document.addEventListener("DOMContentLoaded",()=>{K()});
//# sourceMappingURL=scripts-page-produit.js.map //# sourceMappingURL=scripts-page-produit.js.map

File diff suppressed because one or more lines are too long

View file

@ -19,6 +19,7 @@ $modeles = ["panier.twig"];
$panier = []; $panier = [];
$sous_total_panier = WC()->cart->get_subtotal(); $sous_total_panier = WC()->cart->get_subtotal();
$total_panier = WC()->cart->get_total(""); $total_panier = WC()->cart->get_total("");
foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) { foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
$panier[$cart_item_key] = [ $panier[$cart_item_key] = [
"attributs" => recupere_et_formate_attributs_produit($cart_item["data"]?->get_attributes()), "attributs" => recupere_et_formate_attributs_produit($cart_item["data"]?->get_attributes()),

View file

@ -11,6 +11,9 @@ use function Crell\fp\pipe;
/** /**
* Récupère les informations utilisées pour la grille des Produits et les retourne sous forme * Récupère les informations utilisées pour la grille des Produits et les retourne sous forme
* de tableau associatif. * de tableau associatif.
*
* @param WC_Product $produit
* @return InformationsProduitShop Un tableau avec uniquement les informations pour la Grille de Produits.
*/ */
function recupere_informations_produit_shop($produit) { function recupere_informations_produit_shop($produit) {
return [ return [

View file

@ -7,6 +7,7 @@ export const ATTRIBUT_CONTIENT_ARTICLES = "data-contient-articles";
export const ATTRIBUT_DESACTIVE = "disabled"; export const ATTRIBUT_DESACTIVE = "disabled";
export const ATTRIBUT_CLE_PANIER = "data-cle-panier"; export const ATTRIBUT_CLE_PANIER = "data-cle-panier";
export const SELECTEUR_CONTENEUR_PANIER = "#page-panier";
export const SELECTEUR_BOUTON_PANIER = ".compte-panier a[rel='cart']"; export const SELECTEUR_BOUTON_PANIER = ".compte-panier a[rel='cart']";
export const SELECTEUR_SELECTEUR_QUANTITE = "#selecteur-variation"; export const SELECTEUR_SELECTEUR_QUANTITE = "#selecteur-variation";
export const SELECTEUR_BOUTON_AJOUT_PANIER = "#bouton-ajout-panier"; export const SELECTEUR_BOUTON_AJOUT_PANIER = "#bouton-ajout-panier";

View file

@ -2,6 +2,8 @@
* Constantes liées aux Messages passés par BroadcastChannel. * Constantes liées aux Messages passés par BroadcastChannel.
*/ */
export const NOM_CANAL_BOUTON_PANIER = "bouton_panier";
export const TYPES_MESSAGES = { export const TYPES_MESSAGES = {
MiseAJourPanier: "maj_panier", MiseAJourPanier: "maj_panier",
} as const; } as const;

View file

@ -0,0 +1,18 @@
import { Either } from "purify-ts";
import { parse, type ValiError } from "valibot";
import type { MiseAJourPanierMessage } from "./types/messages";
import { reporteErreur } from "./erreurs.ts";
import { MiseAJourPanierMessageSchema } from "./schemas/messages.ts";
export const valideMessageMajPanier = (
evenementMessage: MessageEvent<unknown>,
): Either<ValiError<typeof MiseAJourPanierMessageSchema>, MiseAJourPanierMessage> =>
Either
.of<ValiError<typeof MiseAJourPanierMessageSchema>, MiseAJourPanierMessage>(
parse(MiseAJourPanierMessageSchema, evenementMessage.data),
)
.ifLeft(erreur => {
reporteErreur(erreur);
});

View file

@ -2,14 +2,14 @@
* Scripts pour la mise à jour trans-fenêtres/trans-onglets du Bouton du Panier. * Scripts pour la mise à jour trans-fenêtres/trans-onglets du Bouton du Panier.
*/ */
import { identity, pipe, prop, tap, when } from "remeda"; import { pipe } from "remeda";
import { safeParse } from "valibot";
import type { MiseAJourPanierMessage } from "./lib/types/messages"; import type { MiseAJourPanierMessage } from "./lib/types/messages";
import { ATTRIBUT_CONTIENT_ARTICLES, SELECTEUR_BOUTON_PANIER } from "./constantes/dom.ts"; import { ATTRIBUT_CONTIENT_ARTICLES, SELECTEUR_BOUTON_PANIER } from "./constantes/dom.ts";
import { NOM_CANAL_BOUTON_PANIER } from "./constantes/messages.ts";
import { recupereElementOuLeve } from "./lib/dom.ts"; import { recupereElementOuLeve } from "./lib/dom.ts";
import { MiseAJourPanierMessageSchema } from "./lib/schemas/messages.ts"; import { valideMessageMajPanier } from "./lib/messages.ts";
import { recupereElementDocumentEither } from "./lib/utils.ts"; import { recupereElementDocumentEither } from "./lib/utils.ts";
const initialiseBoutonPanier = (): void => { const initialiseBoutonPanier = (): void => {
@ -18,21 +18,15 @@ const initialiseBoutonPanier = (): void => {
recupereElementDocumentEither<HTMLAnchorElement>(SELECTEUR_BOUTON_PANIER), recupereElementDocumentEither<HTMLAnchorElement>(SELECTEUR_BOUTON_PANIER),
recupereElementOuLeve, recupereElementOuLeve,
); );
const CANAL_BOUTON_PANIER: BroadcastChannel = new BroadcastChannel(NOM_CANAL_BOUTON_PANIER);
const canalBoutonPanier: BroadcastChannel = new BroadcastChannel("bouton_panier"); CANAL_BOUTON_PANIER.onmessage = (evenementMessage: MessageEvent<unknown>): void => {
valideMessageMajPanier(evenementMessage)
canalBoutonPanier.onmessage = (evenementMessage: MessageEvent<unknown>) => { // Met à jour le Bouton du Panier
pipe( .ifRight((message: MiseAJourPanierMessage) => {
safeParse(MiseAJourPanierMessageSchema, evenementMessage.data), BOUTON_PANIER.textContent = `cart (${String(message.donnees)})`;
when(validation => validation.success, (messageValide) => BOUTON_PANIER.setAttribute(ATTRIBUT_CONTIENT_ARTICLES, String(message.donnees > 0));
pipe( });
prop(messageValide, "output"),
tap((message: MiseAJourPanierMessage) => {
BOUTON_PANIER.textContent = `cart (${String(message.donnees)})`;
BOUTON_PANIER.setAttribute(ATTRIBUT_CONTIENT_ARTICLES, String(message.donnees > 0));
}),
)),
);
}; };
}; };

View file

@ -1,22 +1,39 @@
import { Either, Maybe } from "purify-ts"; import { Either, Maybe } from "purify-ts";
import { pipe, tap } from "remeda"; import { pipe, prop, tap } from "remeda";
import { match, P } from "ts-pattern";
import { parse } from "valibot"; import { parse } from "valibot";
import type { WCStoreCartRemoveItemArgs } from "./lib/types/api/cart-remove-item"; import type { WCStoreCartRemoveItemArgs } from "./lib/types/api/cart-remove-item";
import type { MiseAJourPanierMessage } from "./lib/types/messages";
import { ROUTE_API_RETIRE_ARTICLE_PANIER } from "./constantes/api.ts"; import { ROUTE_API_RETIRE_ARTICLE_PANIER } from "./constantes/api.ts";
import { import {
ATTRIBUT_CLE_PANIER, ATTRIBUT_CLE_PANIER,
ATTRIBUT_CONTIENT_ARTICLES,
SELECTEUR_BOUTON_SUPPRESSION_PANIER, SELECTEUR_BOUTON_SUPPRESSION_PANIER,
SELECTEUR_CONTENEUR_PANIER,
SELECTEUR_ENTREES_PANIER, SELECTEUR_ENTREES_PANIER,
} from "./constantes/dom.ts"; } from "./constantes/dom.ts";
import { recupereElementAvecSelecteur, recupereElementsOuLeve } from "./lib/dom.ts"; import { NOM_CANAL_BOUTON_PANIER, TYPES_MESSAGES } from "./constantes/messages.ts";
import { DOMElementAbsentError, leveServerError, reporteErreur } from "./lib/erreurs.ts"; import { recupereElementAvecSelecteur, recupereElementOuLeve, recupereElementsOuLeve } from "./lib/dom.ts";
import {
DOMElementAbsentError,
ErreurInconnue,
leveBadRequestError,
leveErreur,
leveNotFoundError,
leveServerError,
leveUnauthorizedError,
reporteErreur,
type UnknownError,
} from "./lib/erreurs.ts";
import { estError, estReponse500 } from "./lib/gardes.ts"; import { estError, estReponse500 } from "./lib/gardes.ts";
import { postBackendWC, traiteReponseBackendWCSelonCodesHTTP } from "./lib/reseau.ts"; import { valideMessageMajPanier } from "./lib/messages.ts";
import { postBackendWC } from "./lib/reseau.ts";
import { WCStoreCartRemoveItemArgsSchema } from "./lib/schemas/cart-remove-item.ts"; import { WCStoreCartRemoveItemArgsSchema } from "./lib/schemas/cart-remove-item.ts";
import { WCStoreCartSchema } from "./lib/schemas/cart.ts"; import { WCStoreCartSchema } from "./lib/schemas/cart.ts";
import { recupereElementsDocumentEither } from "./lib/utils.ts"; import { isWCError } from "./lib/schemas/erreurs.ts";
import { recupereElementDocumentEither, recupereElementsDocumentEither } from "./lib/utils.ts";
/** /**
* Récupère les <article> dans le panier * Récupère les <article> dans le panier
@ -51,10 +68,12 @@ const ENTREES_PANIER: Array<HTMLElement> = pipe(
recupereElementsDocumentEither<HTMLElement>(SELECTEUR_ENTREES_PANIER), recupereElementsDocumentEither<HTMLElement>(SELECTEUR_ENTREES_PANIER),
recupereElementsOuLeve, recupereElementsOuLeve,
); );
const CONTENEUR_PANIER: HTMLElement = pipe(
recupereElementDocumentEither<HTMLElement>(SELECTEUR_CONTENEUR_PANIER),
recupereElementOuLeve,
);
const initialiseScriptsPagePanier = (): void => { const initialiseScriptsPagePanier = (): void => {
console.debug(ETATS_PAGE);
ENTREES_PANIER.forEach((entree: HTMLElement) => { ENTREES_PANIER.forEach((entree: HTMLElement) => {
const maybeClePanier: Maybe<string> = Maybe.fromNullable(entree.getAttribute(ATTRIBUT_CLE_PANIER)); const maybeClePanier: Maybe<string> = Maybe.fromNullable(entree.getAttribute(ATTRIBUT_CLE_PANIER));
@ -99,12 +118,28 @@ const initialiseScriptsPagePanier = (): void => {
pipe( pipe(
// Récupère la Réponse // Récupère la Réponse
await reponse.json(), await reponse.json(),
tap((a) => console.debug(a)),
// Traite tous les codes HTTPs possibles // Traite tous les codes HTTPs possibles
(corpsReponse: unknown) => traiteReponseBackendWCSelonCodesHTTP(corpsReponse, WCStoreCartSchema), (corpsReponse: unknown) =>
// TODO: Mettre à jour la quantité dans le bouton Panier match(corpsReponse)
// Retire l'entrée du Panier du DOM // Réponses problématiques
tap(() => entree.remove()), .with({ body: P.select(), status: 400 }, isWCError, leveBadRequestError)
.with({ body: P.select(), status: 401 }, isWCError, leveUnauthorizedError)
.with({ body: P.select(), status: 404 }, isWCError, leveNotFoundError)
// Réponse OK (201)
.with(P._, corpsOkInconnu => parse(WCStoreCartSchema, corpsOkInconnu))
// Réponses inconnues
.otherwise(e => pipe(e, ErreurInconnue, leveErreur<UnknownError>)),
prop("items_count"),
tap((nombreArticlesPanier: number) => {
// Émet un Message avec le nouveau nombre de Produits dans le Panier
const CANAL_BOUTON_PANIER: BroadcastChannel = new BroadcastChannel(NOM_CANAL_BOUTON_PANIER);
CANAL_BOUTON_PANIER.postMessage({
donnees: nombreArticlesPanier,
type: TYPES_MESSAGES.MiseAJourPanier,
});
// Retire l'entrée du Panier du DOM
entree.remove();
}),
); );
}) })
.catch((e: unknown) => { .catch((e: unknown) => {
@ -122,6 +157,18 @@ const initialiseScriptsPagePanier = (): void => {
}); });
}; };
const initialisePagePanier = (): void => {
const CANAL_BOUTON_PANIER: BroadcastChannel = new BroadcastChannel(NOM_CANAL_BOUTON_PANIER);
CANAL_BOUTON_PANIER.onmessage = (evenementMessage: MessageEvent<unknown>): void => {
valideMessageMajPanier(evenementMessage)
// Met à jour le Bouton du Panier
.ifRight((message: MiseAJourPanierMessage) => {
CONTENEUR_PANIER.setAttribute(ATTRIBUT_CONTIENT_ARTICLES, String(message.donnees !== 0));
});
};
};
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
initialiseScriptsPagePanier(); initialiseScriptsPagePanier();
initialisePagePanier();
}); });

View file

@ -19,6 +19,7 @@ import {
SELECTEUR_SECTIONS_CONTENUS, SELECTEUR_SECTIONS_CONTENUS,
SELECTEUR_SELECTEUR_QUANTITE, SELECTEUR_SELECTEUR_QUANTITE,
} from "./constantes/dom"; } from "./constantes/dom";
import { NOM_CANAL_BOUTON_PANIER, TYPES_MESSAGES } from "./constantes/messages.ts";
import { recupereElementOuLeve, recupereElementsOuLeve } from "./lib/dom.ts"; import { recupereElementOuLeve, recupereElementsOuLeve } from "./lib/dom.ts";
import { import {
ErreurInconnue, ErreurInconnue,
@ -148,9 +149,6 @@ const ajouteProduitAuPanier = () => {
/* État de chargement */ /* État de chargement */
BOUTON_AJOUT_PANIER.textContent = "Adding..."; BOUTON_AJOUT_PANIER.textContent = "Adding...";
// Initialise le BroadcastChanel du Bouton du Panier
const canalBoutonPanier: BroadcastChannel = new BroadcastChannel("bouton_panier");
// TODO: Rendre ça moins long // TODO: Rendre ça moins long
// TODO: Créer une méthode pour fetch() // TODO: Créer une méthode pour fetch()
// TODO: Créer une méthode pour traiter les codes HTTP // TODO: Créer une méthode pour traiter les codes HTTP
@ -198,8 +196,7 @@ const ajouteProduitAuPanier = () => {
.otherwise(e => pipe(e, ErreurInconnue, leveErreur<UnknownError>)), .otherwise(e => pipe(e, ErreurInconnue, leveErreur<UnknownError>)),
tap((panier: WCStoreCart) => console.debug("Panier", panier)), tap((panier: WCStoreCart) => console.debug("Panier", panier)),
// Récupère le nombre de Produits dans la Panier // Récupère le nombre de Produits dans la Panier
prop("items"), prop("items_count"),
prop("length"),
// Déclenche les effets pour la mise à jour de l'IU // Déclenche les effets pour la mise à jour de l'IU
tap((nombreArticlesPanier: number) => { tap((nombreArticlesPanier: number) => {
/** /**
@ -208,12 +205,9 @@ const ajouteProduitAuPanier = () => {
* 2. Met à jour le Bouton d'ajout au Panier avec un message de succès * 2. Met à jour le Bouton d'ajout au Panier avec un message de succès
* 3. (3 secondes) Réinitialise le Sélecteur de Quantité et le Bouton d'Ajout au Panier * 3. (3 secondes) Réinitialise le Sélecteur de Quantité et le Bouton d'Ajout au Panier
*/ */
// BOUTON_PANIER.textContent = `cart (${String(nombreArticlesPanier)})`;
// BOUTON_PANIER.setAttribute(ATTRIBUT_CONTIENT_ARTICLES, String(nombreArticlesPanier > 0));
BOUTON_AJOUT_PANIER.textContent = "Added to cart!"; BOUTON_AJOUT_PANIER.textContent = "Added to cart!";
const CANAL_BOUTON_PANIER: BroadcastChannel = new BroadcastChannel(NOM_CANAL_BOUTON_PANIER);
// TODO: Test CANAL_BOUTON_PANIER.postMessage({ donnees: nombreArticlesPanier, type: TYPES_MESSAGES.MiseAJourPanier });
canalBoutonPanier.postMessage({ donnees: nombreArticlesPanier, type: "maj_panier" });
// TODO: Prévoir un cas où ce Timeout est annulé quand l'Utilisateur agit avant sur le Sélecteur // TODO: Prévoir un cas où ce Timeout est annulé quand l'Utilisateur agit avant sur le Sélecteur
setTimeout(() => { setTimeout(() => {

View file

@ -20,7 +20,7 @@ $informations_produits = wc_get_products([
"order" => "DESC", "order" => "DESC",
]); ]);
// Informations nécessaires pour la grille des Produits // Informations nécessaires pour la grille des Produits
$produits = array_map($callback = "recupere_informations_produit_shop", $array = $informations_produits); $produits = array_map(callback: "recupere_informations_produit_shop", array: $informations_produits);
$contexte["produits"] = $produits; $contexte["produits"] = $produits;
// Rendu // Rendu

View file

@ -18,7 +18,6 @@
{% block contenu %} {% block contenu %}
<main id="page-panier" data-contient-articles="{{ articles_presents }}"> <main id="page-panier" data-contient-articles="{{ articles_presents }}">
{# TODO: Prévoir le cas où il n'y a pas de Produits dans le Panier #}
<section class="panneau" id="panneau-panier"> <section class="panneau" id="panneau-panier">
<header class="panneau__en-tete"> <header class="panneau__en-tete">
<h2>Your cart</h2> <h2>Your cart</h2>