Working on some bugs.

This commit is contained in:
charlesgauthereau
2025-07-27 21:26:31 +02:00
parent f9dc15ba73
commit 85047e7509
107 changed files with 971 additions and 2203 deletions
@@ -0,0 +1,34 @@
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { SidebarMenuButton } from "@/components/ui/sidebar";
import { ChevronUp } from "lucide-react";
import { currentUser } from "@/lib/auth/current-user";
import {LoggedInDropdown} from "@/components/wrappers/dashboard/common/logged-in/logged-in-dropdown";
export const LoggedInButton = async () => {
const user = await currentUser();
if (!user) return null;
return (
<LoggedInDropdown
user={{
...user,
image: user.image ?? null,
role: user.role ?? null,
banned: user.banned ?? null,
banReason: user.banReason ?? null,
banExpires: user.banExpires ?? null,
deletedAt: user.deletedAt ? new Date(user.deletedAt) : null,
}}
>
<SidebarMenuButton>
<Avatar className="size-6">
<AvatarFallback>{user.name[0].toUpperCase()}</AvatarFallback>
{user.image ? <AvatarImage src={user.image} alt={`${user.name ?? "-"}'s profile picture`} /> : null}
</Avatar>
<span className="first-letter:capitalize">{user.name}</span>
<ChevronUp className="ml-auto" />
</SidebarMenuButton>
</LoggedInDropdown>
);
};
@@ -0,0 +1,63 @@
"use client";
import { PropsWithChildren } from "react";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { redirect } from "next/navigation";
import { CircleUser, LogOut, ShieldHalf } from "lucide-react";
import { signOut } from "@/lib/auth/auth-client";
import { useRouter } from "next/navigation";
import { User } from "@/db/schema/01_user";
export type LoggedInDropdownProps = PropsWithChildren<{
user: User;
}>;
export const LoggedInDropdown = (props: LoggedInDropdownProps) => {
const router = useRouter();
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>{props.children}</DropdownMenuTrigger>
<DropdownMenuContent side="top" className="w-[--radix-popper-anchor-width]">
<DropdownMenuItem
onClick={() => {
redirect("/dashboard/profile");
}}
>
<div className="flex justify-start items-center gap-2">
<CircleUser size={16} />
<span>Account</span>
</div>
</DropdownMenuItem>
{(props.user.role === "superadmin" || props.user.role === "admin") && (
<DropdownMenuItem
onClick={() => {
redirect("/dashboard/admin");
}}
>
<div className="flex justify-start items-center gap-2">
<ShieldHalf size={16} />
<span>Administration Panel</span>
</div>
</DropdownMenuItem>
)}
<DropdownMenuItem
onClick={async () => {
await signOut({
fetchOptions: {
onSuccess: () => {
router.push("/login");
},
},
});
}}
>
<div className="flex justify-start items-center gap-2">
<LogOut size={16} />
<span>Log out</span>
</div>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
);
};
@@ -8,8 +8,8 @@ import {
import {SidebarLogo} from "@/components/wrappers/dashboard/common/sidebar/logo-sidebar";
import {SidebarMenuCustomMain} from "@/components/wrappers/dashboard/common/sidebar/menu-sidebar-main";
import {SideBarFooterCredit} from "@/components/wrappers/dashboard/common/sidebar/side-bar-footer-credit";
import {LoggedInButton} from "@/components/wrappers/dashboard/loggedInButton/LoggedInButton";
import {OrganizationCombobox} from "@/components/wrappers/dashboard/organization/organization-combobox";
import {LoggedInButton} from "@/components/wrappers/dashboard/common/logged-in/logged-in-button";
export function AppSidebar() {
@@ -15,6 +15,7 @@ export const SidebarMenuCustomMain = () => {
const member = authClient.useActiveMember();
if (isPending) return null;
if (error || !session) {