diff --git a/components/AppsComponent/CartData/page.jsx b/components/AppsComponent/CartData/page.jsx index fddcf37..874500f 100644 --- a/components/AppsComponent/CartData/page.jsx +++ b/components/AppsComponent/CartData/page.jsx @@ -25,40 +25,7 @@ const CartData = () => { ); const handleGoCheckOut = async () => { - // Check if the user is authorized based on the presence of a token in local storage - const token = localStorage.getItem("token"); - - if (token) { - // If token exists, proceed to checkout - const productsToSend = cart.map((item) => ({ - productId: item.id, - count: parseInt(item.count), - })); - try { - const data = await Chapar.post( - `${process.env.NEXT_PUBLIC_API_URL}/order/bag/add`, - - JSON.stringify(productsToSend), - - { - headers: { - Authorization: localStorage.getItem("token"), - }, - } - ); - - CTX.setCheckOutData(data); - } catch ({ error, status }) { - toast.error(`${error?.response?.data?.message}`, { - position: "bottom-right", - closeOnClick: true, - }); - } - router.push("/cart/checkout"); // Redirect to the checkout Page - } else { - // If token does not exist, redirect to login - router.push("/login"); // Redirect to the login Page - } + CTX.GoCheckOut(); }; useEffect(() => { diff --git a/components/AppsComponent/CheckoutData/page.jsx b/components/AppsComponent/CheckoutData/page.jsx index 9c77912..b2b6a8d 100644 --- a/components/AppsComponent/CheckoutData/page.jsx +++ b/components/AppsComponent/CheckoutData/page.jsx @@ -362,9 +362,9 @@ const CheckoutData = () => {

حساب نهایی

-
+ {/*

مشاهده اقلام

-
+
*/}
diff --git a/components/AppsComponent/RootData/page.jsx b/components/AppsComponent/RootData/page.jsx index 4a44983..89ca48e 100644 --- a/components/AppsComponent/RootData/page.jsx +++ b/components/AppsComponent/RootData/page.jsx @@ -31,10 +31,12 @@ const RootData = ({ children }) => { const [bottomSheetDiscountOpen, setBottomSheetDiscountOpen] = useState(false); const [bottomSheetAddressOpen, setBottomSheetAddressOpen] = useState(false); const [bottomSheetLogOutOpen, setBottomSheetLogOutOpen] = useState(false); + const [bottomSheetSeeOrderOpen, setBottomSheetSeeOrderOpen] = useState(false); const [bottomSheetDeleteAddressOpen, setBottomSheetDeleteAddressOpen] = useState(false); const [checkOutData, setCheckOutData] = useState([]); const [addressData, setAddressData] = useState([]); + const [orderUser, setOrderUser] = useState([]); const [profile, setProfile] = useState([]); const [stopProducts, setStopProducts] = useState(false); const [pageGetProducts, setPageGetProducts] = useState(0); @@ -49,6 +51,8 @@ const RootData = ({ children }) => { const router = useRouter(); + console.log("cart", cart); + const AddItemToCart = ( id, persianName, @@ -231,6 +235,27 @@ const RootData = ({ children }) => { } }; + const fetchOrderUser = async () => { + try { + const data = await Chapar.get( + `${process.env.NEXT_PUBLIC_API_URL}/user/order`, + { + headers: { + Authorization: localStorage.getItem("token"), + }, + } + ); + + setOrderUser(data); + } catch ({ error, status }) { + toast.error(`${error?.response?.data?.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + setLoading(false); + } + }; + const fetchUserInfo = async () => { try { const data = await Chapar.get( @@ -252,6 +277,92 @@ const RootData = ({ children }) => { } }; + const fetchOrderBagCheck = async () => { + console.log(cart); + const productsToSend = cart.map((item) => ({ + productId: item.id, + count: parseInt(item.count), + })); + + console.log(productsToSend); + + try { + const data = await Chapar.post( + `${process.env.NEXT_PUBLIC_API_URL}/order/bag/check`, + + JSON.stringify(productsToSend) + ); + + const updatedCart = cart + .map((item) => { + const updatedCartItem = data.find( + (updatedItem) => updatedItem.productId === item.id + ); + if (updatedCartItem) { + if (updatedCartItem.isRemoved || !updatedCartItem.isEnable) { + // Item is removed or not enabled, remove from cart + return null; + } else { + return { + ...item, + cost: updatedCartItem.cost, + costWithDiscount: updatedCartItem.costWithDiscount, + }; + } + } else { + return item; + } + }) + .filter(Boolean); // Filter out null entries (removed items) + + setCart(updatedCart); + localStorage.setItem("cart", JSON.stringify(updatedCart)); // Save updatedCart to localStorage + } catch ({ error, status }) { + toast.error(`${error?.response?.data?.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + } + }; + + const GoCheckOut = async () => { + // Check if the user is authorized based on the presence of a token in local storage + const token = localStorage.getItem("token"); + + if (token) { + // If token exists, proceed to checkout + const productsToSend = cart.map((item) => ({ + productId: item.id, + count: parseInt(item.count), + })); + + try { + const data = await Chapar.post( + `${process.env.NEXT_PUBLIC_API_URL}/order/bag/submit`, + + JSON.stringify(productsToSend), + + { + headers: { + Authorization: localStorage.getItem("token"), + }, + } + ); + + setCheckOutData(data); + } catch ({ error, status }) { + toast.error(`${error?.response?.data?.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + } + router.push("/cart/checkout"); // Redirect to the checkout Page + } else { + // If token does not exist, redirect to login + router.push("/login"); // Redirect to the login Page + } + }; + useEffect(() => { const storedCart = localStorage.getItem("cart"); const token = localStorage.getItem("token"); @@ -289,6 +400,7 @@ const RootData = ({ children }) => { mediaQuery.removeEventListener("change", listener); }; }, []); + return ( { rangePrice, selectedBrands, isChecked, + orderUser, + bottomSheetSeeOrderOpen, }, setCart, setProducts, @@ -343,7 +457,9 @@ const RootData = ({ children }) => { setIsRangePrice, setRangePrice, setSelectedBrands, + setBottomSheetSeeOrderOpen, setIsChecked, + setOrderUser, AddItemToCart, RemoveItemFromCart, fetchNavData, @@ -351,6 +467,9 @@ const RootData = ({ children }) => { setCloseNavbar, setAddressData, fetchAddressUser, + fetchOrderBagCheck, + fetchOrderUser, + GoCheckOut, }} > {children} diff --git a/components/Cards/CardNormal/page.jsx b/components/Cards/CardNormal/page.jsx index a47844e..cce89f2 100644 --- a/components/Cards/CardNormal/page.jsx +++ b/components/Cards/CardNormal/page.jsx @@ -9,7 +9,7 @@ import AppContext from "@ctx/AppContext"; import AddToCart from "../Components/AddToCart/page"; import Link from "next/link"; -const CardNormal = ({ data }) => { +const CardNormal = ({ data, priority }) => { const CTX = useContext(AppContext); const cart = CTX.state.cart; console.log(data); @@ -47,6 +47,7 @@ const CardNormal = ({ data }) => { width={200} height={200} className="xs:!w-[110px] lg:!w-[130px] mx-auto" + priority={!!priority} alt={`${data.persianName} - ${data.englishName}`} /> ) : ( diff --git a/components/Footer/page.jsx b/components/Footer/page.jsx index b244a24..7bf4a14 100644 --- a/components/Footer/page.jsx +++ b/components/Footer/page.jsx @@ -201,7 +201,7 @@ const Footer = () => {

- استفاده از مطالب فروشگاه شاواز فقط برای مقاصد غیرتجاری و باذکر منبع + استفاده از مطالب فروشگاه وسمه فقط برای مقاصد غیرتجاری و باذکر منبع بلامانع است. کلیه حقوق این سایت متعلق به شرکت وسمه می باشد. ورژن {process.env.NEXT_PUBLIC_PACKAGE_VERSION}

diff --git a/components/LandingPage/BeautySection/page.jsx b/components/LandingPage/BeautySection/page.jsx index 45f0152..56f42c6 100644 --- a/components/LandingPage/BeautySection/page.jsx +++ b/components/LandingPage/BeautySection/page.jsx @@ -2,7 +2,6 @@ import CardNormal from "@comp/Cards/CardNormal/page"; import { Swiper, SwiperSlide } from "swiper/react"; const BeautySection = ({ data }) => { - console.log("BeautySection", data); return (
@@ -35,8 +34,8 @@ const BeautySection = ({ data }) => { spaceBetween={50} slidesPerView={6.2} onSlideChange={() => console.log("slide change")} - onSwiper={(swiper) => console.log(swiper)} className="rtl relative mt-5" + // dir="rtl" breakpoints={{ 320: { slidesPerView: 1.3, @@ -57,7 +56,7 @@ const BeautySection = ({ data }) => { > {data?.map((e, index) => ( - + ))} diff --git a/components/Navbar/CartNavbar/page.jsx b/components/Navbar/CartNavbar/page.jsx index 6198126..534ae15 100644 --- a/components/Navbar/CartNavbar/page.jsx +++ b/components/Navbar/CartNavbar/page.jsx @@ -66,7 +66,10 @@ const CartNavbar = (props) => {

*/} - diff --git a/components/TimerDown/TimerDown.jsx b/components/TimerDown/TimerDown.jsx index 00c3817..c6e651e 100644 --- a/components/TimerDown/TimerDown.jsx +++ b/components/TimerDown/TimerDown.jsx @@ -46,7 +46,7 @@ const TimerDown = () => { }, []); return ( -
+

{ />

-

روز

+

روز

@@ -65,7 +65,7 @@ const TimerDown = () => { style={"text-[27px] text-red-900 "} />

-

ساعت

+

ساعت

@@ -74,7 +74,7 @@ const TimerDown = () => { style={"text-[27px] text-red-900 "} />

-

دقیقه

+

دقیقه

@@ -85,7 +85,7 @@ const TimerDown = () => { style={"text-[27px] text-red-900 "} />

-

ثانیه

+

ثانیه

diff --git a/next.config.js b/next.config.js index 51f61fb..9135059 100644 --- a/next.config.js +++ b/next.config.js @@ -3,6 +3,12 @@ const nextConfig = { reactStrictMode: false, // React Strict Mode is off images: { domains: ["storage.vesmook.com"], + remotePatterns: [ + { + protocol: "https", + hostname: "storage.vesmook.com", + }, + ], }, }; diff --git a/plugins/bottomSheet/BottomSheetSeeOrder.jsx b/plugins/bottomSheet/BottomSheetSeeOrder.jsx new file mode 100644 index 0000000..98dc0df --- /dev/null +++ b/plugins/bottomSheet/BottomSheetSeeOrder.jsx @@ -0,0 +1,152 @@ +"use client"; + +import CardCart from "@comp/Cards/CardCart/page"; +import AppContext from "@ctx/AppContext"; +import Image from "next/image"; +import Link from "next/link"; +import Chapar from "plugins/Chapar"; +import PersianNumber from "plugins/PersianNumber"; +import { useContext, useState } from "react"; +import { BottomSheet } from "react-spring-bottom-sheet"; +import { toast } from "react-toastify"; +import logo from "@img/logo.png"; + +const BottomSheetSeeOrder = ({ id }) => { + console.log("id", id); + const CTX = useContext(AppContext); + + const [bag, setBag] = useState([]); + + const handleOpen = async (e) => { + if (e.type == "OPEN") { + try { + const data = await Chapar.get( + `${process.env.NEXT_PUBLIC_API_URL}/order/${id}`, + { + headers: { + Authorization: localStorage.getItem("token"), + }, + } + ); + setBag(data); + } catch ({ error, status }) { + toast.error(`${error?.response?.data?.message}`, { + position: "bottom-right", + closeOnClick: true, + }); + } + } + }; + + return ( + handleOpen(e)} + open={CTX.state.bottomSheetSeeOrderOpen} + onDismiss={() => CTX.setBottomSheetSeeOrderOpen(false)} + className={"z-50 relative"} + > + {/* {bag && bag.length > 0 && ( */} +
+ {bag.orderProducts?.map((e) => ( +
+

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

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

+ {e?.productName} +

+ + +
+
+

+ + عدد +

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

+ + + +

+
+ {" "} +

+ +

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

+ +

+ تومان +
+ )} +
+
+
+
+ ))} +
+
+ ))} +
+ {/* )} */} +
+ ); +}; + +export default BottomSheetSeeOrder; diff --git a/public/android-chrome-192x192.png b/public/android-chrome-192x192.png new file mode 100644 index 0000000..49d9a61 Binary files /dev/null and b/public/android-chrome-192x192.png differ diff --git a/public/android-chrome-512x512.png b/public/android-chrome-512x512.png new file mode 100644 index 0000000..98cf08a Binary files /dev/null and b/public/android-chrome-512x512.png differ diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png new file mode 100644 index 0000000..a8186f2 Binary files /dev/null and b/public/apple-touch-icon.png differ diff --git a/public/browserconfig.xml b/public/browserconfig.xml new file mode 100644 index 0000000..98d065e --- /dev/null +++ b/public/browserconfig.xml @@ -0,0 +1,9 @@ + + + + + + #2ab0da + + + diff --git a/public/favicon-16x16.png b/public/favicon-16x16.png new file mode 100644 index 0000000..18a5dec Binary files /dev/null and b/public/favicon-16x16.png differ diff --git a/public/favicon-32x32.png b/public/favicon-32x32.png new file mode 100644 index 0000000..ce2379b Binary files /dev/null and b/public/favicon-32x32.png differ diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..b9adff4 Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/mstile-150x150.png b/public/mstile-150x150.png new file mode 100644 index 0000000..753e0c8 Binary files /dev/null and b/public/mstile-150x150.png differ diff --git a/public/next.svg b/public/next.svg deleted file mode 100644 index 5174b28..0000000 --- a/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/safari-pinned-tab.svg b/public/safari-pinned-tab.svg new file mode 100644 index 0000000..47d9376 --- /dev/null +++ b/public/safari-pinned-tab.svg @@ -0,0 +1,2153 @@ + + + + +Created by potrace 1.14, written by Peter Selinger 2001-2017 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/site.webmanifest b/public/site.webmanifest new file mode 100644 index 0000000..5e286c9 --- /dev/null +++ b/public/site.webmanifest @@ -0,0 +1,19 @@ +{ + "name": "vesmeh", + "short_name": "vesmeh", + "icons": [ + { + "src": "/android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/android-chrome-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "theme_color": "#2ab0da", + "background_color": "#2ab0da", + "display": "standalone" +} diff --git a/public/vercel.svg b/public/vercel.svg deleted file mode 100644 index d2f8422..0000000 --- a/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/app/layout.jsx b/src/app/layout.jsx index 473486d..0108ee1 100644 --- a/src/app/layout.jsx +++ b/src/app/layout.jsx @@ -1,6 +1,19 @@ import RootData from "@comp/AppsComponent/RootData/page"; +import Head from "next/head"; export const metadata = { + icons: { + icon: [ + { + url: "/favicon-16x16.png", + media: "(prefers-color-scheme: light)", + }, + { + url: "/favicon-16x16.png", + media: "(prefers-color-scheme: dark)", + }, + ], + }, title: { template: "%s | خرید لوازم آرایشی و بهداشتی قیمت مناسب و اصل | فروشگاه اینترنتی وسمه", diff --git a/src/app/page.jsx b/src/app/page.jsx index b8dda1b..8e1d82a 100644 --- a/src/app/page.jsx +++ b/src/app/page.jsx @@ -52,10 +52,14 @@ export default function Page() {
- + + + - + + + {/* */}