fix: nova produktova sekcia sa prida pod listu Akcia plati (za poslednu produktovu sekciu)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fa824c541e
commit
cec8764905
1 file changed
+7
-1
+7
-1
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user