mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
feat: fix bugs in avatar-button.tsx and settings-dialog.tsx because of wrong translation coding
This commit is contained in:
parent
3bd2b5f075
commit
06b6032436
@ -22,7 +22,8 @@ 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 }) => (
|
||||
<Avatar className="h-8 w-8 rounded-lg">
|
||||
@ -47,7 +48,7 @@ export async function AvatarButton() {
|
||||
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 t = await getTranslations('avatar-button');
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
|
@ -31,25 +31,24 @@ 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 (
|
||||
<Dialog open={isDialogOpen} onOpenChange={setDialogOpen}>
|
||||
<DialogContent className="overflow-hidden p-0 md:max-h-[500px] md:max-w-[700px] lg:max-w-[800px]">
|
||||
<DialogTitle className="sr-only">{t('settings')}</DialogTitle>
|
||||
<DialogTitle className="sr-only">{t("settings")}</DialogTitle>
|
||||
<DialogDescription className="sr-only">
|
||||
{t('customize-your-settings-here')}
|
||||
{t("customize-your-settings-here")}
|
||||
</DialogDescription>
|
||||
<SidebarProvider className="items-start">
|
||||
<Sidebar collapsible="none" className="hidden md:flex">
|
||||
@ -57,7 +56,7 @@ export function SettingsDialog() {
|
||||
<SidebarGroup>
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu className="pt-2">
|
||||
{data.nav.map((item) => (
|
||||
{navItems.map((item) => (
|
||||
<SidebarMenuItem key={item.name}>
|
||||
<SidebarMenuButton
|
||||
asChild
|
||||
@ -82,7 +81,7 @@ export function SettingsDialog() {
|
||||
<Breadcrumb>
|
||||
<BreadcrumbList>
|
||||
<BreadcrumbItem className="hidden md:block">
|
||||
<BreadcrumbLink href="#">{t('settings')}</BreadcrumbLink>
|
||||
<BreadcrumbLink href="#">{t("settings")}</BreadcrumbLink>
|
||||
</BreadcrumbItem>
|
||||
<BreadcrumbSeparator className="hidden md:block" />
|
||||
<BreadcrumbItem>
|
||||
@ -94,7 +93,7 @@ export function SettingsDialog() {
|
||||
</header>
|
||||
<ScrollArea className="flex-1 overflow-y-auto p-4 pt-0">
|
||||
<div className="flex flex-col gap-4">
|
||||
{activeSetting === t('appearance') ? (
|
||||
{activeSetting === t("appearance") ? (
|
||||
<AppearanceSettings />
|
||||
) : (
|
||||
Array.from({ length: 10 }).map((_, i) => (
|
||||
|
Loading…
Reference in New Issue
Block a user