update 8 files

master
Reza_ashrafi 2 years ago
parent 8bfdaba083
commit fb46a5b1ee
  1. 5
      src/redux/actions/dashboard.js
  2. 4
      src/redux/reducers/dashboard.js
  3. 2
      src/router.js
  4. 2
      src/views/Auth/Profile/Upload/index.js
  5. 2
      src/views/Auth/Profile/index.js
  6. 16
      src/views/Dashboard/index.js
  7. 4
      src/views/Dashboard/layouts/Main/index.js
  8. 2
      src/views/Dashboard/layouts/SidebarMenu/index.js

@ -1,5 +1,8 @@
const dashboard = { const dashboard = {
setPage:
(data = {}) =>
async (dispatch) =>
dispatch({ type: "dashboard/setPage", data }),
}; };
export default dashboard; export default dashboard;

@ -3,6 +3,7 @@ import { toast } from "react-toastify";
const initialState = { const initialState = {
loading: false, loading: false,
error: null, error: null,
page: localStorage.getItem("dashboardPage"),
sidebar: { sidebar: {
userInfo: true, userInfo: true,
menu: [ menu: [
@ -70,6 +71,9 @@ const initialState = {
export default function dashboard(state = initialState, action) { export default function dashboard(state = initialState, action) {
let { type, data } = action; let { type, data } = action;
switch (type) { switch (type) {
case "dashboard/setPage":
localStorage.setItem("dashboardPage", data);
return { ...state, page: data };
default: default:
return state; return state;
} }

@ -604,7 +604,7 @@ function Router({
} }
/> />
</Routes> </Routes>
{!isMobile ? <FooterDesign1 hasHeader /> : null} {/* {!isMobile ? <FooterDesign1 hasHeader /> : null} */}
</BrowserRouter> </BrowserRouter>
</div> </div>
</div> </div>

@ -15,7 +15,7 @@ function Upload({ name, value: initValue, onChange }) {
return ( return (
<div <div
className="flex justify-center bg-green-400 rounded-full items-center overflow-hidden relative" className="flex justify-center bg-green-400 rounded-full items-center overflow-hidden relative"
style={{ width: 100, height: 100 }} style={{ minWidth: 100, minHeight: 100, maxWidth: 100, maxHeight: 100 }}
> >
<div <div
className={`h-full w-full rounded-full flex justify-center items-center ${ className={`h-full w-full rounded-full flex justify-center items-center ${

@ -399,7 +399,7 @@ function Profile({
</div> </div>
) : ( ) : (
<div <div
className="hidden lg:flex flex-col items-center gap-5 w-full pt-5 select-none" className="hidden lg:flex flex-col items-center gap-5 w-10/12 pt-6 select-none"
onSubmit={(e) => onSubmit()} onSubmit={(e) => onSubmit()}
> >
<Upload <Upload

@ -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);

@ -13,7 +13,7 @@ import Profile from "../../../Auth/Profile";
const views = { const views = {
orders: <Orders />, orders: <Orders />,
mybooks: <MyBooks />, myBooks: <MyBooks />,
userItems: <UserItems />, userItems: <UserItems />,
ticket: ( ticket: (
<div className="flex-1 flex flex-col justify-center items-center"> <div className="flex-1 flex flex-col justify-center items-center">
@ -31,7 +31,7 @@ const views = {
export const Main = ({ page }) => { export const Main = ({ page }) => {
return ( return (
<div <div
className="overflow-y-scroll overflow-x-hidden border-t-2 border-b-2 border-solid border-gray-300 flex flex-1 flex-shrink-0 no-scrollbar" className="overflow-y-scroll overflow-x-hidden border-t-2 pb-10 border-b-2 border-solid border-gray-300 flex justify-center flex-1 flex-shrink-0 no-scrollbar"
> >
{views[page]} {views[page]}
</div> </div>

@ -118,7 +118,7 @@ const SidebarMenu = ({
className="bg-gray-50 py-5 border-l-2 border-t-2 border-b-2 pl-4 pr-2 shadow-sm border-gray-300 border-solid overflow-y-scroll no-scrollbar divide-y divide-solid divide-gray-200" className="bg-gray-50 py-5 border-l-2 border-t-2 border-b-2 pl-4 pr-2 shadow-sm border-gray-300 border-solid overflow-y-scroll no-scrollbar divide-y divide-solid divide-gray-200"
style={{ style={{
height: "calc(100vh - 71px)", height: "calc(100vh - 71px)",
minWidth: 300, minWidth: 250,
}} }}
> >
{sidebar?.userInfo ? ( {sidebar?.userInfo ? (

Loading…
Cancel
Save