Compare commits
2
Commits
9a61564e3c
...
bfce7dcca0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfce7dcca0 | ||
|
|
8f780c3585 |
@@ -40,7 +40,10 @@ export default async function Homepage({ params }: { params: Promise<{ locale: s
|
||||
console.log("Failed to fetch products during build");
|
||||
}
|
||||
|
||||
const featuredProducts = products?.slice(0, 4) || [];
|
||||
const filteredProducts = products?.filter(
|
||||
(p: any) => !p.name.includes("2x Set") && !p.name.includes("3x Set")
|
||||
);
|
||||
const featuredProducts = filteredProducts?.slice(0, 4) || [];
|
||||
const hasProducts = featuredProducts.length > 0;
|
||||
|
||||
const basePath = `/${validLocale}`;
|
||||
|
||||
@@ -20,7 +20,10 @@ export async function generateStaticParams() {
|
||||
try {
|
||||
const saleorLocale = locale === "sr" ? "SR" : "EN";
|
||||
const products = await getProducts(saleorLocale, 100);
|
||||
products.forEach((product: Product) => {
|
||||
const filteredProducts = products.filter(
|
||||
(p: Product) => !p.name.includes("2x Set") && !p.name.includes("3x Set")
|
||||
);
|
||||
filteredProducts.forEach((product: Product) => {
|
||||
params.push({ locale, slug: product.slug });
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -88,9 +91,10 @@ export default async function ProductPage({ params }: ProductPageProps) {
|
||||
let relatedProducts: Product[] = [];
|
||||
let bundleProducts: Product[] = [];
|
||||
try {
|
||||
const allProducts = await getProducts(saleorLocale, 8);
|
||||
const allProducts = await getProducts(saleorLocale, 50);
|
||||
relatedProducts = allProducts
|
||||
.filter((p: Product) => p.id !== product.id)
|
||||
.filter((p) => !p.name.includes("2x Set") && !p.name.includes("3x Set"))
|
||||
.slice(0, 4);
|
||||
} catch (e) {}
|
||||
|
||||
@@ -100,10 +104,9 @@ export default async function ProductPage({ params }: ProductPageProps) {
|
||||
const bundleAttr = p.attributes?.find(
|
||||
(attr) => attr.attribute.slug === "bundle-items"
|
||||
);
|
||||
if (!bundleAttr) return false;
|
||||
if (!bundleAttr || bundleAttr.values.length === 0) return false;
|
||||
return bundleAttr.values.some((val) => {
|
||||
const baseIdPart = product.id.replace("UHJvZHVjdDo", "");
|
||||
return val.slug.includes(baseIdPart);
|
||||
return val.name === product.name || p.name.includes(product.name.split(" - ")[0]);
|
||||
});
|
||||
});
|
||||
} catch (e) {}
|
||||
|
||||
@@ -27,7 +27,11 @@ export default async function ProductsPage({ params }: ProductsPageProps) {
|
||||
setRequestLocale(validLocale);
|
||||
const t = await getTranslations("Products");
|
||||
const saleorLocale = getSaleorLocale(validLocale as Locale);
|
||||
const products = await getProducts(saleorLocale);
|
||||
const allProducts = await getProducts(saleorLocale);
|
||||
|
||||
const products = allProducts.filter((product) => {
|
||||
return !product.name.includes("2x Set") && !product.name.includes("3x Set");
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
+5
-1
@@ -80,9 +80,13 @@ export default async function sitemap(): Promise<SitemapEntry[]> {
|
||||
},
|
||||
];
|
||||
|
||||
const filteredProducts = products.filter(
|
||||
(p: any) => !p.name.includes("2x Set") && !p.name.includes("3x Set")
|
||||
);
|
||||
|
||||
const productUrls: SitemapEntry[] = [];
|
||||
|
||||
for (const product of products) {
|
||||
for (const product of filteredProducts) {
|
||||
const hreflangs: Record<string, string> = {};
|
||||
for (const locale of SUPPORTED_LOCALES) {
|
||||
const path = locale === "sr" ? `/products/${product.slug}` : `/${locale}/products/${product.slug}`;
|
||||
|
||||
@@ -354,28 +354,6 @@ export default function ProductDetail({ product, relatedProducts, bundleProducts
|
||||
)
|
||||
)}
|
||||
|
||||
<div className="flex items-center gap-4 mb-8">
|
||||
<span className="text-sm uppercase tracking-[0.1em] font-medium w-16">
|
||||
{t("qty")}
|
||||
</span>
|
||||
<div className="flex items-center border-2 border-[#1a1a1a]">
|
||||
<button
|
||||
onClick={() => setQuantity(Math.max(1, quantity - 1))}
|
||||
className="w-12 h-12 flex items-center justify-center hover:bg-[#f8f9fa] transition-colors"
|
||||
disabled={quantity <= 1}
|
||||
>
|
||||
<Minus className="w-4 h-4" />
|
||||
</button>
|
||||
<span className="w-14 text-center text-base font-medium">{quantity}</span>
|
||||
<button
|
||||
onClick={() => setQuantity(quantity + 1)}
|
||||
className="w-12 h-12 flex items-center justify-center hover:bg-[#f8f9fa] transition-colors"
|
||||
>
|
||||
<Plus className="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isAvailable ? (
|
||||
<button
|
||||
onClick={handleAddToCart}
|
||||
|
||||
Reference in New Issue
Block a user