2024-10-16

This commit is contained in:
gcch 2024-10-16 22:06:13 +02:00
commit 5793fcb710
72 changed files with 1586 additions and 667 deletions

View file

@ -0,0 +1,56 @@
import { z, N } from "./index.CeK6pfoJ.js";
import { p as parse } from "./index.BgFo03XT.js";
import { R as ROUTE_API_PRODUITS } from "./api.js";
import { f as SELECTEUR_GRILLE_PRODUITS, g as SELECTEUR_BOUTON_PLUS_PRODUITS } from "./dom.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 WCProductsArgsSchema, a as WCProductsSchema } from "./products.js";
import { a as recupereElementDansDocumentOuLeve } from "./utils.js";
import { E as EitherAsync } from "./MaybeAsync.AE1jnxuc.js";
import { E as Either } from "./Either.wHNxn7Os.js";
import "./exports.DMCTjIlP.js";
import "./chunk-7BKSRZNG.C39W3Wne.js";
import "./erreurs2.js";
import "./products2.js";
import "./dom2.js";
const ETATS_PAGE = _etats;
recupereElementDansDocumentOuLeve(SELECTEUR_GRILLE_PRODUITS);
const BOUTON_PLUS_DE_PRODUITS = recupereElementDansDocumentOuLeve(SELECTEUR_BOUTON_PLUS_PRODUITS);
const initialisePageBoutique = () => {
BOUTON_PLUS_DE_PRODUITS.addEventListener("click", () => {
const args = {
page: 1
};
Either.encase(() => parse(WCProductsArgsSchema, args)).map(
async (args2) => {
await EitherAsync(
() => getBackend({
nonce: ETATS_PAGE.nonce,
route: ROUTE_API_PRODUITS,
searchParams: new URLSearchParams(args2).toString()
})
).map((reponse) => {
if (estReponse500(reponse)) leveServerError("500 Server Error");
return reponse.json();
}).map(
(corpsReponse) => (
// Traite tous les codes HTTPs possibles
traiteReponseBackendWCSelonCodesHTTP(
corpsReponse,
WCProductsSchema
)
)
).ifRight((donnees) => {
console.debug(donnees);
}).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