'use client'; import SanityImage from 'components/ui/sanity-image'; import { cn } from 'lib/utils'; import Link from 'next/link'; import { FC } from 'react'; interface CardProps { className?: string; title: string; image: object | any; link: object | any; text?: string; imageFormat?: 'square' | 'portrait' | 'landscape'; } const placeholderImg = '/product-img-placeholder.svg'; const Card: FC = ({ className, title, image, link, text, imageFormat = 'square' }) => { const rootClassName = cn('relative', className); const { linkType } = link; const imageWrapperClasses = cn('w-full h-full overflow-hidden relative', { ['aspect-square']: imageFormat === 'square', ['aspect-[3/4]']: imageFormat === 'portrait', ['aspect-[4/3]']: imageFormat === 'landscape' }); const imageClasses = cn('object-cover w-full h-full'); function Card() { if (linkType === 'internal') { const type = link.internalLink.reference._type; let href = ''; if (type === 'product') { href = `/product/${link.internalLink.reference.slug.current}`; } else if (type === 'category') { href = `/category/${link.internalLink.reference.slug.current}`; } else { return `${link.internalLink.reference.slug.current}`; } return (
{image && (
)}

{title}

{text &&

{text}

}
); } return (
{image && (
)}

{title}

{text &&

{text}

}
); } return ; }; export default Card;