From 114731f30a5787a2f837e64a19f3b4f7aad90764 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: Sun, 30 Mar 2025 15:21:44 +0330 Subject: [PATCH] push to set suprize in card . --- components/AppsComponent/CartData/page.jsx | 56 ++++++++++++++++++- .../AppsComponent/CheckoutData/page.jsx | 35 ++++++++---- .../Carts/component/NavBarDownCart/page.jsx | 2 +- .../Navbar/SideBarNavBarMobile/page.jsx | 4 +- components/Navbar/page.jsx | 5 +- src/app/cart/page.jsx | 22 +++++++- src/app/profile/orders/page.jsx | 6 +- 7 files changed, 109 insertions(+), 21 deletions(-) diff --git a/components/AppsComponent/CartData/page.jsx b/components/AppsComponent/CartData/page.jsx index 41299ba..f8da37d 100644 --- a/components/AppsComponent/CartData/page.jsx +++ b/components/AppsComponent/CartData/page.jsx @@ -1,5 +1,6 @@ "use client"; import CardCart from "@comp/Cards/CardCart/page"; +import CardNormal from "@comp/Cards/CardNormal/page"; import NavBarDownCart from "@comp/Carts/component/NavBarDownCart/page"; import Navbar from "@comp/Navbar/page"; import AppContext from "@ctx/AppContext"; @@ -8,8 +9,9 @@ import Chapar from "plugins/Chapar"; import PersianNumber from "plugins/PersianNumber"; import { useContext, useEffect } from "react"; import { toast } from "react-toastify"; +import { Swiper, SwiperSlide } from "swiper/react"; -const CartData = () => { +const CartData = ({ data }) => { const CTX = useContext(AppContext); const router = useRouter(); const cart = CTX.state.cart; @@ -37,7 +39,7 @@ const CartData = () => {
-
+

محصولات انتخاب شده

@@ -55,8 +57,56 @@ const CartData = () => { ))} +
+
+ {" "} +

+ سبد خریدتو کامل کن{" "} + (فقط امروز) +

+
+ + console.log("slide change")} + className="rtl relative" + // dir="rtl" + breakpoints={{ + 320: { + slidesPerView: 1.8, + }, + 480: { + slidesPerView: 2.1, + }, + 768: { + slidesPerView: 2.2, + }, + 1024: { + slidesPerView: 3.3, + }, + 1440: { + slidesPerView: 2.8, + }, + }} + > + {data?.map((e, index) => ( + + + + ))} + +
+ + {/*

+ برای رسیدن به الماس باید + پنح خرید دیگر + انجام دهید +

+
*/} +
-
+

حساب نهایی

{/*
diff --git a/components/AppsComponent/CheckoutData/page.jsx b/components/AppsComponent/CheckoutData/page.jsx index d7f86dc..7be3fdb 100644 --- a/components/AppsComponent/CheckoutData/page.jsx +++ b/components/AppsComponent/CheckoutData/page.jsx @@ -35,7 +35,6 @@ const CheckoutData = () => { const data = await Chapar.get( `${process.env.NEXT_PUBLIC_API_URL}/warehouse/shipping?page=0` ); - setShippingData(data); } catch ({ error, status }) { toast.error(`${error?.response?.data?.message}`, { @@ -118,6 +117,13 @@ const CheckoutData = () => { } }; + const filteredShippingData = shippingData?.filter((item) => { + if (item.name === "ارسال رایگان" && checkOutData.totalPrice <= 5000000) { + return false; + } + return true; + }); + useEffect(() => { if (shippingData.length <= 0) { GetShippingData(); @@ -138,6 +144,8 @@ const CheckoutData = () => { setPermissionGoPay(false); }, []); + console.log("checkOutData", checkOutData); + return ( <>
@@ -255,7 +263,7 @@ const CheckoutData = () => {
- {shippingData?.map((e, index) => ( + {filteredShippingData?.map((e, index) => (
handleShippingID(index)} className={`flex rtl justify-between cursor-pointer mx-2 ${ @@ -291,15 +299,20 @@ const CheckoutData = () => {

{e.name}{" "}

-

- {" "} - هزینه ارسال - - هزار تومان -

+ {e.name == "ارسال رایگان" ? ( +

+ ارسال با پست پیشتاز +

+ ) : ( +

+ هزینه ارسال + + هزار تومان +

+ )}
diff --git a/components/Carts/component/NavBarDownCart/page.jsx b/components/Carts/component/NavBarDownCart/page.jsx index 2eb7e6f..9661bda 100644 --- a/components/Carts/component/NavBarDownCart/page.jsx +++ b/components/Carts/component/NavBarDownCart/page.jsx @@ -3,7 +3,7 @@ import PersianNumber from "plugins/PersianNumber"; const NavBarDownCart = ({ calculateTotalCost, event, permissionGoPay }) => { return ( -
+
{/* */} diff --git a/components/Navbar/SideBarNavBarMobile/page.jsx b/components/Navbar/SideBarNavBarMobile/page.jsx index 5658919..a33cc8d 100644 --- a/components/Navbar/SideBarNavBarMobile/page.jsx +++ b/components/Navbar/SideBarNavBarMobile/page.jsx @@ -13,7 +13,9 @@ const SideBarNavBarMobile = () => { const [firstChild, setFirstChild] = useState([]); const [firstChildIndex, setFirstChildIndex] = useState(-1); - const dataNav = CTX.state.navData; + const dataNav = CTX?.state?.navData?.filter( + (item) => item.name !== "بهداشت خانه و آشپرخانه" + ); const isSearched = CTX.state.isSearched; const searchResultCategoryData = CTX.state.searchResultData.categories; const searchResultProductData = CTX.state.searchResultData.products; diff --git a/components/Navbar/page.jsx b/components/Navbar/page.jsx index 2f24cc3..8f8fc14 100644 --- a/components/Navbar/page.jsx +++ b/components/Navbar/page.jsx @@ -21,7 +21,10 @@ const Navbar = ({ theme }) => { const CTX = useContext(AppContext); const router = useRouter(); - const dataNav = CTX.state.navData; + + const dataNav = CTX?.state?.navData?.filter( + (item) => item.name !== "بهداشت خانه و آشپرخانه" + ); const profile = CTX.state.profile; const cart = CTX.state.cart; const searchResultCategoryData = CTX.state.searchResultData.categories; diff --git a/src/app/cart/page.jsx b/src/app/cart/page.jsx index 72bae1b..523f4f5 100644 --- a/src/app/cart/page.jsx +++ b/src/app/cart/page.jsx @@ -4,10 +4,28 @@ import React from "react"; export const metadata = { title: "سبد خرید", }; -const page = () => { + +const fetchSpecialOffer = async (categoryId) => { + try { + const res = await fetch( + `${process.env.NEXT_PUBLIC_API_URL}/product?page=0&specialOffer=true` + ); + const specialOffer = await res.json(); + + console.log("===================", specialOffer.products); + return specialOffer; + } catch (error) { + console.error("Error fetching fetchSpecialOffer:", error); + return []; + } +}; + +const page = async () => { + const products = await fetchSpecialOffer(); + return ( <> - + ); }; diff --git a/src/app/profile/orders/page.jsx b/src/app/profile/orders/page.jsx index 97d0413..5e5ca9a 100644 --- a/src/app/profile/orders/page.jsx +++ b/src/app/profile/orders/page.jsx @@ -90,7 +90,7 @@ const Page = () => { تاریخ سفارش - تاریخ تحویل + کد سفارش{" "} مرحله سفارش @@ -119,7 +119,9 @@ const Page = () => { .format("jYYYY/jM/jD")} /> - - + + {e.factorCode} +