diff --git a/public/404.gif b/public/404.gif new file mode 100644 index 000000000..ca8ec2e0c Binary files /dev/null and b/public/404.gif differ diff --git a/src/app/(admin)/_components/layout/Sidebar/index.tsx b/src/app/dashboard/(admin)/_components/layout/Sidebar/index.tsx similarity index 100% rename from src/app/(admin)/_components/layout/Sidebar/index.tsx rename to src/app/dashboard/(admin)/_components/layout/Sidebar/index.tsx diff --git a/src/app/(admin)/_components/layout/Sidebar/sidebar.test.tsx b/src/app/dashboard/(admin)/_components/layout/Sidebar/sidebar.test.tsx similarity index 98% rename from src/app/(admin)/_components/layout/Sidebar/sidebar.test.tsx rename to src/app/dashboard/(admin)/_components/layout/Sidebar/sidebar.test.tsx index 5f6f4a61c..4c35021e9 100644 --- a/src/app/(admin)/_components/layout/Sidebar/sidebar.test.tsx +++ b/src/app/dashboard/(admin)/_components/layout/Sidebar/sidebar.test.tsx @@ -1,7 +1,7 @@ +import Sidebar from "."; import { Box, House, Mail, Settings, Users } from "lucide-react"; import { render, screen } from "~/test/utils"; -import Sidebar from "./"; const sideItems = [ { diff --git a/src/app/(admin)/_components/layout/logo/index.tsx b/src/app/dashboard/(admin)/_components/layout/logo/index.tsx similarity index 100% rename from src/app/(admin)/_components/layout/logo/index.tsx rename to src/app/dashboard/(admin)/_components/layout/logo/index.tsx diff --git a/src/app/(admin)/_components/layout/navbar/index.tsx b/src/app/dashboard/(admin)/_components/layout/navbar/index.tsx similarity index 100% rename from src/app/(admin)/_components/layout/navbar/index.tsx rename to src/app/dashboard/(admin)/_components/layout/navbar/index.tsx diff --git a/src/app/(admin)/_components/layout/navbar/navbar.test.tsx b/src/app/dashboard/(admin)/_components/layout/navbar/navbar.test.tsx similarity index 100% rename from src/app/(admin)/_components/layout/navbar/navbar.test.tsx rename to src/app/dashboard/(admin)/_components/layout/navbar/navbar.test.tsx diff --git a/src/app/(admin)/_components/unread-notification-card/UnreadNotificationCard.tsx b/src/app/dashboard/(admin)/_components/unread-notification-card/UnreadNotificationCard.tsx similarity index 100% rename from src/app/(admin)/_components/unread-notification-card/UnreadNotificationCard.tsx rename to src/app/dashboard/(admin)/_components/unread-notification-card/UnreadNotificationCard.tsx diff --git a/src/app/(admin)/admin/dashboard/page.test.tsx b/src/app/dashboard/(admin)/admin/dashboard/page.test.tsx similarity index 100% rename from src/app/(admin)/admin/dashboard/page.test.tsx rename to src/app/dashboard/(admin)/admin/dashboard/page.test.tsx diff --git a/src/app/(admin)/admin/dashboard/page.tsx b/src/app/dashboard/(admin)/admin/dashboard/page.tsx similarity index 100% rename from src/app/(admin)/admin/dashboard/page.tsx rename to src/app/dashboard/(admin)/admin/dashboard/page.tsx diff --git a/src/app/(admin)/admin/email/_components/Toptab/index.tsx b/src/app/dashboard/(admin)/admin/email/_components/Toptab/index.tsx similarity index 100% rename from src/app/(admin)/admin/email/_components/Toptab/index.tsx rename to src/app/dashboard/(admin)/admin/email/_components/Toptab/index.tsx diff --git a/src/app/(admin)/admin/email/_components/new-template/NewTemplate.test.tsx b/src/app/dashboard/(admin)/admin/email/_components/new-template/NewTemplate.test.tsx similarity index 100% rename from src/app/(admin)/admin/email/_components/new-template/NewTemplate.test.tsx rename to src/app/dashboard/(admin)/admin/email/_components/new-template/NewTemplate.test.tsx diff --git a/src/app/(admin)/admin/email/_components/new-template/NewTemplate.tsx b/src/app/dashboard/(admin)/admin/email/_components/new-template/NewTemplate.tsx similarity index 100% rename from src/app/(admin)/admin/email/_components/new-template/NewTemplate.tsx rename to src/app/dashboard/(admin)/admin/email/_components/new-template/NewTemplate.tsx diff --git a/src/app/(admin)/admin/email/_components/page-header/index.tsx b/src/app/dashboard/(admin)/admin/email/_components/page-header/index.tsx similarity index 100% rename from src/app/(admin)/admin/email/_components/page-header/index.tsx rename to src/app/dashboard/(admin)/admin/email/_components/page-header/index.tsx diff --git a/src/app/(admin)/admin/email/_components/page-header/pageHeader.test.tsx b/src/app/dashboard/(admin)/admin/email/_components/page-header/pageHeader.test.tsx similarity index 100% rename from src/app/(admin)/admin/email/_components/page-header/pageHeader.test.tsx rename to src/app/dashboard/(admin)/admin/email/_components/page-header/pageHeader.test.tsx diff --git a/src/app/(admin)/admin/email/generate-with-html/_components/tips/index.tsx b/src/app/dashboard/(admin)/admin/email/generate-with-html/_components/tips/index.tsx similarity index 100% rename from src/app/(admin)/admin/email/generate-with-html/_components/tips/index.tsx rename to src/app/dashboard/(admin)/admin/email/generate-with-html/_components/tips/index.tsx diff --git a/src/app/(admin)/admin/email/generate-with-html/layout.tsx b/src/app/dashboard/(admin)/admin/email/generate-with-html/layout.tsx similarity index 100% rename from src/app/(admin)/admin/email/generate-with-html/layout.tsx rename to src/app/dashboard/(admin)/admin/email/generate-with-html/layout.tsx diff --git a/src/app/(admin)/admin/email/generate-with-html/page.test.tsx b/src/app/dashboard/(admin)/admin/email/generate-with-html/page.test.tsx similarity index 100% rename from src/app/(admin)/admin/email/generate-with-html/page.test.tsx rename to src/app/dashboard/(admin)/admin/email/generate-with-html/page.test.tsx diff --git a/src/app/(admin)/admin/email/generate-with-html/page.tsx b/src/app/dashboard/(admin)/admin/email/generate-with-html/page.tsx similarity index 100% rename from src/app/(admin)/admin/email/generate-with-html/page.tsx rename to src/app/dashboard/(admin)/admin/email/generate-with-html/page.tsx diff --git a/src/app/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/HtmlTemplateViewer.test.tsx b/src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/HtmlTemplateViewer.test.tsx similarity index 100% rename from src/app/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/HtmlTemplateViewer.test.tsx rename to src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/HtmlTemplateViewer.test.tsx diff --git a/src/app/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/TemplateViewer.tsx b/src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/TemplateViewer.tsx similarity index 100% rename from src/app/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/TemplateViewer.tsx rename to src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/TemplateViewer.tsx diff --git a/src/app/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/index.tsx b/src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/index.tsx similarity index 100% rename from src/app/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/index.tsx rename to src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/index.tsx diff --git a/src/app/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/manual.md b/src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/manual.md similarity index 100% rename from src/app/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/manual.md rename to src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/manual.md diff --git a/src/app/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/template-example.tsx b/src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/template-example.tsx similarity index 100% rename from src/app/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/template-example.tsx rename to src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/_component.tsx/template-example.tsx diff --git a/src/app/(admin)/admin/email/generate-with-html/preview-template/page.testx.tsx b/src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/page.testx.tsx similarity index 100% rename from src/app/(admin)/admin/email/generate-with-html/preview-template/page.testx.tsx rename to src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/page.testx.tsx diff --git a/src/app/(admin)/admin/email/generate-with-html/preview-template/page.tsx b/src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/page.tsx similarity index 56% rename from src/app/(admin)/admin/email/generate-with-html/preview-template/page.tsx rename to src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/page.tsx index 0ce359b88..56b1bf273 100644 --- a/src/app/(admin)/admin/email/generate-with-html/preview-template/page.tsx +++ b/src/app/dashboard/(admin)/admin/email/generate-with-html/preview-template/page.tsx @@ -1,4 +1,4 @@ -import HtmlTemplateViewer from "./_component.tsx"; +import HtmlTemplateViewer from "./_component.tsx/index.jsx"; const page = () => { return ; diff --git a/src/app/(admin)/admin/email/page.test.tsx b/src/app/dashboard/(admin)/admin/email/page.test.tsx similarity index 100% rename from src/app/(admin)/admin/email/page.test.tsx rename to src/app/dashboard/(admin)/admin/email/page.test.tsx diff --git a/src/app/(admin)/admin/email/page.tsx b/src/app/dashboard/(admin)/admin/email/page.tsx similarity index 100% rename from src/app/(admin)/admin/email/page.tsx rename to src/app/dashboard/(admin)/admin/email/page.tsx diff --git a/src/app/(admin)/admin/page.tsx b/src/app/dashboard/(admin)/admin/page.tsx similarity index 100% rename from src/app/(admin)/admin/page.tsx rename to src/app/dashboard/(admin)/admin/page.tsx diff --git a/src/app/(admin)/layout.tsx b/src/app/dashboard/(admin)/layout.tsx similarity index 100% rename from src/app/(admin)/layout.tsx rename to src/app/dashboard/(admin)/layout.tsx diff --git a/src/app/(user-dashboard)/home/page.tsx b/src/app/dashboard/(user-dashboard)/dashboard/page.tsx similarity index 100% rename from src/app/(user-dashboard)/home/page.tsx rename to src/app/dashboard/(user-dashboard)/dashboard/page.tsx diff --git a/src/app/(user-dashboard)/layout.tsx b/src/app/dashboard/(user-dashboard)/layout.tsx similarity index 100% rename from src/app/(user-dashboard)/layout.tsx rename to src/app/dashboard/(user-dashboard)/layout.tsx diff --git a/src/app/(user-dashboard)/products/_components/product-body-shadcn.tsx b/src/app/dashboard/(user-dashboard)/products/_components/product-body-shadcn.tsx similarity index 100% rename from src/app/(user-dashboard)/products/_components/product-body-shadcn.tsx rename to src/app/dashboard/(user-dashboard)/products/_components/product-body-shadcn.tsx diff --git a/src/app/(user-dashboard)/products/_components/product-content.tsx b/src/app/dashboard/(user-dashboard)/products/_components/product-content.tsx similarity index 100% rename from src/app/(user-dashboard)/products/_components/product-content.tsx rename to src/app/dashboard/(user-dashboard)/products/_components/product-content.tsx diff --git a/src/app/(user-dashboard)/products/_components/product-detail-modal.tsx b/src/app/dashboard/(user-dashboard)/products/_components/product-detail-modal.tsx similarity index 100% rename from src/app/(user-dashboard)/products/_components/product-detail-modal.tsx rename to src/app/dashboard/(user-dashboard)/products/_components/product-detail-modal.tsx diff --git a/src/app/(user-dashboard)/products/_components/product-detail-view.tsx b/src/app/dashboard/(user-dashboard)/products/_components/product-detail-view.tsx similarity index 100% rename from src/app/(user-dashboard)/products/_components/product-detail-view.tsx rename to src/app/dashboard/(user-dashboard)/products/_components/product-detail-view.tsx diff --git a/src/app/(user-dashboard)/products/_components/product-filter.tsx b/src/app/dashboard/(user-dashboard)/products/_components/product-filter.tsx similarity index 100% rename from src/app/(user-dashboard)/products/_components/product-filter.tsx rename to src/app/dashboard/(user-dashboard)/products/_components/product-filter.tsx diff --git a/src/app/(user-dashboard)/products/_components/product-header.tsx b/src/app/dashboard/(user-dashboard)/products/_components/product-header.tsx similarity index 100% rename from src/app/(user-dashboard)/products/_components/product-header.tsx rename to src/app/dashboard/(user-dashboard)/products/_components/product-header.tsx diff --git a/src/app/(user-dashboard)/products/data/product.mock.ts b/src/app/dashboard/(user-dashboard)/products/data/product.mock.ts similarity index 100% rename from src/app/(user-dashboard)/products/data/product.mock.ts rename to src/app/dashboard/(user-dashboard)/products/data/product.mock.ts diff --git a/src/app/(user-dashboard)/products/page.test.tsx b/src/app/dashboard/(user-dashboard)/products/page.test.tsx similarity index 100% rename from src/app/(user-dashboard)/products/page.test.tsx rename to src/app/dashboard/(user-dashboard)/products/page.test.tsx diff --git a/src/app/(user-dashboard)/products/page.tsx b/src/app/dashboard/(user-dashboard)/products/page.tsx similarity index 100% rename from src/app/(user-dashboard)/products/page.tsx rename to src/app/dashboard/(user-dashboard)/products/page.tsx diff --git a/src/app/(user-dashboard)/settings/page.tsx b/src/app/dashboard/(user-dashboard)/settings/page.tsx similarity index 100% rename from src/app/(user-dashboard)/settings/page.tsx rename to src/app/dashboard/(user-dashboard)/settings/page.tsx diff --git a/src/app/globals.css b/src/app/globals.css index c9f7dbcc5..fa37ea739 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -17,6 +17,7 @@ --default-foreground: 0 0% 100%; --primary: 25 95% 53%; + --primary-foreground: 0 0% 100%; --secondary: 210 40% 96.1%; diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx new file mode 100644 index 000000000..b2dc0240f --- /dev/null +++ b/src/app/not-found.tsx @@ -0,0 +1,52 @@ +"use client"; + +import { ArrowLeft, Home } from "lucide-react"; +import Image from "next/image"; +import Link from "next/link"; +import { useRouter } from "next/navigation"; + +import Particles404 from "~/components/error/Particles404"; + +const NotFoundPage = () => { + const router = useRouter(); + + return ( +
+
+ +
+

+ Page Not Found +

+ 404 +
+ + + + Home + +
+
+
+ ); +}; + +export default NotFoundPage; diff --git a/src/components/error/Particles404.tsx b/src/components/error/Particles404.tsx new file mode 100644 index 000000000..07b5101e1 --- /dev/null +++ b/src/components/error/Particles404.tsx @@ -0,0 +1,51 @@ +import React, { useEffect } from "react"; + +import useWindowWidth from "~/hooks/use-window-width"; +import { handleMouseEnter } from "~/lib/utils"; +import { particlesCanvas } from "./particles"; + +const Particles404 = () => { + const canvaReference = React.useRef(null); + const { winWidth } = useWindowWidth(); + + useEffect(() => { + setTimeout(() => { + if (!canvaReference.current) return; + particlesCanvas(canvaReference.current); + }, 500); + }, [winWidth]); + return ( +
+ +
+

+ Hng-boilerplate +

+
+
+

+ 404 +

+

+ This is not the page
you are looking for +

+
+
+ ); +}; + +export default Particles404; diff --git a/src/components/error/particles.ts b/src/components/error/particles.ts new file mode 100644 index 000000000..4c801df8e --- /dev/null +++ b/src/components/error/particles.ts @@ -0,0 +1,152 @@ +interface Mouse { + radius: number; + x: number; + y: number; +} + +export function particlesCanvas(canvasElement: HTMLCanvasElement) { + const context = canvasElement.getContext("2d"); + + const canvas = canvasElement; + canvas.width = window.innerWidth * window.devicePixelRatio; + canvas.height = window.innerHeight * window.devicePixelRatio; + + canvas.style.width = `${window.innerWidth}px`; + canvas.style.height = `${window.innerHeight}px`; + + // Particles Class + class Particle { + private originX: number; + private originY: number; + private x: number; + private y: number; + private effect: Effect; + private ctx: CanvasRenderingContext2D; + private vx: number; + private vy: number; + private ease: number; + private friction: number; + private dx: number; + private dy: number; + private distance: number; + private force: number; + private angle: number; + private size: number; + public spread: number; + + constructor(x: number, y: number, effect: Effect) { + this.originX = x; + this.originY = y; + this.effect = effect; + this.x = Math.floor(x); + this.y = Math.floor(y); + this.ctx = effect.ctx; + this.ctx.fillStyle = "#f97415"; + this.vx = 0; + this.vy = 0; + this.ease = 0.05; + this.friction = 0.9; + this.dx = 0; + this.dy = 0; + this.distance = 0; + this.force = 0; + this.angle = 0; + // this.size = Math.floor(Math.random() * 5 + 2); + this.size = 3; + this.spread = 20; + this.draw(); + } + draw() { + this.ctx.beginPath(); + this.ctx.fillRect(this.x, this.y, this.size, this.size); + } + update() { + this.dx = this.effect.mouse.x - this.x; + this.dy = this.effect.mouse.y - this.y; + this.distance = this.dx * this.dx + this.dy * this.dy; + this.force = (-this.effect.mouse.radius / this.distance) * this.spread; + + if (this.distance < this.effect.mouse.radius) { + this.angle = Math.atan2(this.dy, this.dx); + this.vx += this.force * Math.cos(this.angle); + this.vy += this.force * Math.sin(this.angle); + } + + this.x += + (this.vx *= this.friction) + (this.originX - this.x) * this.ease; + this.y += + (this.vy *= this.friction) + (this.originY - this.y) * this.ease; + this.draw(); + } + } + + // Effect class + class Effect { + private width: number; + private height: number; + private gap: number; + public ctx: CanvasRenderingContext2D; + private particlesArray: Particle[]; + public readonly mouse: Mouse; + constructor( + width: number, + height: number, + context: CanvasRenderingContext2D, + ) { + this.width = width; + this.height = height; + this.ctx = context; + this.particlesArray = []; + this.gap = 20; + this.mouse = { + radius: 3000, + x: 0, + y: 0, + }; + + window.addEventListener("mousemove", (event) => { + this.mouse.x = event.clientX * window.devicePixelRatio; + this.mouse.y = event.pageY * window.devicePixelRatio; + this.mouse.radius = 3000; + }); + window.addEventListener("mouseout", () => { + this.mouse.x = 0; + this.mouse.y = 0; + this.mouse.radius = 0; + }); + window.addEventListener("resize", () => { + canvas.width = window.innerWidth * window.devicePixelRatio; + canvas.height = window.innerHeight * window.devicePixelRatio; + this.width = canvas.width; + this.height = canvas.height; + + canvas.style.width = `${window.innerWidth}px`; + canvas.style.height = `${window.innerHeight}px`; + + this.particlesArray = []; + }); + + this.init(); + } + + init() { + for (let x = 0; x < this.width; x += this.gap) { + for (let y = 0; y < this.height; y += this.gap) { + this.particlesArray.push(new Particle(x, y, this)); + } + } + } + update() { + this.ctx.clearRect(0, 0, this.width, this.height); + for (let index = 0; index < this.particlesArray.length; index++) { + this.particlesArray[index].update(); + } + } + } + const effect = new Effect(canvas.width, canvas.height, context!); + function animate() { + effect.update(); + requestAnimationFrame(animate); + } + animate(); +} diff --git a/src/lib/routes.ts b/src/lib/routes.ts new file mode 100644 index 000000000..f406f5888 --- /dev/null +++ b/src/lib/routes.ts @@ -0,0 +1,47 @@ +/** + * An array of routes that are accessible to the public + * These routes do not require authentication + * @type {string[]} + */ +export const publicRoutes = [ + "/", + "/career", + "/faqs", + "privacy-policy", + "/terms", + "/about-us", + "/pricing", + "/contact-us", + "/waitlist", + "/blog", +]; + +export const authRoutes = [ + "/sign-up", + "/login", + "/forgot-password", + "/reset-password", + "/verify-otp", + "/recovery", +]; + +export const apiAuthPrefix = "/api/"; + +/** + * The default redirect after login + * @type {string} + */ +export const DEFAULT_LOGIN_REDIRECT = "/dashboard"; + +/** + * An array of routes that are accessible to the client + * These routes require authentication + * @type {string[]} + */ +export const clientRoutes = [ + "/dashboard", + "/hisory", + "messages", + "/notifications", + "/profile", +]; diff --git a/src/lib/utils.ts b/src/lib/utils.ts index d1fd562a7..a08136474 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -23,3 +23,51 @@ export function formatPrice( }).format(numericPrice); return newPrice; } + +const letters = "!ABCDEFGHIJKLMNOPQRSTUVWXYZ#"; + +export const handleMouseEnter = (event: MouseEvent) => { + if (!event) return; + const element = event.target as HTMLDivElement; + let iteration: number = 0; + const speed: number = element.dataset.value!.length > 7 ? 30 : 60; + + let lastTimestamp: number; + let animationFrameId: number | null; + + const animate = (timestamp: number) => { + if (!lastTimestamp) { + lastTimestamp = timestamp; + } + + // deltaTime is the time elapsed since the last animation frame + // I use am to reduce or increase speed + const deltaTime = timestamp - lastTimestamp; + + if (deltaTime >= speed) { + // @ts-expect-error Hacking the type + element!.textContent! = [...element!.textContent!] + .map((_: string, index: number) => { + if (index < iteration) { + return element.dataset.value![index]; + } + + return letters[Math.floor(Math.random() * letters.length)]; + }) + .join(""); + + if (iteration >= element.dataset.value!.length) { + // Stop the animation if completed + return; + } + + iteration += 1 / 3; + lastTimestamp = timestamp; + } + + animationFrameId = requestAnimationFrame(animate); + }; + + cancelAnimationFrame(animationFrameId!); + animationFrameId = requestAnimationFrame(animate); +}; diff --git a/src/middleware.ts b/src/middleware.ts new file mode 100644 index 000000000..28546a12a --- /dev/null +++ b/src/middleware.ts @@ -0,0 +1,50 @@ +import { NextRequest, NextResponse } from "next/server"; + +import { apiAuthPrefix, authRoutes, publicRoutes } from "~/lib/routes"; + +const NEXT_PUBLIC_ROOT_DOMAIN = "hng-boilerplate.com"; +export default async function middleware(request: NextRequest) { + const { nextUrl } = request; + + const isLoggedIn = true; + + const isApiAuthRoute = nextUrl.pathname.startsWith(apiAuthPrefix); + const isPublicRoute = publicRoutes.includes(nextUrl.pathname); + const isAuthRoute = authRoutes.includes(nextUrl.pathname); + + if (isApiAuthRoute || isPublicRoute) return; + + const url = request.nextUrl; + let hostname = request.headers + .get("host")! + .replace(".localhost:3000", ".hng-boilerplate.com"); + + hostname = hostname.replace("www.", ""); // remove www. from domain + const searchParameters = request.nextUrl.searchParams.toString(); + // Get the pathname of the request (e.g. /, /about, /blog/first-post) + const path = `${url.pathname}${ + searchParameters.length > 0 ? `?${searchParameters}` : "" + }`; + + //rewrites for dashboard pages and dev subdomains + if (hostname == `dashboard.${NEXT_PUBLIC_ROOT_DOMAIN}`) { + if (!isLoggedIn && !isAuthRoute) { + return Response.redirect( + new URL(`/login?callbackUrl=${nextUrl.pathname}`, nextUrl), + ); + } else if (isLoggedIn && isAuthRoute) { + return Response.redirect(new URL("/", nextUrl)); + } + return NextResponse.rewrite( + new URL(`/dashboard${path === "/" ? "/" : path}`, request.url), + ); + } + + return; +} + +// Optionally, don't invoke Middleware on some paths +export const config = { + // eslint-disable-next-line unicorn/prefer-string-raw + matcher: ["/((?!.+\\.[\\w]+$|_next).*)", "/", "/(api|trpc)(.*)"], +};