- All Products
+ {locale === "en" ? "All Products" : "Svi Proizvodi"}
- {publishedProducts.length === 0 ? (
-
No products available
+ {products.length === 0 ? (
+
+ {locale === "en" ? "No products available" : "Nema dostupnih proizvoda"}
+
) : (
- {publishedProducts.map((product, index) => (
-
+ {products.map((product, index) => (
+
))}
)}
diff --git a/src/components/product/ProductCard.tsx b/src/components/product/ProductCard.tsx
index 8242160..f404732 100644
--- a/src/components/product/ProductCard.tsx
+++ b/src/components/product/ProductCard.tsx
@@ -3,15 +3,20 @@
import { motion } from "framer-motion";
import Image from "next/image";
import Link from "next/link";
-import { WooProduct, formatPrice, getProductImage } from "@/lib/woocommerce";
+import type { Product } from "@/types/saleor";
+import { getProductPrice, getProductImage, getLocalizedProduct } from "@/lib/saleor";
interface ProductCardProps {
- product: WooProduct;
+ product: Product;
index?: number;
+ locale?: string;
}
-export default function ProductCard({ product, index = 0 }: ProductCardProps) {
+export default function ProductCard({ product, index = 0, locale = "SR" }: ProductCardProps) {
const image = getProductImage(product);
+ const price = getProductPrice(product);
+ const localized = getLocalizedProduct(product, locale);
+ const isAvailable = product.variants?.[0]?.quantityAvailable > 0;
return (
-
+
{image && (
)}
- {product.stock_status === "outofstock" && (
+ {!isAvailable && (
- Out of Stock
+
+ {locale === "en" ? "Out of Stock" : "Nema na stanju"}
+
)}
- {product.name}
+ {localized.name}
- {product.price ? formatPrice(product.price) : "Contact for price"}
+ {price || (locale === "en" ? "Contact for price" : "Kontaktirajte za cenu")}