diff --git a/.env.production b/.env.production index e702129..d1be7fe 100644 --- a/.env.production +++ b/.env.production @@ -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=1.0.0.1 \ No newline at end of file +NEXT_PUBLIC_PACKAGE_VERSION=1.0.2.4 \ No newline at end of file diff --git a/Dockerfile.x b/Dockerfile.x index 3c72cc0..cc86b82 100644 --- a/Dockerfile.x +++ b/Dockerfile.x @@ -15,4 +15,5 @@ CMD ["node_modules/.bin/next", "start"] -# docker build -f Dockerfile.x -t registry.vnfco.ir/netinashop/vesmeh:0.32.31 . \ No newline at end of file +# docker build -f Dockerfile.x -t registry.vnfco.ir/netinashop/vesmeh:0.32.31 . +# \ No newline at end of file diff --git a/components/AppsComponent/CheckoutData/page.jsx b/components/AppsComponent/CheckoutData/page.jsx index 2b6f19e..29d7d23 100644 --- a/components/AppsComponent/CheckoutData/page.jsx +++ b/components/AppsComponent/CheckoutData/page.jsx @@ -102,6 +102,22 @@ const CheckoutData = () => { } }; + const deleteDiscount = async () => { + 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/${checkOutData?.id}` + ); + CTX.setCheckOutData(data); + } 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, + }); + } + }; + useEffect(() => { if (shippingData.length <= 0) { GetShippingData(); @@ -122,6 +138,8 @@ const CheckoutData = () => { setPermissionGoPay(false); }, []); + console.log("checkOutData", checkOutData); + return ( <>
@@ -343,30 +361,57 @@ const CheckoutData = () => { >
- - - + {checkOutData?.discountCode == "" ? ( + + + + ) : ( + + + + + )}

- افزودن کد تخفیف{" "} + {checkOutData?.discountCode == "" + ? "افزودن کد تخفیف" + : "تخفیف ثبت شد"}

- کد تخفیف خود را وارد کنید + {checkOutData?.discountCode == "" + ? "کد تخفیف خود را وارد کنید" + : `تخفیف با کد ${checkOutData?.discountCode} ثبت شده است`}

@@ -376,10 +421,27 @@ const CheckoutData = () => { +
) : ( -
-

- کد تخفیف ثبت شد{" "} -

+
deleteDiscount()} + > +
+ + + +
)}
diff --git a/components/AppsComponent/ProductData/page.jsx b/components/AppsComponent/ProductData/page.jsx index dca2197..e8b844e 100644 --- a/components/AppsComponent/ProductData/page.jsx +++ b/components/AppsComponent/ProductData/page.jsx @@ -252,17 +252,7 @@ const ProductData = ({ params, data }) => {

مشخصات

-
{ - setProductBarDetail(1); - scrollToSection("section1"); - }} - > -

روش استفاده

-
+
{
-
-

- روش استفاده -

-
-
-
- چیزی یافت نشد -
-
-
{" "} -
-

نقد و برسی{" "} diff --git a/components/AppsComponent/RootData/page.jsx b/components/AppsComponent/RootData/page.jsx index e85e035..72a6742 100644 --- a/components/AppsComponent/RootData/page.jsx +++ b/components/AppsComponent/RootData/page.jsx @@ -56,6 +56,7 @@ const RootData = ({ children }) => { const [specialOfferData, setSpecialOfferData] = useState([]); const [cosmeticData, setCosmeticData] = useState([]); const [HomeCosmeticData, setHomeCosmeticData] = useState([]); + const [sunCreamData, setSunCreamData] = useState([]); const [isChecked, setIsChecked] = useState(false); const [selectedBrands, setSelectedBrands] = useState([]); @@ -352,13 +353,7 @@ const RootData = ({ children }) => { const data = await Chapar.post( `${process.env.NEXT_PUBLIC_API_URL}/order/bag/submit`, - JSON.stringify(productsToSend), - - { - headers: { - Authorization: localStorage.getItem("token"), - }, - } + JSON.stringify(productsToSend) ); setCheckOutData(data); @@ -459,6 +454,14 @@ const RootData = ({ children }) => { setHomeCosmeticData(HomeCosmetic); }; + const fetchSunCream = async () => { + const res = await fetch( + `${process.env.NEXT_PUBLIC_API_URL}/product?page=0&categoryId=df80c111-087f-4b2d-bc32-c44d660e76f2` + ); + const sunCream = await res.json(); + setSunCreamData(sunCream); + }; + useEffect(() => { const storedCart = localStorage.getItem("cart"); const token = localStorage.getItem("token"); @@ -537,6 +540,7 @@ const RootData = ({ children }) => { cosmeticData, HomeCosmeticData, specialOfferData, + sunCreamData, }, setCart, setProducts, @@ -573,6 +577,7 @@ const RootData = ({ children }) => { fetchProducts, setCloseNavbar, setAddressData, + setSunCreamData, fetchAddressUser, fetchOrderBagCheck, fetchOrderUser, @@ -587,6 +592,7 @@ const RootData = ({ children }) => { fetchHomeCosmetic, fetchCosmetic, fetchSpecialOffer, + fetchSunCream, }} > {children} diff --git a/components/Footer/page.jsx b/components/Footer/page.jsx index 564e20b..27fca67 100644 --- a/components/Footer/page.jsx +++ b/components/Footer/page.jsx @@ -184,14 +184,14 @@ const Footer = () => {

diff --git a/components/LandingPage/BetweenSexualSection/page.jsx b/components/LandingPage/BetweenSexualSection/page.jsx index 383325d..cb74c38 100644 --- a/components/LandingPage/BetweenSexualSection/page.jsx +++ b/components/LandingPage/BetweenSexualSection/page.jsx @@ -1,8 +1,10 @@ import Image from "next/image"; import Link from "next/link"; import between from "../../../public/images/between.jpg"; -import between1 from "../../../public/images/between1.png"; -import between2 from "../../../public/images/between2.png"; +import w1 from "@img/w1.jpg"; +import w2 from "@img/w2.jpg"; +import w3 from "@img/w3.jpg"; +import PersianNumber from "plugins/PersianNumber"; const BetweenSexualSection = () => { return ( @@ -19,8 +21,8 @@ const BetweenSexualSection = () => { -
-
+
+ {/*

لوازم بهداشتی وسمه

@@ -28,66 +30,82 @@ const BetweenSexualSection = () => {

به صرفه زیبا شـــــــــــــو

+
*/} + +
+
+ +
+ +
+ +
+

+ شامپو بدن بانوان{" "} +

+ +
+

+ تصمین بهترین قیمت +

+
+
+ +
+
+ +
+ +
+ +
+

نرم کننده مو

+ +
+

+ تصمین بهترین قیمت +

+
+
+ +
+
+ +
+ +
+ +
+

+ ژل بهداشتی بانوان و آقایان{" "} +

+ +
+

+ تصمین بهترین قیمت +

+
+
+ +
{/*

لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است

*/} - -
- -
-
-
-
- لوازم بهداشت بانوان وسمه -
-
-
-

- بهداشت روزانه بانوان -

- -

- شروع خرید{" "} -

-
- - - -
-
-
-
- لوازم بهداشت آقایان وسمه -
-
-
-

- بهداشت روزانه آقایان -

- -

- شروع خرید{" "} -

-
- -
diff --git a/components/LandingPage/SunCreamSection/page.jsx b/components/LandingPage/SunCreamSection/page.jsx new file mode 100644 index 0000000..e62aa2e --- /dev/null +++ b/components/LandingPage/SunCreamSection/page.jsx @@ -0,0 +1,80 @@ +import CardNormal from "@comp/Cards/CardNormal/page"; +import Link from "next/link"; +import { Swiper, SwiperSlide } from "swiper/react"; + +const SunCreamSection = ({ data }) => { + return ( +
+
+
+ + + +
+
+ +
+
+
+

+ کرم ضد آفتاب{" "} +

+
+
+ console.log("slide change")} + className="rtl relative mt-5" + // dir="rtl" + breakpoints={{ + 320: { + slidesPerView: 1.3, + }, + 480: { + slidesPerView: 2, + }, + 768: { + slidesPerView: 3, + }, + 1024: { + slidesPerView: 4.5, + }, + 1440: { + slidesPerView: 6, + }, + }} + > + {data?.map((e, index) => ( + + + + ))} + + + +
+

+ مشاهده بیشتر{" "} +

+
+ +
+
+ ); +}; + +export default SunCreamSection; diff --git a/plugins/Chapar/index.js b/plugins/Chapar/index.js index a5f4a13..ccbd273 100644 --- a/plugins/Chapar/index.js +++ b/plugins/Chapar/index.js @@ -1,42 +1,44 @@ import axios from "axios"; export const getToken = () => { - return localStorage.token; + return localStorage.getItem("token"); }; const Chapar = axios.create({ baseURL: process.env.NEXT_PUBLIC_API_URL, timeout: 10000, headers: { - common: { - "Content-type": "application/json", - "Access-Control-Allow-Origin": "*", - ...(typeof window !== "undefined" && - localStorage.token && { - Authorization: getToken(), - }), - }, + "Content-type": "application/json", + "Access-Control-Allow-Origin": "*", }, }); -Chapar.interceptors.response.use( - function (response) { - // Any status code that lie within the range of 2xx cause this function to trigger - // Do something with response data +// Request interceptor to conditionally add token to headers +Chapar.interceptors.request.use( + (config) => { + const token = getToken(); + if (token && !config.isPublic) { + config.headers.Authorization = token; + } + return config; + }, + (error) => { + return Promise.reject(error); + } +); +// Response interceptor to handle responses +Chapar.interceptors.response.use( + (response) => { return response.data; }, - function (error, status) { - // Any status codes that falls outside the range of 2xx cause this function to trigger - // Do something with response error - // ; - - // if (error.response.status === 401) { - // localStorage.removeItem("token"); - // window.location.href = "/login"; - // } - - return Promise.reject({ error, status: error?.response?.status }); + (error) => { + const status = error?.response?.status; + if (status === 401) { + localStorage.removeItem("token"); + window.location.href = "/login"; + } + return Promise.reject({ error, status }); } ); diff --git a/plugins/bottomSheet/BottomSheetDeleteAddress.jsx b/plugins/bottomSheet/BottomSheetDeleteAddress.jsx index 1f9371a..bf79605 100644 --- a/plugins/bottomSheet/BottomSheetDeleteAddress.jsx +++ b/plugins/bottomSheet/BottomSheetDeleteAddress.jsx @@ -1,6 +1,7 @@ "use client"; import AppContext from "@ctx/AppContext"; +import Chapar from "plugins/Chapar"; import { useContext } from "react"; import { BottomSheet } from "react-spring-bottom-sheet"; import { toast } from "react-toastify"; @@ -9,11 +10,13 @@ const BottomSheetDeleteAddress = ({ id }) => { const CTX = useContext(AppContext); const cart = CTX.state.cart; - const handleDelete = async (id) => { + const handleDelete = async () => { try { - const data = await Chapar.post( + const data = await Chapar.delete( `${process.env.NEXT_PUBLIC_API_URL}/user/address/${id}` ); + CTX.setBottomSheetDeleteAddressOpen(false); + CTX.fetchAddressUser(); } catch ({ error, status }) { toast.error(`${error?.response?.data?.message}`, { position: "bottom-right", diff --git a/public/images/w1.JPG b/public/images/w1.JPG new file mode 100644 index 0000000..032906e Binary files /dev/null and b/public/images/w1.JPG differ diff --git a/public/images/w2.JPG b/public/images/w2.JPG new file mode 100644 index 0000000..95b17cd Binary files /dev/null and b/public/images/w2.JPG differ diff --git a/public/images/w3.JPG b/public/images/w3.JPG new file mode 100644 index 0000000..daca63f Binary files /dev/null and b/public/images/w3.JPG differ diff --git a/src/app/page.jsx b/src/app/page.jsx index b4e05a9..9da4de1 100644 --- a/src/app/page.jsx +++ b/src/app/page.jsx @@ -5,6 +5,7 @@ import BetweenSexualSection from "@comp/LandingPage/BetweenSexualSection/page"; import BrandsLogoSection from "@comp/LandingPage/BrandsLogoSection/page"; import HeroSection from "@comp/LandingPage/HeroSection/page"; import HomeSection from "@comp/LandingPage/HomeSection/page"; +import SunCreamSection from "@comp/LandingPage/SunCreamSection/page"; import SurpriseSection from "@comp/LandingPage/SurpriseSection/page"; import Navbar from "@comp/Navbar/page"; import AppContext from "@ctx/AppContext"; @@ -17,11 +18,13 @@ export default function Page() { const specialOfferData = CTX.state.specialOfferData; const cosmeticData = CTX.state.cosmeticData; const HomeCosmeticData = CTX.state.HomeCosmeticData; + const sunCreamData = CTX.state.sunCreamData; useEffect(() => { CTX.fetchSpecialOffer(); CTX.fetchCosmetic(); CTX.fetchHomeCosmetic(); + CTX.fetchSunCream(); }, []); return ( <> @@ -36,6 +39,7 @@ export default function Page() { + diff --git a/src/app/profile/address/page.jsx b/src/app/profile/address/page.jsx index 3c4ec4e..692f7c5 100644 --- a/src/app/profile/address/page.jsx +++ b/src/app/profile/address/page.jsx @@ -3,13 +3,15 @@ import Navbar from "@comp/Navbar/page"; import AppContext from "@ctx/AppContext"; import BottomSheetDeleteAddress from "plugins/bottomSheet/BottomSheetDeleteAddress"; -import { useContext, useEffect } from "react"; +import { useContext, useEffect, useState } from "react"; import SideBarProfile from "../component/SideBarProfile/page"; const Page = () => { const CTX = useContext(AppContext); const addressData = CTX.state.addressData; + const [currentAddressId, setCurrentAddressId] = useState(); + useEffect(() => { if (addressData.length <= 0) { CTX.fetchAddressUser(); @@ -63,9 +65,10 @@ const Page = () => { {" "} @@ -85,7 +88,7 @@ const Page = () => { - + ); }; diff --git a/src/app/sitemap.xml/page.jsx b/src/app/sitemap.xml/page.jsx index ccf6997..5138a26 100644 --- a/src/app/sitemap.xml/page.jsx +++ b/src/app/sitemap.xml/page.jsx @@ -5,25 +5,5 @@ async function getData(id) { } export default async function Sitemap() { - const localUrl = [ - { - url: "https://acme.com", - lastModified: new Date(), - changeFrequency: "yearly", - priority: 1, - }, - { - url: "https://acme.com/about", - lastModified: new Date(), - changeFrequency: "monthly", - priority: 0.8, - }, - { - url: "https://acme.com/blog", - lastModified: new Date(), - changeFrequency: "weekly", - priority: 0.5, - }, - ]; - return (await getData()).concat(localUrl); + return await getData(); }