import { pushDatalayer } from '../../utils/pushDatalayer'; import type { ViewPromotion } from '../../types'; import type { Banners } from '../../../Api/types'; export function viewPromotion( bannerGroups: Array>, ) { bannerGroups.forEach(bannerGroup => { pushDatalayer({ event: 'view_promotion', ecommerce: { items: [ ...bannerGroup.banners.map((banner, bannerIndex) => { return { promotion_id: banner.id, promotion_name: 'Banners' as ViewPromotion['ecommerce']['items'][0]['promotion_name'], creative_name: `${banner.scheduling?.startDate.slice(0, 10)}-${banner.name.replaceAll(' ', '-')}`, creative_slot: bannerIndex + 1, index: bannerIndex + 1, }; }), ], }, }); }); }