29 lines
935 B
TypeScript
Executable file
29 lines
935 B
TypeScript
Executable file
/** Schémas des Messages passés avec BroadcastChannel. */
|
|
|
|
import * as v from "valibot";
|
|
|
|
import { TYPES_MESSAGES } from "../../constantes/messages.ts";
|
|
import { WCStoreCartItemSchema } from "./api/cart.ts";
|
|
|
|
export const TypesMessagesSchema = v["enum"](TYPES_MESSAGES);
|
|
|
|
export const MessageMajBoutonPanierDonneesSchema = v.object({
|
|
quantiteProduits: v.number(),
|
|
});
|
|
|
|
export const MessageMajBoutonPanierSchema = v.object({
|
|
donnees: MessageMajBoutonPanierDonneesSchema,
|
|
type: v.pipe(v.string(), v.value(TYPES_MESSAGES.MajBoutonPanier)),
|
|
});
|
|
|
|
export const MessageMajContenuPanierDonneesSchema = v.object({
|
|
produits: v.array(WCStoreCartItemSchema),
|
|
sousTotalProduits: v.number(),
|
|
sousTotalReduction: v.number(),
|
|
totalPanier: v.number(),
|
|
});
|
|
|
|
export const MessageMajContenuPanierSchema = v.object({
|
|
donnees: MessageMajContenuPanierDonneesSchema,
|
|
type: v.pipe(v.string(), v.value(TYPES_MESSAGES.MajContenuPanier)),
|
|
});
|