Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .hintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
"development"
],
"hints": {
"typescript-config/consistent-casing": "off"
"typescript-config/consistent-casing": "off",
"axe/forms": [
"default",
{
"label": "off"
}
]
}
}
4 changes: 2 additions & 2 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bun run build
git pull --rebase origin main
bun run build
# git pull --rebase origin main
23 changes: 23 additions & 0 deletions .husky/pre-rebase
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# #!/bin/sh
# . "$(dirname "$0")/_/husky.sh"

# # Get the current branch name before rebase
# current_branch=$(git rev-parse --abbrev-ref HEAD)

# # Fetch latest changes from origin/main
# git fetch origin main

# # Count the number of commits ahead of origin/main
# commit_count=$(git rev-list --count origin/main..HEAD)

# # If more than one commit exists, abort rebase
# if [ "$commit_count" -gt 1 ]; then
# echo "❌ Rebase aborted: More than one commit ahead of origin/main ($commit_count commits)."
# echo "🔄 Please squash your commits first, then run 'git rebase'."
# exit 1
# fi

# # Ensure we stay on the correct branch
# git checkout "$current_branch" 2>/dev/null || true

# echo "✅ Rebase can proceed. Only one or no commits ahead of main."
76 changes: 76 additions & 0 deletions apps/core/app/dashboard/_compnents/app-sidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"use client";

import * as React from "react";

//components ui
import {
Sidebar,
SidebarContent,
SidebarHeader,
SidebarRail,
useSidebar,
} from "@repo/ui/components/sidebar";

//icons
import BoxPackage from "@repo/icons/box-package";
import ChartBarPopular from "@repo/icons/chart-bar-popular";
import LayoutDashboard from "@repo/icons/layout-dashboard";
import ReportMoney from "@repo/icons/report-money";
import Usericon from "@repo/icons/user";

//components sidebar
import Settingsicon from "@repo/icons/settings";
import { LogoIconSwitcher } from "./logo-icon-switcher";
import { NavMain } from "./nav-main";

// This is items of dashboard.
const data = {
navMain: [
{
title: "Dashboard",
url: "/dashboard",
icon: LayoutDashboard,
},
{
title: "Products",
url: "/products",
icon: BoxPackage,
},
{
title: "Sales",
url: "/sales",
icon: ChartBarPopular,
},
{
title: "Profile",
url: "/profile",
icon: Usericon,
},
{
title: "Payouts",
url: "/payouts",
icon: ReportMoney,
},
{
title: "Settings",
url: "/settings",
icon: Settingsicon,
},
],
};

export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
const { open, isMobile } = useSidebar();

Comment on lines +62 to +64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove unused destructured variables.

The open and isMobile variables are destructured from useSidebar but never used.

 export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
-  const { open, isMobile } = useSidebar();
+  useSidebar(); // Remove if not needed, or keep only required variables
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
const { open, isMobile } = useSidebar();
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
useSidebar(); // Remove if not needed, or keep only required variables

return (
<Sidebar collapsible="icon" className="" {...props}>
<SidebarHeader className="pt-5 pb-6">
<LogoIconSwitcher />
</SidebarHeader>
<SidebarContent>
<NavMain items={data.navMain} />
</SidebarContent>
<SidebarRail />
</Sidebar>
);
}
46 changes: 46 additions & 0 deletions apps/core/app/dashboard/_compnents/logo-icon-switcher.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import * as React from "react";
import { motion, AnimatePresence } from "framer-motion";

// UI components
import {
SidebarMenu,
SidebarMenuItem,
useSidebar,
} from "@repo/ui/components/sidebar";

// Logo
import PixelIcon from "@repo/icons/pxiel";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix typo in import path

There's a typo in the import path: @repo/icons/pxiel should be @repo/icons/pixel.

-import PixelIcon from "@repo/icons/pxiel";
+import PixelIcon from "@repo/icons/pixel";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import PixelIcon from "@repo/icons/pxiel";
import PixelIcon from "@repo/icons/pixel";

import { cn } from "@repo/ui/lib/utils";

export function LogoIconSwitcher() {
const { open } = useSidebar();

return (
<SidebarMenu>
<SidebarMenuItem
className={"flex items-center flex-1 space-x-2 pl-2"}
style={{
justifyContent: open ? "flex-start" : "center",
}}
>
{/* Ensure icon remains centered */}
<div className="flex aspect-square relative z-50 size-9 shrink-0 items-center justify-center rounded-lg text-sidebar-primary-foreground">
<PixelIcon size={46} color="currentColor" />
</div>

{/* Animate text visibility but maintain spacing */}
<AnimatePresence>
{open && (
<motion.div
className="grid absolute left-12 flex-shrink text-left text-lg leading-tight overflow-hidden"
exit={{ opacity: 0, scale: 0 }}
transition={{ duration: 0.2 }}
>
<span className="truncate font-semibold">PixelGenius</span>
</motion.div>
)}
</AnimatePresence>
</SidebarMenuItem>
</SidebarMenu>
);
}
39 changes: 39 additions & 0 deletions apps/core/app/dashboard/_compnents/nav-main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {
SidebarGroup,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
} from "@repo/ui/components/sidebar";
import { usePathname } from "next/navigation";

export function NavMain({
items,
}: {
items: {
title: string;
url: string;
icon: React.ElementType;
}[];
}) {
const pathname = usePathname();

return (
<SidebarGroup>
<SidebarMenu>
{items.map((item) => (
<SidebarMenuItem
className={`${pathname === item.url ? "bg-sidebar-accent text-secondary-100 rounded-md text-[#6751D6]" : ""}`}
key={item.title}
>
<SidebarMenuButton asChild>
<a className="py-6" href={item.url}>
<item.icon />
<span>{item.title}</span>
</a>
</SidebarMenuButton>
Comment on lines +24 to +33
Copy link
Contributor

@coderabbitai coderabbitai bot Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Enhance accessibility and UX

The navigation items need accessibility improvements and better active state handling.

Apply these changes:

 <SidebarMenuItem
-  className={`${pathname === item.url ? "bg-sidebar-accent text-secondary-100 rounded-md text-[#6751D6]" : ""}`}
+  className={cn(
+    "transition-colors duration-200",
+    pathname === item.url && "bg-sidebar-accent text-secondary-100 rounded-md text-[#6751D6]"
+  )}
   key={item.title}
 >
   <SidebarMenuButton asChild>
-    <a className="py-6" href={item.url}>
+    <a 
+      className="py-6"
+      href={item.url}
+      aria-current={pathname === item.url ? 'page' : undefined}
+      role="menuitem"
+    >
       <item.icon />
-      <span>{item.title}</span>
+      <span className="sr-only md:not-sr-only">{item.title}</span>
     </a>
   </SidebarMenuButton>
 </SidebarMenuItem>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<SidebarMenuItem
className={`${pathname === item.url ? "bg-sidebar-accent text-secondary-100 rounded-md text-[#6751D6]" : ""}`}
key={item.title}
>
<SidebarMenuButton asChild>
<a className="py-6" href={item.url}>
<item.icon />
<span>{item.title}</span>
</a>
</SidebarMenuButton>
<SidebarMenuItem
className={cn(
"transition-colors duration-200",
pathname === item.url && "bg-sidebar-accent text-secondary-100 rounded-md text-[#6751D6]"
)}
key={item.title}
>
<SidebarMenuButton asChild>
<a
className="py-6"
href={item.url}
aria-current={pathname === item.url ? 'page' : undefined}
role="menuitem"
>
<item.icon />
<span className="sr-only md:not-sr-only">{item.title}</span>
</a>
</SidebarMenuButton>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please used cn function
link => next js

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrbadri, here’s an updated snippet that applies the cn function and adds Next.js-friendly accessibility attributes:

TypeScript JSX code:

import { cn } from "@/lib/utils"; // or wherever your cn helper is defined

<SidebarMenuItem
className={cn(
"transition-colors duration-200",
pathname === item.url && "bg-sidebar-accent text-secondary-100 rounded-md text-[#6751D6]"
)}
key={item.title}

{item.title}

</SidebarMenuItem>
))}
</SidebarMenu>
</SidebarGroup>
);
}
13 changes: 13 additions & 0 deletions apps/core/app/dashboard/_compnents/navbar-dashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { SidebarTrigger } from "@repo/ui/components/sidebar";

const NavbarDashboard = () => {
return (
<nav className="bg-sidebar flex items-center justify-between">
<div className="w-full">
<SidebarTrigger />
</div>
</nav>
);
};

export default NavbarDashboard;
62 changes: 0 additions & 62 deletions apps/core/app/dashboard/_compnents/sidebar.tsx

This file was deleted.

15 changes: 10 additions & 5 deletions apps/core/app/dashboard/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import React from "react";
import SideBarDashboard from "./_compnents/sidebar";
import { SidebarProvider } from "@repo/ui/components/sidebar";
import { AppSidebar } from "./_compnents/app-sidebar";
import NavbarDashboard from "./_compnents/navbar-dashboard";
Comment on lines +3 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct the typos in import paths

The directory name _compnents should be corrected to _components in the import statements.

Suggested change:

-import { AppSidebar } from "./_compnents/app-sidebar";
-import NavbarDashboard from "./_compnents/navbar-dashboard";
+import { AppSidebar } from "./_components/app-sidebar";
+import NavbarDashboard from "./_components/navbar-dashboard";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { AppSidebar } from "./_compnents/app-sidebar";
import NavbarDashboard from "./_compnents/navbar-dashboard";
import { AppSidebar } from "./_components/app-sidebar";
import NavbarDashboard from "./_components/navbar-dashboard";


export default function DashboardLayout({
children,
}: {
children: React.ReactNode;
}): JSX.Element {
return (
<div className="flex h-full">
<SideBarDashboard />
<div className="flex-1">{children}</div>
</div>
<SidebarProvider className="flex h-full ">
<AppSidebar />
<main className="flex-1">
<NavbarDashboard />
{children}
</main>
</SidebarProvider>
);
}
2 changes: 1 addition & 1 deletion apps/core/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const DashboardPage = () => {
<div className="container mx-auto">
<div className="pt-14">
<div className="flex justify-between">
<Tabs defaultValue="account" className="w-screen">
<Tabs defaultValue="account" className="w-full">
<TabsList>
<TabsTrigger value="General">General</TabsTrigger>
<TabsTrigger value="Images">Images</TabsTrigger>
Expand Down
10 changes: 5 additions & 5 deletions apps/core/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export function middleware(request: NextRequest) {
const isDashboard = pathname.startsWith("/dashboard");

// Redirect to login if unauthenticated
if (isDashboard) {
if (!accessToken || !refreshToken) {
return NextResponse.redirect(new URL("/auth/login", request.url));
}
}
// if (isDashboard) {
// if (!accessToken || !refreshToken) {
// return NextResponse.redirect(new URL("/auth/login", request.url));
// }
// }
Comment on lines +12 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

CRITICAL: Restore authentication checks for dashboard routes.

Commenting out the authentication middleware for dashboard routes creates a significant security vulnerability by allowing unauthorized access to potentially sensitive dashboard content. This change doesn't appear to be necessary for implementing the new sidebar feature.

Please restore the authentication checks by removing the comments:

-  // if (isDashboard) {
-  //   if (!accessToken || !refreshToken) {
-  //     return NextResponse.redirect(new URL("/auth/login", request.url));
-  //   }
-  // }
+  if (isDashboard) {
+    if (!accessToken || !refreshToken) {
+      return NextResponse.redirect(new URL("/auth/login", request.url));
+    }
+  }

If there's a specific reason why authentication needs to be disabled for the dashboard, please:

  1. Explain the rationale in the PR description
  2. Consider adding a temporary development-only flag instead of removing the checks entirely
  3. Create a separate security-focused PR for this change instead of bundling it with UI updates
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// if (isDashboard) {
// if (!accessToken || !refreshToken) {
// return NextResponse.redirect(new URL("/auth/login", request.url));
// }
// }
if (isDashboard) {
if (!accessToken || !refreshToken) {
return NextResponse.redirect(new URL("/auth/login", request.url));
}
}


// Allow access to protected routes if authenticated
return NextResponse.next();
Expand Down
3 changes: 2 additions & 1 deletion apps/core/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

// https://s3-alpha-sig.figma.com/img/ce79/f737/ea54458a8146c4935
//https://images.unsplash.com/photo-1730292422804-5bbb2bd2d3f0?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D
// https://github.com/shadcn.png
// config src image
const nextConfig = {
transpilePackages: ["@repo/ui"],
images: {
domains: ["images.unsplash.com"],
domains: ["images.unsplash.com", "github.com/shadcn.png"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the incorrect domain format for GitHub images.

The domain "github.com/shadcn.png" is incorrectly formatted as it includes the full path. Next.js domains should only include the hostname.

Apply this diff to fix the domain:

-    domains: ["images.unsplash.com", "github.com/shadcn.png"],
+    domains: ["images.unsplash.com", "github.com", "avatars.githubusercontent.com"],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
domains: ["images.unsplash.com", "github.com/shadcn.png"],
domains: ["images.unsplash.com", "github.com", "avatars.githubusercontent.com"],

},
output: "standalone",
};
Expand Down
Loading
Loading