diff --git a/src/components/avatar-button.tsx b/src/components/avatar-button.tsx index b8e4b24..96bae05 100644 --- a/src/components/avatar-button.tsx +++ b/src/components/avatar-button.tsx @@ -1,106 +1,107 @@ //avatar-button import { - BadgeCheck, - Bell, - LogIn, - LogOut, + BadgeCheck, + Bell, + LogIn, + LogOut, } from "lucide-react"; import { - Avatar, - AvatarImage, + Avatar, + AvatarImage, } from "@/components/ui/avatar"; import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuGroup, - DropdownMenuItem, - DropdownMenuLabel, - DropdownMenuSeparator, - DropdownMenuTrigger, + DropdownMenu, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { auth, signOut } from "@/lib/auth"; import { redirect } from "next/navigation"; import { Skeleton } from "@/components/ui/skeleton"; import { SettingsButton } from "@/components/settings-button"; -import { useTranslations } from 'next-intl'; +//import { useTranslations } from 'next-intl'; +import { getTranslations } from "next-intl/server"; const UserAvatar = ({ image, name }: { image: string; name: string }) => ( - - - - + + + + ); async function handleSignIn() { - "use server"; - redirect("/sign-in"); + "use server"; + redirect("/sign-in"); } async function handleSignOut() { - "use server"; - await signOut(); + "use server"; + await signOut(); } export async function AvatarButton() { - const session = await auth(); - const isLoggedIn = !!session?.user; - const image = session?.user?.image ?? "https://github.com/shadcn.png"; - const name = session?.user?.name ?? "unknown"; - const email = session?.user?.email ?? "unknwon@example.com"; - const t = useTranslations('avatar-button'); + const session = await auth(); + const isLoggedIn = !!session?.user; + const image = session?.user?.image ?? "https://github.com/shadcn.png"; + const name = session?.user?.name ?? "unknown"; + const email = session?.user?.email ?? "unknwon@example.com"; + const t = await getTranslations('avatar-button'); - return ( - - - - - - {!isLoggedIn ? ( - - - - - {t('log-in')} - - - ) : ( - <> - - + return ( + + - - {name} - {email} - - - - - - - - {t('account')} - - - - Notifications - - - - - - - - - - {t('log-out')} - - > - )} - - - ); + + + {!isLoggedIn ? ( + + + + + {t('log-in')} + + + ) : ( + <> + + + + + {name} + {email} + + + + + + + + {t('account')} + + + + Notifications + + + + + + + + + + {t('log-out')} + + > + )} + + + ); } diff --git a/src/components/settings-dialog.tsx b/src/components/settings-dialog.tsx index 97dbc17..e462264 100644 --- a/src/components/settings-dialog.tsx +++ b/src/components/settings-dialog.tsx @@ -31,84 +31,83 @@ import { useSettingsStore } from "@/stores/useSettingsStore"; import { CodeXml, Globe, Paintbrush, Settings } from "lucide-react"; import { useTranslations } from "next-intl"; -const t = useTranslations('settings'); -const data = { - nav: [ - { name: t('appearance'), icon: Paintbrush }, - { name: t('language-and-region'), icon: Globe }, - { name: t('code-editor'), icon: CodeXml }, - { name: t('advanced'), icon: Settings }, - ], -}; - export function SettingsDialog() { - const { isDialogOpen, activeSetting, setDialogOpen, setActiveSetting } = useSettingsStore(); + const { isDialogOpen, activeSetting, setDialogOpen, setActiveSetting } = + useSettingsStore(); + const t = useTranslations("settings"); + + const navItems = [ + { name: t("appearance"), icon: Paintbrush }, + { name: t("language-and-region"), icon: Globe }, + { name: t("code-editor"), icon: CodeXml }, + { name: t("advanced"), icon: Settings }, + ]; return ( - - - {t('settings')} - - {t('customize-your-settings-here')} - - - - - - - - {data.nav.map((item) => ( - - setActiveSetting(item.name)} - > - - - {item.name} - - - - ))} - - - - - - - - - - - - {t('settings')} - - - - {activeSetting} - - - - - - - - {activeSetting === t('appearance') ? ( - - ) : ( - Array.from({ length: 10 }).map((_, i) => ( - - )) - )} - - - - - - + + + {t("settings")} + + {t("customize-your-settings-here")} + + + + + + + + {navItems.map((item) => ( + + setActiveSetting(item.name)} + > + + + {item.name} + + + + ))} + + + + + + + + + + + + {t("settings")} + + + + {activeSetting} + + + + + + + + {activeSetting === t("appearance") ? ( + + ) : ( + Array.from({ length: 10 }).map((_, i) => ( + + )) + )} + + + + + + ); }