diff --git a/public/images/icons/vuesax/bold/pinterest.svg b/public/images/icons/vuesax/bold/pinterest.svg new file mode 100644 index 0000000..4af9570 --- /dev/null +++ b/public/images/icons/vuesax/bold/pinterest.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/app/shops/[shopId]/products/new/images/page.tsx b/src/app/shops/[shopId]/products/new/images/page.tsx index 436b2d8..8b84c30 100644 --- a/src/app/shops/[shopId]/products/new/images/page.tsx +++ b/src/app/shops/[shopId]/products/new/images/page.tsx @@ -36,16 +36,21 @@ function ProductImagesPage() { const [images, setImages] = useState([]); const [primaryIndex, setPrimaryIndex] = useState(0); + const [isPinterest, setIsPinterest] = useState(false); useEffect(() => { if (!listingId) return; - request<{ listing: { images: string[]; primaryImageIndex: number } }>( - "GET", - `/shop-products/${listingId}` - ).then((res) => { + request<{ + listing: { + images: string[]; + primaryImageIndex: number; + is_pinterest?: boolean; + }; + }>("GET", `/shop-products/${listingId}`).then((res) => { if (!res?.listing) return; setImages((res.listing.images || []).map((path) => ({ type: "existing", path }))); setPrimaryIndex(res.listing.primaryImageIndex || 0); + setIsPinterest(Boolean(res.listing.is_pinterest)); }); // eslint-disable-next-line react-hooks/exhaustive-deps }, [listingId]); @@ -83,6 +88,7 @@ function ProductImagesPage() { newFiles.forEach((img) => formData.append("images", img.file, img.file.name)); formData.append("existing_images", JSON.stringify(existingImages)); formData.append("primaryImageIndex", String(primaryIndex)); + formData.append("is_pinterest", String(isPinterest)); try { await request("PATCH", `/shop-products/${listingId}`, formData); @@ -172,6 +178,34 @@ function ProductImagesPage() { onChange={handleSelect} /> + + setIsPinterest((v) => !v)} + className="mt-4 flex w-full max-w-sm items-center gap-2.5 rounded-2xl border border-neutral-200 bg-neutral-50 px-3.5 py-3 text-right dark:border-neutral-700 dark:bg-neutral-900" + > + + {isPinterest ? ( + + ) : null} + + + + + {t("shops.pinterestProductLabel")} + + + {t("shops.pinterestProductHint")} + + + {t("shops.discoverTitle")} + + + setPinterestOnly(false)} + className={cn( + "rounded-2xl border px-3.5 py-2 text-sm font-medium transition", + !pinterestOnly + ? "border-pink-400 bg-pink-50 text-pink-600 dark:bg-pink-950/30" + : "border-neutral-200 text-neutral-700 dark:border-neutral-700 dark:text-neutral-300" + )} + > + {t("common.all")} + + setPinterestOnly(true)} + className={cn( + "flex items-center gap-1.5 rounded-2xl border px-3.5 py-2 text-sm font-medium transition", + pinterestOnly + ? "border-[#E60023] bg-[#E60023]/10 text-[#E60023]" + : "border-neutral-200 text-neutral-700 dark:border-neutral-700 dark:text-neutral-300" + )} + > + + {t("shops.pinterestFilter")} + + + + {listing.is_pinterest && ( + + + + )} handleToggleFavorite(listing._id)} diff --git a/src/locales/en/common.json b/src/locales/en/common.json index ba8adde..cbf10f4 100644 --- a/src/locales/en/common.json +++ b/src/locales/en/common.json @@ -3000,6 +3000,9 @@ "comparisonTitle": "Compare shop prices", "noListingsForProduct": "No shops found for this product", "discoverTitle": "Shops", + "pinterestFilter": "Pinterest", + "pinterestProductLabel": "Pinterest product", + "pinterestProductHint": "This product will show up under the shop's Pinterest filter", "quantityLabel": "Quantity", "buyNow": "Continue purchase", "addressRequiredHint": "You need to set your address and location to place an order", diff --git a/src/locales/fa/common.json b/src/locales/fa/common.json index 2847b35..6ab2c3e 100644 --- a/src/locales/fa/common.json +++ b/src/locales/fa/common.json @@ -2999,6 +2999,9 @@ "comparisonTitle": "مقایسه قیمت فروشگاهها", "noListingsForProduct": "فروشگاهی برای این کالا یافت نشد", "discoverTitle": "فروشگاهها", + "pinterestFilter": "پینترستی", + "pinterestProductLabel": "محصول پینترستی", + "pinterestProductHint": "این کالا در فیلتر پینترستی فروشگاه نمایش داده میشود", "quantityLabel": "تعداد", "buyNow": "ادامه خرید", "addressRequiredHint": "برای ثبت سفارش نیاز به ثبت آدرس و لوکیشن میباشید", diff --git a/src/types/types.ts b/src/types/types.ts index 0d9e317..93bcc38 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -139,6 +139,7 @@ export interface IShopProductListing { isTaggedPost?: boolean; postId?: string; postCaption?: string | null; + is_pinterest?: boolean; } export interface LastPost { _id: string;