|
|
@@ -16,6 +16,10 @@ let Allproducts = [];
|
|
|
let cart = [];
|
|
|
let itsEmpty = true;
|
|
|
|
|
|
+// --- Categorias Importantes ---
|
|
|
+
|
|
|
+const favoriteCategories = ["Shop", "Pizzas Familiares", "Pizza Medianas" ];
|
|
|
+
|
|
|
// --- Historial de Chat ---
|
|
|
let chatHistory = [
|
|
|
{ role: "system", content: "¡Hola! Soy tu asistente en Biergarten Klein. ¿Te gustaría una recomendación de nuestras cervezas artesanales?" }
|
|
|
@@ -166,7 +170,13 @@ async function initializeProducts() {
|
|
|
async function createCategories(products) {
|
|
|
let categories = new Set(products.map(product => product.type || "Sin categoría"));
|
|
|
categories = Array.from(categories).sort((a, b) => a.localeCompare(b));
|
|
|
-
|
|
|
+
|
|
|
+ for (const category of favoriteCategories.reverse() ) {
|
|
|
+ if (categories.includes(category)) {
|
|
|
+ categories = categories.filter(cat => cat !== category);
|
|
|
+ categories.unshift(category); // Mover la categoría favorita al inicio
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!productListElement) return;
|
|
|
|
|
|
const categoryContainers = categories.map(category => {
|
|
|
@@ -175,8 +185,7 @@ async function createCategories(products) {
|
|
|
container.classList.add("mb-8", "p-4");
|
|
|
const title = document.createElement("h2");
|
|
|
title.classList.add("category-title", "text-3xl", "font-bold", "border-b-2", "pb-3", "mb-4");
|
|
|
- let titleText = ["a", "e", "i", "o", "u"].includes(category.charAt(category.length - 1).toLowerCase()) ? "s" :
|
|
|
- ["á", "é", "í", "ó", "ú"].includes(category.charAt(category.length - 1).toLowerCase()) ? "s" :
|
|
|
+ let titleText = ["a", "e", "i", "o", "u", "á", "é", "í", "ó", "ú", "p"].includes(category.charAt(category.length - 1).toLowerCase()) ? "s" :
|
|
|
category.charAt(category.length - 1).toLowerCase() === "s" ? "" : "es";
|
|
|
title.textContent = category + titleText;
|
|
|
container.appendChild(title);
|