From c3dea8ae95ef0aa6d5da6bdf94aa26ff7d3cdb88 Mon Sep 17 00:00:00 2001 From: Chief Bube Date: Sun, 22 Oct 2023 23:20:34 -0700 Subject: [PATCH 1/3] changed index --- pages/index.js | 93 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 84 insertions(+), 9 deletions(-) diff --git a/pages/index.js b/pages/index.js index ec9013d..9c2b14d 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,12 +1,87 @@ -import { useRouter } from "next/router"; -import ECommerce from "./ecommerce"; +import React from "react"; +import Grid from "@mui/material/Grid"; +import Link from "next/link"; +import styles from "@/styles/PageTitle.module.css"; +import Features from "@/components/Dashboard/eCommerce/Features"; +import Ratings from "@/components/Dashboard/eCommerce/Ratings"; +import AudienceOverview from "@/components/Dashboard/eCommerce/AudienceOverview"; +import VisitsByDay from "@/components/Dashboard/eCommerce/VisitsByDay"; +import Impressions from "@/components/Dashboard/eCommerce/Impressions"; +import ActivityTimeline from "@/components/Dashboard/eCommerce/ActivityTimeline"; +import RevenuStatus from "@/components/Dashboard/eCommerce/RevenuStatus"; +import SalesByCountries from "@/components/Dashboard/eCommerce/SalesByCountries"; +import NewCustomers from "@/components/Dashboard/eCommerce/NewCustomers"; +import RecentOrders from "@/components/Dashboard/eCommerce/RecentOrders"; +import TeamMembersList from "@/components/Dashboard/eCommerce/TeamMembersList"; +import BestSellingProducts from "@/components/Dashboard/eCommerce/BestSellingProducts"; +import LiveVisitsOnOurSite from "@/components/Dashboard/eCommerce/LiveVisitsOnOurSite"; -export default function Home() { - const router = useRouter(); +function MainPage() { + return ( + <> + {/* Page title */} +
+

eCommerce

+ +
+ + + {/* Features */} + + {/* AudienceOverview */} + + + + {/* VisitsByDay */} + + + + {/* Impressions */} + - console.log("Check pathname: " + router.pathname) - - if (router.pathname === "/") { - return ; - } + {/* ActivityTimeline */} + + + + {/* RevenuStatus */} + + + + + + {/* Ratings */} + + {/* LiveVisitsOnOurSite */} + + {/* SalesByLocations */} + + {/* NewCustomers */} + + + + {/* Recent Orders */} + + + + {/* TeamMembersList */} + + + + {/* BestSellingProducts */} + + + + + ); } + +export default MainPage \ No newline at end of file From de57daf98ae147f7006516d59465b8dd03d3ae55 Mon Sep 17 00:00:00 2001 From: Chief Bube Date: Mon, 23 Oct 2023 00:45:13 -0700 Subject: [PATCH 2/3] Added Logout Option and prefetch for the dashboard --- components/Authentication/SignInForm.js | 21 ++++-- components/_App/Layout.js | 11 ++- components/_App/LeftSidebar/SidebarData.js | 6 ++ components/_App/LeftSidebar/index.js | 82 +++++++++++----------- middleware.js | 16 ----- pages/auth/logout.js | 44 +++++++----- 6 files changed, 95 insertions(+), 85 deletions(-) diff --git a/components/Authentication/SignInForm.js b/components/Authentication/SignInForm.js index 29c3668..33f7c58 100644 --- a/components/Authentication/SignInForm.js +++ b/components/Authentication/SignInForm.js @@ -1,6 +1,6 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { useRouter } from "next/router"; -import { setCookie } from 'cookies-next'; +import { setCookie } from "cookies-next"; import Link from "next/link"; import Grid from "@mui/material/Grid"; import LoadingButton from "@mui/lab/LoadingButton"; @@ -79,9 +79,17 @@ const SignInForm = () => { } // Store the token in cookies - await setCookie("cmc-token", res.token); - router.push("/"); + // Calculate the expiration time in 24 hours + const expirationDate = new Date(); + expirationDate.setTime(expirationDate.getTime() + 24 * 60 * 60 * 1000); // 24 hours in milliseconds + const cookieOptions = { + expires: expirationDate, + httpOnly: true, // Make the cookie accessible only via HTTP (recommended for security) + }; + + await setCookie("cmc-token", res.token); + router.push("/"); console.log(res); } catch (error) { @@ -100,6 +108,11 @@ const SignInForm = () => { setShowPassword(!showPassword); }; + useEffect(() => { + // Prefetch the dashboard + router.prefetch("/"); + }); + return ( <>
diff --git a/components/_App/Layout.js b/components/_App/Layout.js index edca465..1736b2a 100644 --- a/components/_App/Layout.js +++ b/components/_App/Layout.js @@ -20,14 +20,11 @@ const Layout = ({ children }) => { useEffect(() => { const authenticationPages = [ - // "/", - "/auth", "/auth/login", "/auth/sign-up", "/auth/forgot-password", "/auth/lock-screen", "/auth/confirm-mail", - "/auth/logout", ]; setIsAuthenticationPage(authenticationPages.includes(router.pathname)); @@ -38,8 +35,8 @@ const Layout = ({ children }) => { const title = isAuthenticationPage ? "CMC - auth" : "CMC - dashboard"; const mainWrapper = { - paddingLeft: typeof window !== "undefined" && isAuthenticationPage && "0" - } + paddingLeft: typeof window !== "undefined" && isAuthenticationPage && "0", + }; return ( <> @@ -65,7 +62,9 @@ const Layout = ({ children }) => { {children}
- {!isAuthenticationPage &&