()
| 13 | import { Button } from "./ui/button"; |
| 14 | |
| 15 | export default function ProfileDropdown() { |
| 16 | const { t } = useTranslation(); |
| 17 | const updateUserPreference = useUpdateUserPreference(); |
| 18 | const { data: user } = useUser(); |
| 19 | |
| 20 | const { data: config } = useConfig(); |
| 21 | |
| 22 | const isAdmin = user?.id === (config?.ADMIN || 1); |
| 23 | |
| 24 | const handleToggle = () => { |
| 25 | const newTheme = user?.theme === "dark" ? "light" : "dark"; |
| 26 | updateUserPreference.mutate({ theme: newTheme }); |
| 27 | }; |
| 28 | |
| 29 | return ( |
| 30 | <DropdownMenu> |
| 31 | <DropdownMenuTrigger> |
| 32 | <Button variant="ghost" className="rounded-full p-1"> |
| 33 | <ProfilePhoto |
| 34 | src={user?.image ? user?.image : undefined} |
| 35 | priority={true} |
| 36 | /> |
| 37 | </Button> |
| 38 | </DropdownMenuTrigger> |
| 39 | <DropdownMenuContent align="end" className="min-w-40"> |
| 40 | <DropdownMenuItem asChild> |
| 41 | <Link href="/settings/account" className="whitespace-nowrap"> |
| 42 | <i className="bi-gear"></i> |
| 43 | {t("settings")} |
| 44 | </Link> |
| 45 | </DropdownMenuItem> |
| 46 | |
| 47 | <DropdownMenuItem asChild> |
| 48 | <div |
| 49 | onClick={() => handleToggle()} |
| 50 | className="whitespace-nowrap block sm:hidden" |
| 51 | > |
| 52 | {user?.theme === "light" ? ( |
| 53 | <i className="bi-moon-fill"></i> |
| 54 | ) : ( |
| 55 | <i className="bi-sun-fill"></i> |
| 56 | )} |
| 57 | {t("switch_to", { |
| 58 | theme: user?.theme === "light" ? t("dark") : t("light"), |
| 59 | })} |
| 60 | </div> |
| 61 | </DropdownMenuItem> |
| 62 | |
| 63 | {isAdmin && ( |
| 64 | <DropdownMenuItem asChild> |
| 65 | <Link |
| 66 | href="/admin/user-administration" |
| 67 | onClick={() => (document?.activeElement as HTMLElement)?.blur()} |
| 68 | className="whitespace-nowrap" |
| 69 | > |
| 70 | <i className="bi-hdd-stack"></i> |
| 71 | {t("server_administration")} |
| 72 | </Link> |
nothing calls this directly
no test coverage detected