master
حسین معصومی پور 2024-04-16 02:04:28 +03:30
parent edb6a19de0
commit df200fdb51
8 changed files with 77 additions and 32 deletions

View File

@ -6,4 +6,4 @@ NEXT_PUBLIC_PUBLIC_URL=https://api.vesmeh.com
NEXT_PUBLIC_API_URL=https://api.vesmeh.com/api
NEXT_PUBLIC_STORAGE_URL=http://storage.vesmeh.com
STORAGE_URL=http://storage.vesmeh.com
NEXT_PUBLIC_PACKAGE_VERSION=0.2.9
NEXT_PUBLIC_PACKAGE_VERSION=0.3.0

View File

@ -111,9 +111,7 @@ const CheckoutData = () => {
GetShippingData();
}
if (CTX.state.addressData <= 0) {
CTX.fetchAddressUser();
}
CTX.fetchAddressUser();
}, [checkOutData]);
useEffect(() => {

View File

@ -53,7 +53,7 @@ const BetweenSexualSection = () => {
</div>
</div>
<h3 className="xs:text-lg lg:text-xl ">
بهداشت مصرفی و روزانه بانوان
بهداشت روزانه بانوان
</h3>
<p className="px-3 py-1 mt-2 mb-0 text-sm rounded-full w-fit bg-sky-200">
@ -79,7 +79,7 @@ const BetweenSexualSection = () => {
</div>
</div>
<h3 className="xs:text-lg lg:text-xl ">
بهداشت مصرفی و روزانه آقایان
بهداشت روزانه آقایان
</h3>
<p className="px-3 py-1 mt-2 mb-0 text-sm rounded-full w-fit bg-sky-200">

View File

@ -5,25 +5,43 @@ import Link from "next/link";
import PersianNumber from "plugins/PersianNumber";
import { useContext, useState } from "react";
const CartNavbar = (props) => {
const CartNavbar = ({ isScrolled }) => {
const CTX = useContext(AppContext);
const cart = CTX.state.cart;
const [smallBasket, setSmallBasket] = useState(false);
return (
<div className="mr-2">
<div
className={` ${
isScrolled ? " fixed w-fit !z-[100] mt-[-40px] mr-[30px] " : "mr-2"
}`}
>
<div
className="bg-secondary-600 py-2 px-5 rounded-xl text-sm flex cursor-pointer "
onMouseEnter={() => setSmallBasket(true)}
onClick={() => setSmallBasket(false)}
className={`bg-secondary-600 rounded-xl text-sm flex cursor-pointer px-5 ${
isScrolled ? "p-1" : "py-2"
} `}
onClick={() => setSmallBasket(!smallBasket)}
>
<p className="mb-0 text-white">سبد خرید</p>
</div>
<div className="flex justify-end">
<div className="absolute mt-[-50px] mr-[3px]">
<div className="bg-white border-[1px] w-[25px] h-[25px] rounded-full text-center">
<PersianNumber number={cart?.length} style={"!text-sm"} />{" "}
<div
className={`absolute mr-[3px] ${
isScrolled ? "mt-[-40px]" : "mt-[-50px]"
}`}
>
<div
className={`bg-white border-[1px] rounded-full text-center ${
isScrolled ? "w-[20px] h-[20px]" : "w-[25px] h-[25px] "
}`}
>
<PersianNumber
number={cart?.length}
style={` ${
isScrolled ? "!text-[10px] relative top-[-3px]" : "!text-sm"
}`}
/>{" "}
</div>
</div>
</div>
@ -33,8 +51,6 @@ const CartNavbar = (props) => {
className={`relative !z-[100] tr03 ${
smallBasket ? "opacity-100" : "opacity-0"
} `}
onMouseEnter={() => setSmallBasket(true)}
onMouseLeave={() => setSmallBasket(false)}
>
<div className="absolute w-[400px] bg-white border-[3px] border-gray-100 rounded-xl mt-2 max-h-[450px] overflow-auto mr-[-310px] scroll-1">
<div className="text-center p-3">

View File

@ -82,7 +82,7 @@ const Navbar = ({ theme }) => {
</Link>
</div>
<div className="flex rtl py-5 ">
<div className={`flex rtl py-5 `}>
{profile?.length <= 0 ? (
<div className="flex">
<Link href={"/login"}>
@ -168,7 +168,7 @@ const Navbar = ({ theme }) => {
</div>
)}
<CartNavbar />
<CartNavbar isScrolled={isScrolled} />
</div>
</div>
@ -194,7 +194,7 @@ const Navbar = ({ theme }) => {
<div className="flex rtl">
{dataNav?.map((e, index) => (
<p
className={`mb-0 pb-4 px-2 tr03 cursor-pointer ${
className={`mb-0 pt-2 pb-3 px-2 tr03 cursor-pointer ${
navItemHover == index
? " border-y-[5px] border-b-primary-800 border-t-transparent text-primary-900"
: "border-y-[5px] border-y-transparent text-black"
@ -210,7 +210,7 @@ const Navbar = ({ theme }) => {
))}
</div>
<div
{/* <div
onClick={() => {
const element = document.getElementById("offer");
if (element) {
@ -222,10 +222,10 @@ const Navbar = ({ theme }) => {
}
}}
>
<div className="bg-red-600 mb-4 px-4 h-fit mt-1 mr-2 rounded-full cursor-pointer">
<div className="bg-red-600 mb-4 px-4 mt-3 h-fit mr-2 rounded-full cursor-pointer">
<p className="mb-0 text-white">بمب امروز </p>
</div>
</div>
</div> */}
</div>
<div
@ -316,13 +316,13 @@ const Navbar = ({ theme }) => {
</ul>
</div>
<div className=" w-[230px]">
<div className="absolute left-5">
<div className=" w-[250px] ">
<div className="absolute left-5 ">
<Image
src={`${process.env.NEXT_PUBLIC_STORAGE_URL}/${dataNav[navItemHover]?.mainImage}`}
className=" !w-[230px] rounded-xl "
width={300}
height={300}
className=" !w-[250px] h-[250px] rounded-xl object-cover "
width={600}
height={600}
alt={`${dataNav[navItemHover]?.name} وسمه`}
/>
</div>
@ -474,10 +474,10 @@ const Navbar = ({ theme }) => {
</div>
<div
className="mx-2 mt-2"
className="mx-2 "
onClick={() => CTX.setBottomSheetCartOpen(true)}
>
<div className="absolute mt-[-16px] mr-[6px] ">
{/* <div className="absolute mt-[-16px] mr-[6px] ">
{cart?.length > 0 && (
<div className="">
<PersianNumber
@ -518,7 +518,30 @@ const Navbar = ({ theme }) => {
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</svg> */}
<div className="absolute mt-[-8px] mr-[6px] bg-white w-[15px] h-[15px] rounded-full text-center ">
{cart?.length > 0 && (
<div className="">
<PersianNumber
number={cart?.length}
style={`!text-[10px] text-primary-900 font-bold text-center relative top-[-5px] ${
theme == 1
? "text-primary-500"
: isScrolled
? "text-primary-500"
: "text-white"
}`}
/>
</div>
)}
</div>
<div
className="bg-secondary-600 py-2 px-3 rounded-xl text-sm flex cursor-pointer "
onClick={() => CTX.setBottomSheetCartOpen(true)}
>
<p className="mb-0 text-white text-[12px]">سبد خرید</p>
</div>
</div>
</div>
</div>

View File

@ -7,26 +7,34 @@ import { BottomSheet } from "react-spring-bottom-sheet";
import { toast } from "react-toastify";
const BottomSheetDiscount = ({ orderId }) => {
// const [item, setItem] = useState();
const CTX = useContext(AppContext);
const [discountCode, setDiscountCode] = useState(null);
const body = { orderId, discountCode };
// Function to handle discount operation asynchronously
const handleDiscount = async () => {
// Retrieve token from localStorage asynchronously
const token = localStorage.getItem("token");
try {
// Send a POST request to the API endpoint to apply discount
const data = await Chapar.post(
`${process.env.NEXT_PUBLIC_API_URL}/order/bag/discount/${orderId}?discountCode=${discountCode}`,
{
// Include the token in the Authorization header
headers: {
Authorization: localStorage.getItem("token"),
Authorization: token,
},
}
);
// Update the checkout data with the response
CTX.setCheckOutData(data);
// Close the bottom sheet for discount
CTX.setBottomSheetDiscountOpen(false);
} catch ({ error, status }) {
// If there's an error, display an error message using toast
toast.error(`${error?.response?.data?.message}`, {
position: "bottom-right",
closeOnClick: true,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 477 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 KiB

After

Width:  |  Height:  |  Size: 52 KiB