"use client"; import { motion } from "framer-motion"; import Image from "next/image"; import Link from "next/link"; import { useTranslations } from "next-intl"; import type { Product } from "@/types/saleor"; import { getProductPrice, getProductImage, getLocalizedProduct } from "@/lib/saleor"; import { isValidLocale, getSaleorLocale } from "@/lib/i18n/locales"; interface ProductCardProps { product: Product; index?: number; locale?: string; } export default function ProductCard({ product, index = 0, locale = "sr" }: ProductCardProps) { const t = useTranslations("ProductCard"); const image = getProductImage(product); const price = getProductPrice(product); const saleorLocale = isValidLocale(locale) ? getSaleorLocale(locale) : "SR"; const localized = getLocalizedProduct(product, saleorLocale); const isAvailable = product.variants?.[0]?.quantityAvailable > 0; return (
{image ? ( {localized.name} ) : (
{t("noImage")}
)} {!isAvailable && (
{t("outOfStock")}
)}

{localized.name}

{price || t("contactForPrice")}

); }