refactor: streamline authentication flow by removing unused code, replacing custom auth utilities with NextAuth, and updating session handling in components
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 5m56s

This commit is contained in:
2025-03-28 22:24:45 +05:00
parent 99c5fef748
commit ef9f032366
10 changed files with 291 additions and 323 deletions

View File

@ -4,33 +4,26 @@ import { Wallet } from "@/components/wallet";
import { ModeToggle } from "@/components/theme-toggle";
import { AppSidebar } from "@/components/ui/app-sidebar";
import { authOptions } from "@/app/auth";
import { Separator } from "@/components/ui/separator";
import {
SidebarInset,
SidebarProvider,
SidebarTrigger,
} from "@/components/ui/sidebar";
import { auth } from "@/app/auth";
import prisma from "@/lib/db";
import { getServerSession } from "next-auth";
import { headers } from "next/headers";
import { AccountPopover } from "./account-popver";
export async function ApplicationLayout({
children,
}: { children: React.ReactNode }) {
const session = await auth.api.getSession({
headers: await headers(),
});
const billFormula = await prisma.billFormula.findFirst();
const user = await prisma.user.findFirst({
where: {
id: session?.user?.id,
},
});
const session = await getServerSession(authOptions);
return (
<SidebarProvider>
<AppSidebar role={session?.user?.role || "USER"} />
<DeviceCartDrawer billFormula={billFormula || null} />
<AppSidebar role={"admin"} />
{/* <DeviceCartDrawer billFormula={billFormula || null} /> */}
<SidebarInset>
<header className="flex justify-between sticky top-0 bg-background h-16 shrink-0 items-center gap-2 border-b px-4 z-10">
<div className="flex items-center gap-2 ">
@ -44,7 +37,7 @@ export async function ApplicationLayout({
</div>
<div className="flex items-center gap-2">
<Wallet walletBalance={user?.walletBalance || 0} />
{/* <Wallet walletBalance={user?.walletBalance || 0} /> */}
<ModeToggle />
<AccountPopover />
</div>