diff --git a/src/components/AdDisplay/AdDisplay.tsx b/src/components/AdDisplay/AdDisplay.tsx index ce3d36c..5524dee 100644 --- a/src/components/AdDisplay/AdDisplay.tsx +++ b/src/components/AdDisplay/AdDisplay.tsx @@ -75,15 +75,11 @@ function Ad({ function AdContainer({ secure_url, index, - fileImage, - setFileImage, scale, children, }: { secure_url: string; index: number; - fileImage: object[] | undefined; - setFileImage: any; scale: number | undefined; children: React.ReactNode; }) { @@ -113,9 +109,7 @@ function AdContainer({ } function Ads({ - fileImage, imageMedia, - setFileImage, scale, adTitle, adCopy, @@ -123,9 +117,7 @@ function Ads({ callToAction, buttonText, }: { - fileImage: object[] | undefined; imageMedia: { secure_url: string; mediaUrlType: string }[]; - setFileImage: any; scale: number | undefined; adTitle?: string | undefined; adCopy?: string | undefined; @@ -134,9 +126,7 @@ function Ads({ buttonText?: string | undefined; }) { const ads = getAds( - fileImage, imageMedia, - setFileImage, scale, adTitle, adCopy, @@ -154,9 +144,7 @@ function Ads({ ); } export default function AdDisplay({ - fileImage, imageMedia, - setFileImage, scale, adTitle, adCopy, @@ -164,9 +152,7 @@ export default function AdDisplay({ callToAction, buttonText, }: { - fileImage: object[]; imageMedia: { secure_url: string; mediaUrlType: string }[]; - setFileImage: any; scale?: number | undefined; adTitle?: string | undefined; adCopy?: string | undefined; @@ -176,9 +162,7 @@ export default function AdDisplay({ }) { return ( { - return typeof fileImage !== 'undefined' +const getMedia = (fileImage?: object[] | string[] | undefined): any => { + if (typeof fileImage === 'undefined') return fileImage; + if (typeof fileImage?.length === 'undefined') return fileImage; + return typeof fileImage[0] !== 'string' ? fileImage.map((media: any): MediaObject | undefined => { const secure_url: string | null = media?.secure_url || null; if (!secure_url) return undefined; @@ -16,11 +18,16 @@ const getMedia = (fileImage?: object[] | undefined): any => { mediaUrlType: detectMediaType(secure_url), }; }) - : fileImage; + : fileImage.map((url) => { + const secure_url: string = url as string; + return { + secure_url: secure_url, + mediaUrlType: detectMediaType(secure_url), + }; + }); }; export default function DefaultAdDisplay({ fileImage, - setFileImage, scale, adTitle, adCopy, @@ -28,8 +35,7 @@ export default function DefaultAdDisplay({ callToAction, buttonText, }: { - fileImage: object[] | undefined; - setFileImage: any; + fileImage: object[] | string[] | undefined; scale: number | undefined; adTitle?: string | undefined; adCopy?: string | undefined; @@ -44,9 +50,7 @@ export default function DefaultAdDisplay({ className={'' /*"promo-scale-65 sm:promo--translate-x-4 promo--w-full"*/} >