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) => {
|
setCampaign((prev) => {
|
||||||
const firstBottomIdx = prev.modules.findIndex((m) => isBottomModule(m));
|
const firstBottomIdx = prev.modules.findIndex((m) => isBottomModule(m));
|
||||||
const newModules = [...prev.modules];
|
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);
|
newModules.splice(firstBottomIdx, 0, newMod);
|
||||||
} else {
|
} else {
|
||||||
newModules.push(newMod);
|
newModules.push(newMod);
|
||||||
|
|||||||
Reference in new issue
Block a user