|
|
@ -1,6 +1,6 @@ |
|
|
|
import React, { useState, useEffect } from "react"; |
|
|
|
import React, { useState, useEffect } from "react"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { publicApi } from "../../redux/actions"; |
|
|
|
import { publicApi, dashboard } from "../../redux/actions"; |
|
|
|
|
|
|
|
|
|
|
|
//components
|
|
|
|
//components
|
|
|
|
import Sidebar from "./layouts/SidebarMenu"; |
|
|
|
import Sidebar from "./layouts/SidebarMenu"; |
|
|
@ -9,19 +9,11 @@ import User from "./layouts/Mobile/User"; |
|
|
|
import Trophy from "./layouts/Mobile/Trophy"; |
|
|
|
import Trophy from "./layouts/Mobile/Trophy"; |
|
|
|
import List from "./layouts/Mobile/List"; |
|
|
|
import List from "./layouts/Mobile/List"; |
|
|
|
|
|
|
|
|
|
|
|
export const Dashboard = ({ isMobile, headerOptions, setHeaderOptions }) => { |
|
|
|
export const Dashboard = ({ isMobile, headerOptions, setHeaderOptions, setPage, page }) => { |
|
|
|
const [page, setPage] = useState( |
|
|
|
|
|
|
|
localStorage?.getItem("dashboard") || "userItems" |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
setHeaderOptions(headerOptions); |
|
|
|
setHeaderOptions(headerOptions); |
|
|
|
}, []); |
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
localStorage.setItem("dashboard", page); |
|
|
|
|
|
|
|
}, [page]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return isMobile ? ( |
|
|
|
return isMobile ? ( |
|
|
|
<div className="flex-1 flex flex-col px-4"> |
|
|
|
<div className="flex-1 flex flex-col px-4"> |
|
|
|
<User /> |
|
|
|
<User /> |
|
|
@ -42,11 +34,13 @@ export const Dashboard = ({ isMobile, headerOptions, setHeaderOptions }) => { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
isMobile: state.publicApi.isMobile, |
|
|
|
isMobile: state.config.device === 'mobile', |
|
|
|
|
|
|
|
page: state.dashboard.page |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
const mapDispatchToProps = { |
|
|
|
setHeaderOptions: publicApi.setHeaderOptions, |
|
|
|
setHeaderOptions: publicApi.setHeaderOptions, |
|
|
|
|
|
|
|
setPage: dashboard.setPage |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Dashboard); |
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Dashboard); |
|
|
|