Merge branch 'adding-login' of Controls/CMS-Client into master

This commit is contained in:
2023-10-23 11:00:30 +00:00
committed by Gogs
7 changed files with 20 additions and 104 deletions
+1 -1
View File
@@ -450,7 +450,7 @@ export const SidebarData = [
}, },
{ {
title: "Authentication", title: "Authentication",
path: "/auth/login/", path: "/auth/",
icon: <LockIcon />, icon: <LockIcon />,
iconClosed: <KeyboardArrowRightIcon />, iconClosed: <KeyboardArrowRightIcon />,
iconOpened: <KeyboardArrowDownIcon />, iconOpened: <KeyboardArrowDownIcon />,
+4 -6
View File
@@ -13,13 +13,13 @@ export async function middleware(req, next) {
const { origin, pathname } = req.nextUrl; const { origin, pathname } = req.nextUrl;
try { try {
console.log("Test path", pathname, origin); // console.log("Test path", pathname, origin);
if (token) { if (token) {
// Redirect to the home page if already authenticated // Redirect to the home page if already authenticated
NextResponse.redirect(new URL("/"), { status: 201 }); NextResponse.redirect(new URL(pathname, origin), { status: 302 });
next(); // Continue with the request if authenticated
return NextResponse.next();
} }
if ( if (
@@ -43,8 +43,6 @@ export async function middleware(req, next) {
// }); // });
// } // }
// Continue with the request if authenticated
return NextResponse.next();
} catch (error) { } catch (error) {
console.error("Error during authentication check:", error); console.error("Error during authentication check:", error);
return NextResponse.error(); return NextResponse.error();
+1 -1
View File
@@ -14,7 +14,7 @@ const nextConfig = {
i18n: { i18n: {
locales: ['en', 'ar'], locales: ['en', 'ar'],
defaultLocale: 'en', defaultLocale: 'en',
}, }
} }
module.exports = nextConfig module.exports = nextConfig
+3 -6
View File
@@ -16,18 +16,15 @@ import theme from "../styles/theme";
import { ThemeProvider, CssBaseline } from "@mui/material"; import { ThemeProvider, CssBaseline } from "@mui/material";
import Layout from "@/components/_App/Layout"; import Layout from "@/components/_App/Layout";
import AuthRoute from "middlewares/AuthRoute";
function MyApp({ Component, pageProps }) { function MyApp({ Component, pageProps }) {
return ( return (
<> <>
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<CssBaseline /> <CssBaseline />
{/* <AuthRoute> */} <Layout>
<Layout> <Component {...pageProps} />
<Component {...pageProps} /> </Layout>
</Layout>
{/* </AuthRoute> */}
</ThemeProvider> </ThemeProvider>
</> </>
); );
-5
View File
@@ -1,5 +0,0 @@
import SignInForm from "@/components/Authentication/SignInForm";
export default function Index() {
return <SignInForm />;
}
+1 -1
View File
@@ -16,7 +16,7 @@ import TeamMembersList from "@/components/Dashboard/eCommerce/TeamMembersList";
import BestSellingProducts from "@/components/Dashboard/eCommerce/BestSellingProducts"; import BestSellingProducts from "@/components/Dashboard/eCommerce/BestSellingProducts";
import LiveVisitsOnOurSite from "@/components/Dashboard/eCommerce/LiveVisitsOnOurSite"; import LiveVisitsOnOurSite from "@/components/Dashboard/eCommerce/LiveVisitsOnOurSite";
export default function eCommerce() { export default function ECommerce() {
return ( return (
<> <>
{/* Page title */} {/* Page title */}
+9 -83
View File
@@ -1,86 +1,12 @@
import React from "react"; import { useRouter } from "next/router";
import Grid from "@mui/material/Grid"; import ECommerce from "./ecommerce";
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";
import AuthRoute from "middlewares/AuthRoute";
export default function MainPage() { export default function Home() {
return ( const router = useRouter();
<>
{/* Page title */}
<div className={styles.pageTitle}>
<h1>eCommerce</h1>
<ul>
<li>
<Link href="/">Dashboard</Link>
</li>
<li>eCommerce</li>
</ul>
</div>
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 2 }}>
<Grid item xs={12} md={12} lg={12} xl={8}>
{/* Features */}
<Features />
{/* AudienceOverview */}
<AudienceOverview />
<Grid container columnSpacing={{ xs: 1, sm: 2, md: 2 }}>
<Grid item xs={12} md={8}>
{/* VisitsByDay */}
<VisitsByDay />
</Grid>
<Grid item xs={12} md={4}>
{/* Impressions */}
<Impressions />
{/* ActivityTimeline */} console.log("Check pathname: " + router.pathname)
<ActivityTimeline />
</Grid> if (router.pathname === "/") {
<Grid item xs={12} md={12}> return <ECommerce />;
{/* RevenuStatus */} }
<RevenuStatus />
</Grid>
</Grid>
</Grid>
<Grid item xs={12} md={12} lg={12} xl={4}>
{/* Ratings */}
<Ratings />
{/* LiveVisitsOnOurSite */}
<LiveVisitsOnOurSite />
{/* SalesByLocations */}
<SalesByCountries />
{/* NewCustomers */}
<NewCustomers />
</Grid>
</Grid>
{/* Recent Orders */}
<RecentOrders />
<Grid
container
rowSpacing={1}
columnSpacing={{ xs: 1, sm: 1, md: 1, lg: 1, xl: 2 }}
>
<Grid item xs={12} md={12} lg={12} xl={8}>
{/* TeamMembersList */}
<TeamMembersList />
</Grid>
<Grid item xs={12} md={12} lg={12} xl={4}>
{/* BestSellingProducts */}
<BestSellingProducts />
</Grid>
</Grid>
</>
);
} }