@streamscloud/embeddable 5.1.0 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ export const mapToAdCardModel = (payload) => {
3
3
  return {
4
4
  id: payload.id,
5
5
  type: payload.type,
6
- image: getMediaItemImageUrl(payload.media[0]),
6
+ image: getMediaItemImageUrl(payload.media?.[0]),
7
7
  title: payload.title,
8
8
  description: payload.description,
9
9
  price: payload.price,
@@ -1,2 +1,2 @@
1
1
  import { type MediaItemModel } from './types';
2
- export declare const getMediaItemImageUrl: (media: MediaItemModel) => string;
2
+ export declare const getMediaItemImageUrl: (media?: MediaItemModel | null) => string;
@@ -1,3 +1,8 @@
1
1
  import { MediaType } from '../enums';
2
2
  import {} from './types';
3
- export const getMediaItemImageUrl = (media) => (media.type === MediaType.Image ? media.url : media.thumbnailUrl);
3
+ export const getMediaItemImageUrl = (media) => {
4
+ if (!media) {
5
+ return '';
6
+ }
7
+ return media.type === MediaType.Image ? media.url : media.thumbnailUrl;
8
+ };
@@ -1,8 +1,8 @@
1
1
  import { getMediaItemImageUrl } from '../../core/media';
2
2
  import { shouldUseSalePrice } from '../price-helper';
3
3
  export const mapToProductCard = (payload, referenceDate) => {
4
- const effectiveSalePrice = payload.priceAndAvailability.productSalePrices?.find((x) => shouldUseSalePrice({
5
- price: payload.priceAndAvailability.price,
4
+ const effectiveSalePrice = payload.priceAndAvailability?.productSalePrices?.find((x) => shouldUseSalePrice({
5
+ price: payload.priceAndAvailability?.price,
6
6
  salePrice: x.salePrice,
7
7
  effectiveDateFrom: x.salePriceEffectiveDateFrom,
8
8
  effectiveDateTo: x.salePriceEffectiveDateTo,
@@ -14,7 +14,7 @@ export const mapToProductCard = (payload, referenceDate) => {
14
14
  shortDescription: payload.shortDescription,
15
15
  link: payload.link,
16
16
  brandName: payload.brand?.name || null,
17
- image: getMediaItemImageUrl(payload.media[0]),
17
+ image: getMediaItemImageUrl(payload.media?.[0]),
18
18
  currency: payload.priceAndAvailability.currency,
19
19
  price: payload.priceAndAvailability.price,
20
20
  salePrice: effectiveSalePrice?.salePrice ?? null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/embeddable",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "author": "StreamsCloud",
5
5
  "repository": "https://github.com/StreamsCloud/streamscloud-frontend-packages.git",
6
6
  "type": "module",