fonc(à-propos) termine la page
This commit is contained in:
parent
a565d3bc7b
commit
7276dff1a4
114 changed files with 448 additions and 14475 deletions
|
|
@ -1,102 +1,24 @@
|
|||
import { z, N } from "./index.CeK6pfoJ.js";
|
||||
import { p as parse } from "./index.Dco04HYW.js";
|
||||
import { R as ROUTE_API_NOUVELLE_PRODUCTS } from "./api.js";
|
||||
import { f as SELECTEUR_GRILLE_PRODUITS, g as SELECTEUR_BOUTON_PLUS_PRODUITS, h as ATTRIBUT_ID_CATEGORIE_PRODUITS, i as ATTRIBUT_PAGE, j as ATTRIBUT_HIDDEN } from "./dom.js";
|
||||
import { h as html } from "./dom2.js";
|
||||
import { l as leveServerError } from "./erreurs.js";
|
||||
import { e as estReponse500 } from "./gardes.js";
|
||||
import { g as getBackend, t as traiteReponseBackendWCSelonCodesHTTP } from "./reseau.js";
|
||||
import { W as WCV3ProductsArgsSchema, a as WCV3ProductsSchema } from "./products3.js";
|
||||
import { a as recupereElementDansDocumentOuLeve } from "./utils.js";
|
||||
import { E as EitherAsync } from "./MaybeAsync.AE1jnxuc.js";
|
||||
import { p as pipe } from "./pipe.XPB0wEfw.js";
|
||||
import { t as tap } from "./index-0eef19ec.C9-H3LKa.js";
|
||||
import { E as Either } from "./Either.wHNxn7Os.js";
|
||||
import "./exports.BuUzFliQ.js";
|
||||
import "./erreurs2.js";
|
||||
import "./products4.js";
|
||||
import "./belt_Option-91f3b350.BEnQsSyX.js";
|
||||
const ETATS_PAGE = _etats;
|
||||
const GRILLE_PRODUITS = recupereElementDansDocumentOuLeve(SELECTEUR_GRILLE_PRODUITS);
|
||||
const BOUTON_PLUS_DE_PRODUITS = recupereElementDansDocumentOuLeve(SELECTEUR_BOUTON_PLUS_PRODUITS);
|
||||
const initialisePageBoutique = () => {
|
||||
const idCategorieProduits = GRILLE_PRODUITS.getAttribute(ATTRIBUT_ID_CATEGORIE_PRODUITS);
|
||||
BOUTON_PLUS_DE_PRODUITS.addEventListener("click", () => {
|
||||
const nouvellePage = Number(GRILLE_PRODUITS.getAttribute(ATTRIBUT_PAGE)) + 1;
|
||||
const args = {
|
||||
page: nouvellePage,
|
||||
per_page: 13,
|
||||
// Ajoute conditionnellement la Catégorie de Produits
|
||||
...idCategorieProduits && { category: idCategorieProduits }
|
||||
};
|
||||
Either.encase(() => parse(WCV3ProductsArgsSchema, args)).map(
|
||||
async (args2) => {
|
||||
await EitherAsync(
|
||||
() => getBackend({
|
||||
authString: ETATS_PAGE.authString,
|
||||
nonce: ETATS_PAGE.nonce,
|
||||
route: ROUTE_API_NOUVELLE_PRODUCTS,
|
||||
searchParams: new URLSearchParams(args2).toString()
|
||||
})
|
||||
).map((reponse) => {
|
||||
console.debug("réponse", reponse);
|
||||
if (estReponse500(reponse)) leveServerError("500 Server Error");
|
||||
return reponse.json();
|
||||
}).map(
|
||||
(corpsReponse) => (
|
||||
// Traite tous les codes HTTPs possibles
|
||||
traiteReponseBackendWCSelonCodesHTTP(
|
||||
corpsReponse,
|
||||
WCV3ProductsSchema
|
||||
)
|
||||
)
|
||||
).ifRight((donnees) => {
|
||||
if (donnees.length < 12) {
|
||||
BOUTON_PLUS_DE_PRODUITS.toggleAttribute(ATTRIBUT_HIDDEN);
|
||||
}
|
||||
const fragment = document.createDocumentFragment();
|
||||
console.debug(donnees);
|
||||
for (const produit of donnees.slice(0, 12)) {
|
||||
pipe(
|
||||
html`
|
||||
import{z as _,N as g}from"./index.CuMLbxmh.js";import{p as d}from"./index.DFL3aKZD.js";import{R as f}from"./api.js";import{f as E,g as T,h,i as s,j as S}from"./dom.js";import{h as R}from"./dom2.js";import{l as P}from"./erreurs.js";import{e as U}from"./gardes.js";import{g as L,t as A}from"./reseau.js";import{W as O,a as D}from"./products3.js";import{a as m}from"./utils.js";import{E as I}from"./MaybeAsync.BkJailCK.js";import{p as C}from"./pipe.CtTFdEz3.js";import{t as v}from"./index-0eef19ec._7_ubBTi.js";import{E as b}from"./Either.DDEPhGsy.js";import"./exports.LfjCCHHP.js";import"./erreurs2.js";import"./products4.js";import"./belt_Option-91f3b350.aHdMVyeC.js";const p=_etats,i=m(E),n=m(T),B=()=>{const o=i.getAttribute(h);n.addEventListener("click",()=>{const a=Number(i.getAttribute(s))+1,c={page:a,per_page:13,...o&&{category:o}};b.encase(()=>d(O,c)).map(async u=>{await I(()=>L({authString:p.authString,nonce:p.nonce,route:f,searchParams:new URLSearchParams(u).toString()})).map(t=>(console.debug("réponse",t),U(t)&&P("500 Server Error"),t.json())).map(t=>A(t,D)).ifRight(t=>{t.length<12&&n.toggleAttribute(S);const r=document.createDocumentFragment();console.debug(t);for(const e of t.slice(0,12))C(R`
|
||||
<article class="produit">
|
||||
<figure>
|
||||
<a href="https://haikuatelier.fr.ddev.site/product/${produit.slug}">
|
||||
<a href="https://haikuatelier.fr.ddev.site/product/${e.slug}">
|
||||
<picture class="produit__illustration produit__illustration__principale">
|
||||
${produit.images[0]?.tag}
|
||||
${e.images[0]?.tag}
|
||||
</picture>
|
||||
|
||||
<picture class="produit__illustration produit__illustration__survol">
|
||||
${produit.image_survol ?? ""}
|
||||
${e.image_survol??""}
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
<figcaption class="produit__textuel">
|
||||
<h3 class="produit__textuel__titre">
|
||||
<a href="${produit.permalink}">${produit.name}</a>
|
||||
<a href="${e.permalink}">${e.name}</a>
|
||||
</h3>
|
||||
<p class="produit__textuel__prix">
|
||||
${Number(produit.price)}€
|
||||
${Number(e.price)}€
|
||||
</p>
|
||||
</figcaption>
|
||||
</figure>
|
||||
</article>
|
||||
`,
|
||||
tap((article) => {
|
||||
fragment.appendChild(article);
|
||||
})
|
||||
);
|
||||
}
|
||||
GRILLE_PRODUITS.appendChild(fragment);
|
||||
GRILLE_PRODUITS.setAttribute(ATTRIBUT_PAGE, String(nouvellePage));
|
||||
}).ifLeft((e) => {
|
||||
z(e).with({ issues: N.select(), name: "ValiError" }, (problemes) => console.error("ValiError", problemes)).otherwise((e2) => console.error("Autre", e2.name, e2));
|
||||
}).void();
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
initialisePageBoutique();
|
||||
});
|
||||
//# sourceMappingURL=scripts-page-boutique.js.map
|
||||
`,v(l=>{r.appendChild(l)}));i.appendChild(r),i.setAttribute(s,String(a))}).ifLeft(t=>{_(t).with({issues:g.select(),name:"ValiError"},r=>console.error("ValiError",r)).otherwise(r=>console.error("Autre",r.name,r))}).void()})})};document.addEventListener("DOMContentLoaded",()=>{B()});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue