From 30cc3dfa9b44a0bace95a4909498598e2218c787 Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Sat, 9 Jul 2022 13:08:49 +0430 Subject: [PATCH] update 8 files --- src/assets/icons/bookmark-active-dark.svg | 8 + src/assets/icons/bookmark-active-light.svg | 8 + src/components/Drawer/index.js | 362 +++++++++++---------- src/components/Navbar/index.js | 79 +++-- src/router.js | 30 +- src/views/Blogs/index.js | 13 +- src/views/Product/index.js | 17 +- src/views/Products/index.js | 1 + src/views/Products/layouts/Mobile/Main.js | 2 +- src/views/ShoppingCart/Product/index.js | 65 ++-- 10 files changed, 338 insertions(+), 247 deletions(-) create mode 100644 src/assets/icons/bookmark-active-dark.svg create mode 100644 src/assets/icons/bookmark-active-light.svg diff --git a/src/assets/icons/bookmark-active-dark.svg b/src/assets/icons/bookmark-active-dark.svg new file mode 100644 index 0000000..1fdbe87 --- /dev/null +++ b/src/assets/icons/bookmark-active-dark.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/assets/icons/bookmark-active-light.svg b/src/assets/icons/bookmark-active-light.svg new file mode 100644 index 0000000..13423d5 --- /dev/null +++ b/src/assets/icons/bookmark-active-light.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/components/Drawer/index.js b/src/components/Drawer/index.js index 36a9f8f..2a56294 100644 --- a/src/components/Drawer/index.js +++ b/src/components/Drawer/index.js @@ -10,7 +10,7 @@ import homeDarkIcon from "./home-dark.svg"; import logoutIcon from "./logout.svg"; import logoutDarkIcon from "./logout-dark.svg"; import dangerIcon from "./mobile-danger.svg"; -import dangerDarkIcon from "./mobile-danger-dark.svg"; +// import dangerDarkIcon from "./mobile-danger-dark.svg"; import activationIcon from "./activation.svg"; import activationDarkIcon from "./activation-dark.svg"; import contactIcon from "./contact.svg"; @@ -24,7 +24,7 @@ import cartDarkIcon from "./mobile-basket-dark.svg"; import faqIcon from "./faq.svg"; import faqDarkIcon from "./faq-dark.svg"; -import arrowLeftVideo from "../../assets/icons/dropdown-white.svg"; +// import arrowLeftVideo from "../../assets/icons/dropdown-white.svg"; import sunIcon from "./sun.svg"; import moonIcon from "./moon.svg"; @@ -40,186 +40,192 @@ const MyDrawer = ({ setDialog, logout, }) => { - const [addUserDropdown, setAddUserDropdown] = useState(false); - const publicLink = [ - { - name: window.t("صفحه اصلی"), - link: "/", - icon: ( - {window.t("صفحه - ), - toast: "", - message: "", - }, - { - name: window.t("ورود یا ثبت نام"), - link: "/signup", - icon: ( - {window.t("کتاب‌های - ), - toast: "", - message: "", - }, - { - name: window.t("پشتیبانی"), - link: "/contact-us", - icon: ( - {window.t("پشتیبانی")} - ), - toast: "", - message: "", - }, - ]; - const privateLink = [ - { - name: window.t("صفحه اصلی"), - link: "/", - icon: ( - {window.t("صفحه - ), - toast: "", - message: "", - onClick: () => { - setDrawerOpen(false); + // const [addUserDropdown, setAddUserDropdown] = useState(false); + + const privateLink = React.useMemo(() => { + return [ + { + name: window.t("صفحه اصلی"), + link: "/", + icon: ( + {window.t("صفحه + ), + toast: "", + message: "", + onClick: () => { + setDrawerOpen(false); + }, }, - }, - { - name: window.t("سبد خرید"), - link: "/cart", - icon: ( - {window.t("سبد - ), - toast: "", - message: "", - onClick: () => { - setDrawerOpen(false); + { + name: window.t("سبد خرید"), + link: "/cart", + icon: ( + {window.t("سبد + ), + toast: "", + message: "", + onClick: () => { + setDrawerOpen(false); + }, }, - }, - { - name: window.t("فعال سازی کتاب"), - link: "/activation", - icon: ( - {window.t("فعال - ), - toast: "", - message: "", - onClick: () => { - setDrawerOpen(false); + { + name: window.t("فعال سازی کتاب"), + link: "/activation", + icon: ( + {window.t("فعال + ), + toast: "", + message: "", + onClick: () => { + setDrawerOpen(false); + }, }, - }, - { - name: window.t("واقعیت افزوده"), - link: "/ar", - icon: ( - {window.t("واقعیت - ), - toast: "", - message: "", - onClick: () => { - setDrawerOpen(false); + { + name: window.t("واقعیت افزوده"), + link: "/ar", + icon: ( + {window.t("واقعیت + ), + toast: "", + message: "", + onClick: () => { + setDrawerOpen(false); + }, }, - }, - { - name: window.t("سفارشات"), - link: "/orders", - icon: ( - {window.t("سفارشات")} - ), - toast: "", - message: "", - onClick: () => { - setDrawerOpen(false); + { + name: window.t("سفارشات"), + link: "/orders", + icon: ( + {window.t("سفارشات")} + ), + toast: "", + message: "", + onClick: () => { + setDrawerOpen(false); + }, }, - }, - { - name: window.t("سوالات متداول"), - link: "/faq", - icon: ( - {window.t("سوالات - ), - toast: "", - message: "", - onClick: () => { - setDrawerOpen(false); + { + name: window.t("سوالات متداول"), + link: "/faq", + icon: ( + {window.t("سوالات + ), + toast: "", + message: "", + onClick: () => { + setDrawerOpen(false); + }, }, - }, - { - name: window.t("پشتیبانی"), - link: "/contact", - icon: ( - {window.t("پشتیبانی")} - ), - toast: "", - message: "", - onClick: () => { - setDrawerOpen(false); + { + name: window.t("پشتیبانی"), + link: "/contact", + icon: ( + {window.t("پشتیبانی")} + ), + toast: "", + message: "", + onClick: () => { + setDrawerOpen(false); + }, }, - }, - { - name: window.t("خروج از حساب کاربری"), - link: "/", - icon: ( - {window.t("خروج - ), - toast: "", - message: "", - onClick: () => { - setDialog({ - open: true, - type: "confirm", - accept: () => { - logout(); - }, - text: window.t("قصد خروج از حساب کاربری رو داری؟"), - }); - setDrawerOpen(false); + { + name: window.t("خروج از حساب کاربری"), + link: "/", + icon: ( + {window.t("خروج + ), + toast: "", + message: "", + onClick: () => { + setDialog({ + open: true, + type: "confirm", + accept: () => { + logout(); + }, + text: window.t("قصد خروج از حساب کاربری رو داری؟"), + }); + setDrawerOpen(false); + }, }, - }, - ]; + ]; + },[isDark, user]); + + const publicLink = React.useMemo(() => { + return [ + { + name: window.t("صفحه اصلی"), + link: "/", + icon: ( + {window.t("صفحه + ), + toast: "", + message: "", + }, + { + name: window.t("ورود یا ثبت نام"), + link: "/signup", + icon: ( + {window.t("کتاب‌های + ), + toast: "", + message: "", + }, + { + name: window.t("پشتیبانی"), + link: "/contact-us", + icon: ( + {window.t("پشتیبانی")} + ), + toast: "", + message: "", + }, + ]; + },[isDark, user]); return ( - setAddUserDropdown(() => !addUserDropdown)} - /> + /> */} - + > */}

نسخه محصول را انتخاب کنید @@ -196,6 +204,7 @@ const mapStateToProps = (state) => ({ isMobile: state.publicApi.isMobile, isDark: state.publicApi.isDark, userId: state.user.status?.id, + bookmarkLoading: state.userFavorite.loading, }); const mapDispatchToProps = { diff --git a/src/views/Products/index.js b/src/views/Products/index.js index 4ba7306..1aefab3 100644 --- a/src/views/Products/index.js +++ b/src/views/Products/index.js @@ -23,6 +23,7 @@ export const Products = ({ useEffect(() => { getList({ vod: true }); setHeaderOptions(headerOptions); + window.scroll({top: 0, behavior : 'smooth'}); }, []); return ( diff --git a/src/views/Products/layouts/Mobile/Main.js b/src/views/Products/layouts/Mobile/Main.js index b0bf8dd..2f7570f 100644 --- a/src/views/Products/layouts/Mobile/Main.js +++ b/src/views/Products/layouts/Mobile/Main.js @@ -137,7 +137,7 @@ export const Main = ({ books, filterOptions, grades }) => { }; return ( -
+
{filterOptions?.productType === "دوره ویدئویی" && Items(2)} {filterOptions?.productType === "کتاب دیجیتال" && Items(0)} {filterOptions?.productType === "کتاب فیزیکی" && Items(1)} diff --git a/src/views/ShoppingCart/Product/index.js b/src/views/ShoppingCart/Product/index.js index 82dc283..e03b7b8 100644 --- a/src/views/ShoppingCart/Product/index.js +++ b/src/views/ShoppingCart/Product/index.js @@ -10,6 +10,14 @@ import exitIcon from "../../../assets/icons/exit.svg"; import deleteIcon from "../../../assets/icons/delete.svg"; function Product({ product, grades, pushToCart, isMobile, loading }) { + const [selectedItem, setSelectedItem] = React.useState(null); + + React.useEffect(() => { + if (!loading) { + setSelectedItem(null); + } + }, [loading]); + return isMobile ? (
@@ -34,7 +42,8 @@ function Product({ product, grades, pushToCart, isMobile, loading }) { src={exitIcon} className="w-4" alt="" - onClick={() => + onClick={() => { + setSelectedItem(product?.productId); pushToCart( { productId: product?.productId, @@ -43,26 +52,27 @@ function Product({ product, grades, pushToCart, isMobile, loading }) { }, {}, { id: product?.factorId } - ) - } + ); + }} />
- {product.productType === 2 && ( + {product.productType === 2 ? (
- {loading ? ( + {loading && selectedItem === product?.productId ? ( ) : ( product.count @@ -72,7 +82,8 @@ function Product({ product, grades, pushToCart, isMobile, loading }) { <> {product.count === 1 ? ( + onClick={() => { + setSelectedItem(product?.productId); pushToCart( { productId: product?.productId, @@ -82,22 +93,23 @@ function Product({ product, grades, pushToCart, isMobile, loading }) { }, {}, { id: product?.factorId } - ) - } + ); + }} src={deleteIcon} alt="delete" - className="border border-blue-800 border-solid p-1 w-8 bg-red-100 rounded-md cursor-pointer" + className="border border-red-800 border-solid p-1 w-8 bg-red-100 rounded-md cursor-pointer" /> ) : ( @@ -105,7 +117,7 @@ function Product({ product, grades, pushToCart, isMobile, loading }) { }
- )} + ) : null} {separate(product.product.price * product.count)} تومان @@ -147,13 +159,14 @@ function Product({ product, grades, pushToCart, isMobile, loading }) {
@@ -164,7 +177,8 @@ function Product({ product, grades, pushToCart, isMobile, loading }) { <> {product.count === 1 ? ( + onClick={() => { + setSelectedItem(product?.productId); pushToCart( { productId: product?.productId, @@ -173,8 +187,8 @@ function Product({ product, grades, pushToCart, isMobile, loading }) { }, {}, { id: product?.factorId } - ) - } + ); + }} src={deleteIcon} alt="delete" className="border border-red-300 border-solid p-1 w-7 bg-red-100 rounded-md cursor-pointer" @@ -182,13 +196,14 @@ function Product({ product, grades, pushToCart, isMobile, loading }) { ) : (