|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
import React from "react"; |
|
|
|
|
import React, { useEffect } from "react"; |
|
|
|
|
import { BrowserRouter, Routes, Route } from "react-router-dom"; |
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
import { publicApi } from "./redux/actions"; |
|
|
|
|
import Navbar from "./components/Navbar"; |
|
|
|
|
import BG from "./components/BG"; |
|
|
|
|
import BottomNavigation from "./components/BottomNavigation"; |
|
|
|
@ -24,7 +25,20 @@ import Faq from "./views/Faq"; |
|
|
|
|
import Contact from "./views/Contact"; |
|
|
|
|
// import VideoTube from "./views/Home/VideoTube";
|
|
|
|
|
|
|
|
|
|
function Router({ isDark,isMobile, isLogin, headerOptions }) { |
|
|
|
|
function Router({ isDark, isMobile, isLogin, headerOptions, setDesktopContentTransform }) { |
|
|
|
|
useEffect(() => { |
|
|
|
|
window.addEventListener("scroll", () => { |
|
|
|
|
if (!isMobile) { |
|
|
|
|
window.addEventListener("scroll", () => { |
|
|
|
|
if (window.scrollY >= 64) { |
|
|
|
|
setDesktopContentTransform(true); |
|
|
|
|
} else { |
|
|
|
|
setDesktopContentTransform(false); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, []); |
|
|
|
|
return ( |
|
|
|
|
<div className={_.join([isDark ? "dark" : ""], " ")}> |
|
|
|
|
<div |
|
|
|
@ -39,8 +53,12 @@ function Router({ isDark,isMobile, isLogin, headerOptions }) { |
|
|
|
|
> |
|
|
|
|
<BrowserRouter> |
|
|
|
|
{headerOptions?.shown && <Navbar headerOptions={headerOptions} />} |
|
|
|
|
{isMobile && ( |
|
|
|
|
<> |
|
|
|
|
<BG /> |
|
|
|
|
<BottomNavigation /> |
|
|
|
|
</> |
|
|
|
|
)} |
|
|
|
|
<Routes> |
|
|
|
|
<Route |
|
|
|
|
path="/" |
|
|
|
@ -82,7 +100,9 @@ function Router({ isDark,isMobile, isLogin, headerOptions }) { |
|
|
|
|
<Route |
|
|
|
|
path="/products" |
|
|
|
|
exact |
|
|
|
|
element={<Products headerOptions={{ shown: isMobile ? false : true }} />} |
|
|
|
|
element={ |
|
|
|
|
<Products headerOptions={{ shown: isMobile ? false : true }} /> |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
<Route |
|
|
|
|
path="/products/:id" |
|
|
|
@ -108,8 +128,8 @@ function Router({ isDark,isMobile, isLogin, headerOptions }) { |
|
|
|
|
<ShoppingCart |
|
|
|
|
headerOptions={{ |
|
|
|
|
shown: true, |
|
|
|
|
title: "سبد خرید", |
|
|
|
|
back: true, |
|
|
|
|
title: isMobile && "سبد خرید", |
|
|
|
|
back: isMobile && true, |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
} |
|
|
|
@ -308,4 +328,8 @@ const mapStateToProps = (state) => ({ |
|
|
|
|
headerOptions: state.publicApi.headerOptions, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, {})(Router); |
|
|
|
|
const mapDispatchToProps = { |
|
|
|
|
setDesktopContentTransform : publicApi.setDesktopContentTransform, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Router); |
|
|
|
|