push to set suprize in card .
parent
66206df6b3
commit
114731f30a
|
@ -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 = () => {
|
|||
<Navbar theme={1} />
|
||||
|
||||
<div className="xs:w-full lg:w-4/12 mx-auto">
|
||||
<div className="text-right flex rtl justify-between border-t-[1px] border-gray-200 my-3 px-4 ">
|
||||
<div className="text-right flex rtl justify-between p-2 mt-2 ">
|
||||
<p className="mb-0 text-sm font-semibold py-4">
|
||||
محصولات انتخاب شده
|
||||
</p>
|
||||
|
@ -55,8 +57,56 @@ const CartData = () => {
|
|||
<CardCart key={index} data={e} />
|
||||
))}
|
||||
|
||||
<div className="my-5">
|
||||
<div className="text-right px-4">
|
||||
{" "}
|
||||
<p className="mb-0 text-sm py-4">
|
||||
سبد خریدتو کامل کن{" "}
|
||||
<strong className="text-red-600">(فقط امروز)</strong>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Swiper
|
||||
spaceBetween={50}
|
||||
slidesPerView={6.2}
|
||||
// onSlideChange={() => 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) => (
|
||||
<SwiperSlide key={index}>
|
||||
<CardNormal data={e} priority />
|
||||
</SwiperSlide>
|
||||
))}
|
||||
</Swiper>
|
||||
</div>
|
||||
|
||||
{/* <p className="mb-0 text-[12px] text-right text-gray-500">
|
||||
برای رسیدن به الماس باید
|
||||
<strong> پنح خرید دیگر </strong>
|
||||
انجام دهید
|
||||
</p>
|
||||
<div className="w-3/12 bg-green-600 p-2 rounded-full mt-2 ml-auto text-center"></div> */}
|
||||
|
||||
<div className="">
|
||||
<div className="text-right flex rtl justify-between border-y-[1px] border-gray-200 my-3 px-4 ">
|
||||
<div className="text-right flex rtl justify-between border-b-[1px] border-gray-200 my-3 px-4 ">
|
||||
<p className="mb-0 text-sm font-medium py-4">حساب نهایی</p>
|
||||
|
||||
{/* <div className="bg-primary-200 w-fit h-fit relative my-3 p-1 rounded-lg">
|
||||
|
|
|
@ -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 (
|
||||
<>
|
||||
<div className=" pb-20">
|
||||
|
@ -255,7 +263,7 @@ const CheckoutData = () => {
|
|||
</div>
|
||||
|
||||
<div>
|
||||
{shippingData?.map((e, index) => (
|
||||
{filteredShippingData?.map((e, index) => (
|
||||
<div
|
||||
onClick={() => handleShippingID(index)}
|
||||
className={`flex rtl justify-between cursor-pointer mx-2 ${
|
||||
|
@ -291,15 +299,20 @@ const CheckoutData = () => {
|
|||
<h3 className="mb-0 text-sm text-right font-medium text-primary-500 ">
|
||||
{e.name}{" "}
|
||||
</h3>
|
||||
<p className="mb-0 text-[12px] text-gray-500">
|
||||
{" "}
|
||||
هزینه ارسال
|
||||
<PersianNumber
|
||||
number={(e.deliveryCost / 10)?.toLocaleString()}
|
||||
style={"text-gray-600 mx-1"}
|
||||
/>
|
||||
هزار تومان
|
||||
</p>
|
||||
{e.name == "ارسال رایگان" ? (
|
||||
<p className="mb-0 text-[12px] text-gray-500">
|
||||
ارسال با پست پیشتاز
|
||||
</p>
|
||||
) : (
|
||||
<p className="mb-0 text-[12px] text-gray-500">
|
||||
هزینه ارسال
|
||||
<PersianNumber
|
||||
number={(e.deliveryCost / 10)?.toLocaleString()}
|
||||
style={"text-gray-600 mx-1"}
|
||||
/>
|
||||
هزار تومان
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import PersianNumber from "plugins/PersianNumber";
|
|||
|
||||
const NavBarDownCart = ({ calculateTotalCost, event, permissionGoPay }) => {
|
||||
return (
|
||||
<div className="relative ">
|
||||
<div className="relative z-50 ">
|
||||
<div className="fixed w-full bottom-[0] p-4 bg-body-100 border-t-[1px] border-gray-200 flex rtl">
|
||||
{/* <Link href={"/cart/checkout"} className="w-full"> */}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 (
|
||||
<>
|
||||
<CartData />
|
||||
<CartData data={products.products} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -90,7 +90,7 @@ const Page = () => {
|
|||
تاریخ سفارش
|
||||
</th>
|
||||
<th className="px-4 text-right text-xs font-semibold text-gray-600 uppercase border-b py-5">
|
||||
تاریخ تحویل
|
||||
کد سفارش{" "}
|
||||
</th>
|
||||
<th className="px-4 text-right text-xs font-semibold text-gray-600 uppercase border-b py-5">
|
||||
مرحله سفارش
|
||||
|
@ -119,7 +119,9 @@ const Page = () => {
|
|||
.format("jYYYY/jM/jD")}
|
||||
/>
|
||||
</td>
|
||||
<td className="px-4 py-3">-</td>
|
||||
<td className="px-4 py-3 font-bold">
|
||||
{e.factorCode}
|
||||
</td>
|
||||
<td
|
||||
className={`px-4 py-3 ${
|
||||
e.orderStatus == 500
|
||||
|
|
Loading…
Reference in New Issue