From 101d650a2e4c6a32a34359a9e64503b1f861abd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D8=AD=D8=B3=DB=8C=D9=86=20=D9=85=D8=B9=D8=B5=D9=88=D9=85?= =?UTF-8?q?=DB=8C=20=D9=BE=D9=88=D8=B1?= Date: Sat, 2 Nov 2024 19:38:46 +0330 Subject: [PATCH] order bag history --- .../AppsComponent/CategoriesData/page.jsx | 2 + .../LandingPage/CategoriesHero/page.jsx | 16 +- components/Navbar/page.jsx | 37 ++-- plugins/bottomSheet/BottomSheetSeeOrder.jsx | 168 +++++++++--------- src/app/categories/[...id]/page.jsx | 34 +++- src/app/{ => login}/faq/page.jsx | 0 .../profile/component/SideBarProfile/page.jsx | 2 +- 7 files changed, 145 insertions(+), 114 deletions(-) rename src/app/{ => login}/faq/page.jsx (100%) diff --git a/components/AppsComponent/CategoriesData/page.jsx b/components/AppsComponent/CategoriesData/page.jsx index 2525827..cab50b6 100644 --- a/components/AppsComponent/CategoriesData/page.jsx +++ b/components/AppsComponent/CategoriesData/page.jsx @@ -16,6 +16,8 @@ export default function CategoriesData({ params, products }) { const CTX = useContext(AppContext); const searchParams = useSearchParams(); + console.log("products :products", products); + useEffect(() => { if ( Number(searchParams.get("page")) === 0 || diff --git a/components/LandingPage/CategoriesHero/page.jsx b/components/LandingPage/CategoriesHero/page.jsx index bff80ac..4bafbde 100644 --- a/components/LandingPage/CategoriesHero/page.jsx +++ b/components/LandingPage/CategoriesHero/page.jsx @@ -54,10 +54,20 @@ const CategoriesHero = () => { ]; return ( <> -
+
{categories.map((category, index) => ( - -
+ +
{/* Image as a background */}
{ setSearchValue(event.target.value); }; + console.log(dataNav); + return ( <> {isDesktop && ( @@ -309,20 +311,25 @@ const Navbar = ({ theme }) => { >
{dataNav?.map((e, index) => ( -

+

handleItemNavber(index)} - onMouseLeave={() => setNavItemHover(null)} - key={index} - > - {e.name}{" "} -

+ onMouseEnter={() => handleItemNavber(index)} + onMouseLeave={() => setNavItemHover(null)} + key={index} + > + {e.name}{" "} +

+ ))}
@@ -413,9 +420,9 @@ const Navbar = ({ theme }) => { {e.children.map((child, index) => (

{ > {/* {bag && bag.length > 0 && ( */}

- {bag.orderProducts?.map((e) => ( -
-

- - محصول موجود در سبد -

+
+

+ + محصول موجود در سبد +

- {/*
*/} -
- {bag.orderProducts.map((e, index) => ( -
- -
- {!!e.mainImage ? ( + {/*
*/} +
+ {bag?.orderProducts?.map((e, index) => ( +
+ +
+ {!!e.mainImage ? ( + {`${e.productName} + ) : ( +
{`${e.productName} +
+ )} +
+ +
+ +

+ {e?.productName} +

+ + +
+
+

+ + عدد +

+
+
+ {e?.hasDiscount ? ( +
+

+ + + +

+
+ {" "} +

+ +

+ تومان +
+
) : ( -
- وسمه +
+ {" "} +

+ +

+ تومان
)}
- -
- -

- {e?.productName} -

- - -
-
-

- - عدد -

-
-
- {e?.hasDiscount ? ( -
-

- - - -

-
- {" "} -

- -

- تومان -
-
- ) : ( -
- {" "} -

- -

- تومان -
- )} -
-
- ))} -
+
+ ))}
- ))} +
{/* )} */} diff --git a/src/app/categories/[...id]/page.jsx b/src/app/categories/[...id]/page.jsx index 4c37816..3d8c6e9 100644 --- a/src/app/categories/[...id]/page.jsx +++ b/src/app/categories/[...id]/page.jsx @@ -3,10 +3,14 @@ import React from "react"; export async function generateMetadata({ params }) { const decodedName = decodeURIComponent(params.id[1]); + const products = await fetchProducts(params?.["id"]?.[0]); return { title: decodedName, - description: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`, + description: + products.seo.description != "" + ? products.seo.description + : ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`, metadataBase: new URL( `https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}` ), @@ -22,13 +26,19 @@ export async function generateMetadata({ params }) { }, openGraph: { title: decodedName, - description: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`, + description: + products.seo.description != "" + ? products.seo.description + : ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`, url: `https://www.vesmeh.com/categories/${params.id[0]}/${decodedName}`, type: "website", }, twitter: { site: "@vesmehstore", - description: ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`, + description: + products.seo.description != "" + ? products.seo.description + : ` خرید ${decodedName}| برندهای متنوع با پایین ترین قیمت | فروشگاه اینترنتی وسمه`, title: decodedName, creator: "@vesmehstore", }, @@ -42,7 +52,8 @@ export async function generateMetadata({ params }) { // minPrice // maxPrice // sortBy -const fetchProducts = async (categoryId, searchParams) => { + +const fetchProducts = async (categoryId, searchParams = {}) => { const { brandIds: brandIdsString, isActive, @@ -53,19 +64,23 @@ const fetchProducts = async (categoryId, searchParams) => { const query = { ...(categoryId != 0 ? { categoryId } : {}), page: 0, - ...(!!isActive ? { isActive: !!isActive } : {}), - ...(!!specialOffer ? { specialOffer: !!specialOffer } : {}), + ...(typeof isActive !== "undefined" ? { isActive: !!isActive } : {}), + ...(typeof specialOffer !== "undefined" + ? { specialOffer: !!specialOffer } + : {}), ...params, }; const brandIds = brandIdsString?.split(",") ?? []; const brandIdsQuery = - brandIds?.length > 0 ? `&brandIds=${brandIds?.join("&brandIds=")}` : ""; + brandIds.length > 0 + ? `&${brandIds.map((id) => `brandIds=${id}`).join("&")}` + : ""; try { const res = await fetch( `${process.env.NEXT_PUBLIC_API_URL}/product?` + - new URLSearchParams({ ...query }) + + new URLSearchParams(query).toString() + brandIdsQuery, { cache: "no-cache", @@ -74,9 +89,10 @@ const fetchProducts = async (categoryId, searchParams) => { if (!res.ok) return []; const products = await res.json(); - console.log("products++++++++++++++++++++++++++++++++", products); + console.log("Fetched products:", products); return products; } catch (error) { + console.error("Error fetching products:", error); return []; } }; diff --git a/src/app/faq/page.jsx b/src/app/login/faq/page.jsx similarity index 100% rename from src/app/faq/page.jsx rename to src/app/login/faq/page.jsx diff --git a/src/app/profile/component/SideBarProfile/page.jsx b/src/app/profile/component/SideBarProfile/page.jsx index d858f38..9cc2dbf 100644 --- a/src/app/profile/component/SideBarProfile/page.jsx +++ b/src/app/profile/component/SideBarProfile/page.jsx @@ -41,7 +41,7 @@ const SideBarProfile = () => {

- پیگیری سغارشات + پیگیری سفارشات