From cec8764905a674647fff22fc3acfaec1c644c775 Mon Sep 17 00:00:00 2001 From: Jandl-hostacny Date: Wed, 21 Oct 2026 16:17:02 +0200 Subject: [PATCH] fix: nova produktova sekcia sa prida pod listu Akcia plati (za poslednu produktovu sekciu) Co-Authored-By: Claude Opus 5.5 --- src/app/page.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index fc1f5c7..82c2876 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -339,7 +339,13 @@ export default function Home() { setCampaign((prev) => { const firstBottomIdx = prev.modules.findIndex((m) => isBottomModule(m)); const newModules = [...prev.modules]; - if (firstBottomIdx !== -1) { + // Produktová sekcia ide za poslednú existujúcu produktovú sekciu, a keď žiadna nie je, hneď pod lištu „Akcia platí“ + const lastProductsIdx = prev.modules.map((m) => m.type).lastIndexOf('products_grid'); + const validityIdx = prev.modules.findIndex((m) => m.type === 'validity_bar'); + const productsAt = lastProductsIdx !== -1 ? lastProductsIdx + 1 : validityIdx !== -1 ? validityIdx + 1 : -1; + if (newMod.type === 'products_grid' && productsAt !== -1) { + newModules.splice(productsAt, 0, newMod); + } else if (firstBottomIdx !== -1) { newModules.splice(firstBottomIdx, 0, newMod); } else { newModules.push(newMod);