From 227032368a0f7ec09028cd57325100faf6938d52 Mon Sep 17 00:00:00 2001 From: Nik Tverd Date: Wed, 13 Sep 2023 15:54:53 +0600 Subject: [PATCH 1/3] feat: add analyticsEvents to BackgroundCard --- src/models/constructor-items/sub-blocks.ts | 1 + src/sub-blocks/BackgroundCard/BackgroundCard.tsx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/models/constructor-items/sub-blocks.ts b/src/models/constructor-items/sub-blocks.ts index 27b827f6b..652736376 100644 --- a/src/models/constructor-items/sub-blocks.ts +++ b/src/models/constructor-items/sub-blocks.ts @@ -100,6 +100,7 @@ export interface QuoteProps extends Themable, CardBaseProps { export interface BackgroundCardProps extends CardBaseProps, + AnalyticsEventsBase, Omit { url?: string; background?: ThemeSupporting; diff --git a/src/sub-blocks/BackgroundCard/BackgroundCard.tsx b/src/sub-blocks/BackgroundCard/BackgroundCard.tsx index 72eb30664..b491867a3 100644 --- a/src/sub-blocks/BackgroundCard/BackgroundCard.tsx +++ b/src/sub-blocks/BackgroundCard/BackgroundCard.tsx @@ -23,6 +23,7 @@ const BackgroundCard = (props: BackgroundCardProps) => { theme: cardTheme = 'default', links, buttons, + analyticsEvents, } = props; const theme = useTheme(); @@ -34,6 +35,7 @@ const BackgroundCard = (props: BackgroundCardProps) => { className={b({padding: paddingBottom, theme: cardTheme})} url={url} border={borderType} + analyticsEvents={analyticsEvents} > Date: Wed, 13 Sep 2023 16:23:07 +0600 Subject: [PATCH 2/3] fixup! feat: add analyticsEvents to BackgroundCard --- src/models/constructor-items/common.ts | 5 ++++- src/models/constructor-items/sub-blocks.ts | 3 ++- src/sub-blocks/BackgroundCard/schema.ts | 14 ++++++++++++++ src/sub-blocks/MediaCard/MediaCard.tsx | 9 +++++++-- src/sub-blocks/MediaCard/schema.ts | 14 ++++++++++++++ .../CombinedPriceDetailed.tsx | 6 ++++-- .../SeparatePriceDetailed.tsx | 9 +++++++-- src/sub-blocks/PriceDetailed/schema.ts | 14 ++++++++++++++ 8 files changed, 66 insertions(+), 8 deletions(-) diff --git a/src/models/constructor-items/common.ts b/src/models/constructor-items/common.ts index 6f8c8fea6..8f92481c6 100644 --- a/src/models/constructor-items/common.ts +++ b/src/models/constructor-items/common.ts @@ -383,7 +383,10 @@ export interface PriceDetailsProps { items?: PriceDetailsSettingsProps[] | PriceDetailsListProps[]; } -export interface PriceItemProps extends PriceDetailsProps, PriceDescriptionProps {} +export interface PriceItemProps + extends PriceDetailsProps, + PriceDescriptionProps, + AnalyticsEventsBase {} export interface PriceFoldableDetailsProps { title: string; diff --git a/src/models/constructor-items/sub-blocks.ts b/src/models/constructor-items/sub-blocks.ts index 652736376..101e48378 100644 --- a/src/models/constructor-items/sub-blocks.ts +++ b/src/models/constructor-items/sub-blocks.ts @@ -110,6 +110,7 @@ export interface BackgroundCardProps export interface BasicCardProps extends CardBaseProps, + AnalyticsEventsBase, Omit { url: string; icon?: ImageProps; @@ -127,7 +128,7 @@ export interface BannerCardProps { button: Pick; } -export interface MediaCardProps extends MediaProps, CardBaseProps {} +export interface MediaCardProps extends MediaProps, AnalyticsEventsBase, CardBaseProps {} export interface LayoutItemProps extends ClassNameProps { content: Omit; diff --git a/src/sub-blocks/BackgroundCard/schema.ts b/src/sub-blocks/BackgroundCard/schema.ts index e4d064532..278fea9f4 100644 --- a/src/sub-blocks/BackgroundCard/schema.ts +++ b/src/sub-blocks/BackgroundCard/schema.ts @@ -2,6 +2,7 @@ import _ from 'lodash'; import {ImageObjectProps} from '../../components/Image/schema'; import {BaseProps, CardBase, withTheme} from '../../schema/validators/common'; +import {AnalyticsEventSchema} from '../../schema/validators/event'; import {ContentBase} from '../Content/schema'; const BackgroundCardContentProps = _.omit(ContentBase, ['size']); @@ -25,6 +26,19 @@ export const BackgroundCard = { type: 'string', enum: ['s', 'm', 'l', 'xl'], }, + analyticsEvents: { + oneOf: [ + { + ...AnalyticsEventSchema, + optionName: 'single', + }, + { + type: 'array', + items: AnalyticsEventSchema, + optionName: 'list', + }, + ], + }, }, }, }; diff --git a/src/sub-blocks/MediaCard/MediaCard.tsx b/src/sub-blocks/MediaCard/MediaCard.tsx index 19624b727..4aa8cd7bc 100644 --- a/src/sub-blocks/MediaCard/MediaCard.tsx +++ b/src/sub-blocks/MediaCard/MediaCard.tsx @@ -8,8 +8,13 @@ import './MediaCard.scss'; const b = block('MediaCard'); -const MediaCard = ({border, ...mediaProps}: MediaCardProps) => ( - +const MediaCard = ({border, analyticsEvents, ...mediaProps}: MediaCardProps) => ( + diff --git a/src/sub-blocks/MediaCard/schema.ts b/src/sub-blocks/MediaCard/schema.ts index 3a046e976..6ec523240 100644 --- a/src/sub-blocks/MediaCard/schema.ts +++ b/src/sub-blocks/MediaCard/schema.ts @@ -1,4 +1,5 @@ import {AnimatableProps, BaseProps, CardBase, MediaProps} from '../../schema/validators/common'; +import {AnalyticsEventSchema} from '../../schema/validators/event'; export const MediaCardBlock = { 'media-card': { @@ -9,6 +10,19 @@ export const MediaCardBlock = { ...CardBase, ...MediaProps, ...AnimatableProps, + analyticsEvents: { + oneOf: [ + { + ...AnalyticsEventSchema, + optionName: 'single', + }, + { + type: 'array', + items: AnalyticsEventSchema, + optionName: 'list', + }, + ], + }, }, }, }; diff --git a/src/sub-blocks/PriceDetailed/CombinedPriceDetailed/CombinedPriceDetailed.tsx b/src/sub-blocks/PriceDetailed/CombinedPriceDetailed/CombinedPriceDetailed.tsx index d14df3594..df128a12a 100644 --- a/src/sub-blocks/PriceDetailed/CombinedPriceDetailed/CombinedPriceDetailed.tsx +++ b/src/sub-blocks/PriceDetailed/CombinedPriceDetailed/CombinedPriceDetailed.tsx @@ -6,6 +6,7 @@ import {CardBase} from '../../../components'; import {BREAKPOINTS} from '../../../constants'; import {Col, Grid, GridColumnSize, Row} from '../../../grid'; import { + AnalyticsEventsBase, CardBorder, PriceDescriptionProps, PriceDetailsListProps, @@ -24,7 +25,7 @@ const CombinedPricesGroupSize = { [GridColumnSize.Lg]: 3, }; -interface CombinedPriceDetailedProps { +interface CombinedPriceDetailedProps extends AnalyticsEventsBase { items: PriceItemProps[]; numberGroupItems: number; useMixedView?: boolean; @@ -43,6 +44,7 @@ const CombinedPriceDetailed = (props: CombinedPriceDetailedProps) => { useMixedView, getDescriptionComponent, getDetailsComponent, + analyticsEvents, } = props; const [groupItemsSize, setGroupItemsSize] = useState(numberGroupItems); @@ -103,7 +105,7 @@ const CombinedPriceDetailed = (props: CombinedPriceDetailedProps) => { const chunkedItems = _.chunk(items, groupItemsSize); return ( - + {chunkedItems.map((chunk: PriceItemProps[], id) => { diff --git a/src/sub-blocks/PriceDetailed/SeparatePriceDetailed/SeparatePriceDetailed.tsx b/src/sub-blocks/PriceDetailed/SeparatePriceDetailed/SeparatePriceDetailed.tsx index 9fcf29d0d..6697fdeb1 100644 --- a/src/sub-blocks/PriceDetailed/SeparatePriceDetailed/SeparatePriceDetailed.tsx +++ b/src/sub-blocks/PriceDetailed/SeparatePriceDetailed/SeparatePriceDetailed.tsx @@ -28,8 +28,13 @@ const SeparatePriceDetailed = (props: SeparatePriceDetailedProps) => { return ( - {items.map((item: PriceItemProps, id: number) => ( - + {items.map(({analyticsEvents, ...item}: PriceItemProps, id: number) => ( + {getDescriptionComponent(item)} {getDetailsComponent(item.items)} diff --git a/src/sub-blocks/PriceDetailed/schema.ts b/src/sub-blocks/PriceDetailed/schema.ts index 31ed177e1..83d11183c 100644 --- a/src/sub-blocks/PriceDetailed/schema.ts +++ b/src/sub-blocks/PriceDetailed/schema.ts @@ -1,4 +1,5 @@ import {AnimatableProps, BaseProps, textSize} from '../../schema/validators/common'; +import {AnalyticsEventSchema} from '../../schema/validators/event'; import {filteredArray} from '../../schema/validators/utils'; const PriceDetailedDetailsType = ['marked-list', 'settings']; @@ -162,6 +163,19 @@ const PriceItem = { properties: { ...PriceDetailsProps, ...PriceDescriptionProps, + analyticsEvents: { + oneOf: [ + { + ...AnalyticsEventSchema, + optionName: 'single', + }, + { + type: 'array', + items: AnalyticsEventSchema, + optionName: 'list', + }, + ], + }, }, }; From f5ac6cd706f36466d898cc50ff13f3123c36b353 Mon Sep 17 00:00:00 2001 From: Nik Tverd Date: Wed, 13 Sep 2023 16:26:54 +0600 Subject: [PATCH 3/3] fixup! fixup! feat: add analyticsEvents to BackgroundCard --- src/models/constructor-items/sub-blocks.ts | 2 +- src/sub-blocks/LayoutItem/LayoutItem.tsx | 4 +++- src/sub-blocks/LayoutItem/schema.ts | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/models/constructor-items/sub-blocks.ts b/src/models/constructor-items/sub-blocks.ts index 101e48378..75ddfb11a 100644 --- a/src/models/constructor-items/sub-blocks.ts +++ b/src/models/constructor-items/sub-blocks.ts @@ -130,7 +130,7 @@ export interface BannerCardProps { export interface MediaCardProps extends MediaProps, AnalyticsEventsBase, CardBaseProps {} -export interface LayoutItemProps extends ClassNameProps { +export interface LayoutItemProps extends ClassNameProps, AnalyticsEventsBase { content: Omit; media: MediaProps; metaInfo?: string[]; diff --git a/src/sub-blocks/LayoutItem/LayoutItem.tsx b/src/sub-blocks/LayoutItem/LayoutItem.tsx index 24bf6a706..7fdfe3bc7 100644 --- a/src/sub-blocks/LayoutItem/LayoutItem.tsx +++ b/src/sub-blocks/LayoutItem/LayoutItem.tsx @@ -18,6 +18,7 @@ const LayoutItem = ({ border, fullscreen, className, + analyticsEvents, }: LayoutItemProps) => (
{fullscreen && hasFullscreen(media) ? ( @@ -31,11 +32,12 @@ const LayoutItem = ({ {...media} {...fullscreenMediaProps} className={b('media', {border}, mediaClassName)} + analyticsEvents={analyticsEvents} /> )} ) : ( - + )} {metaInfo && }
diff --git a/src/sub-blocks/LayoutItem/schema.ts b/src/sub-blocks/LayoutItem/schema.ts index 31ef2466f..7f254bbb4 100644 --- a/src/sub-blocks/LayoutItem/schema.ts +++ b/src/sub-blocks/LayoutItem/schema.ts @@ -2,6 +2,7 @@ import {omit} from 'lodash'; import metaInfo from '../../components/MetaInfo/schema'; import {BaseProps, MediaProps} from '../../schema/validators/common'; +import {AnalyticsEventSchema} from '../../schema/validators/event'; import {ContentBase} from '../../sub-blocks/Content/schema'; export const LayoutItem = { @@ -19,5 +20,18 @@ export const LayoutItem = { fullscreen: { type: 'boolean', }, + analyticsEvents: { + oneOf: [ + { + ...AnalyticsEventSchema, + optionName: 'single', + }, + { + type: 'array', + items: AnalyticsEventSchema, + optionName: 'list', + }, + ], + }, }, };