♻️ Minor refactoring (#1683)

This commit is contained in:
Luke Vella 2025-04-23 11:59:25 +01:00 committed by GitHub
parent 86a380dd57
commit 42d0077045
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 54 additions and 73 deletions

View file

@ -24,7 +24,6 @@ import { LogoLink } from "@/app/components/logo-link";
import { Trans } from "@/components/trans"; import { Trans } from "@/components/trans";
import { getUser } from "@/data/get-user"; import { getUser } from "@/data/get-user";
import { FeedbackToggle } from "@/features/feedback/components/feedback-toggle"; import { FeedbackToggle } from "@/features/feedback/components/feedback-toggle";
import { getTranslation } from "@/i18n/server";
import { UpgradeButton } from "../upgrade-button"; import { UpgradeButton } from "../upgrade-button";
import { NavItem } from "./nav-item"; import { NavItem } from "./nav-item";
@ -34,7 +33,6 @@ export async function AppSidebar({
...props ...props
}: React.ComponentProps<typeof Sidebar>) { }: React.ComponentProps<typeof Sidebar>) {
const user = await getUser(); const user = await getUser();
const { t } = await getTranslation();
return ( return (
<Sidebar variant="inset" {...props}> <Sidebar variant="inset" {...props}>
<SidebarHeader> <SidebarHeader>
@ -54,7 +52,9 @@ export async function AppSidebar({
</Link> </Link>
</Button> </Button>
</TooltipTrigger> </TooltipTrigger>
<TooltipContent>Create</TooltipContent> <TooltipContent>
<Trans i18nKey="create" />
</TooltipContent>
</Tooltip> </Tooltip>
</div> </div>
</div> </div>
@ -62,35 +62,18 @@ export async function AppSidebar({
<SidebarContent> <SidebarContent>
<SidebarGroup> <SidebarGroup>
<SidebarMenu> <SidebarMenu>
{/* <NavItem href="/spaces">
<span className="inline-flex size-4 items-center justify-center rounded bg-violet-400 text-xs text-white">
P
</span>
<span className="flex-1">Personal</span>
</NavItem> */}
<NavItem href="/"> <NavItem href="/">
<HomeIcon className="size-4" /> <HomeIcon className="size-4" />
{t("home")} <Trans i18nKey="home" />
</NavItem> </NavItem>
<NavItem href="/polls"> <NavItem href="/polls">
<BarChart2Icon className="size-4" /> <BarChart2Icon className="size-4" />
{t("polls")} <Trans i18nKey="polls" />
</NavItem> </NavItem>
<NavItem href="/events"> <NavItem href="/events">
<CalendarIcon className="size-4" /> <CalendarIcon className="size-4" />
{t("events")} <Trans i18nKey="events" />
</NavItem> </NavItem>
{/* <NavItem href="/teams">
<UsersIcon className="size-4" />
{t("teams", { defaultValue: "Teams" })}
</NavItem>
<NavItem href="/settings">
<SettingsIcon className="size-4" />
{t("settings", { defaultValue: "Settings" })}
</NavItem> */}
{/* <NavItem href="/links" icon={LinkIcon} label="Links" /> */}
{/* <NavItem href="/availability" icon={ClockIcon} label="Availability" /> */}
{/* <NavItem href="/integrations" icon={PuzzleIcon} label="Integrations" /> */}
</SidebarMenu> </SidebarMenu>
</SidebarGroup> </SidebarGroup>
</SidebarContent> </SidebarContent>

View file

@ -7,18 +7,16 @@ import {
PageHeader, PageHeader,
PageTitle, PageTitle,
} from "@/app/components/page-layout"; } from "@/app/components/page-layout";
import { getTranslation } from "@/i18n/server"; import { Trans } from "@/components/trans";
import { SignOutButton } from "./components/sign-out-button"; import { SignOutButton } from "./components/sign-out-button";
import { SettingsLayout } from "./settings-menu"; import { SettingsLayout } from "./settings-menu";
export default async function ProfileLayout({ export default async function ProfileLayout({
children, children,
params, }: {
}: React.PropsWithChildren<{ children?: React.ReactNode;
params: { locale: string }; }) {
}>) {
const { t } = await getTranslation(params.locale);
return ( return (
<PageContainer> <PageContainer>
<PageHeader> <PageHeader>
@ -26,9 +24,7 @@ export default async function ProfileLayout({
<div className="flex-1"> <div className="flex-1">
<PageTitle> <PageTitle>
<SettingsPageIcon /> <SettingsPageIcon />
{t("settings", { <Trans i18nKey="settings" />
defaultValue: "Settings",
})}
</PageTitle> </PageTitle>
</div> </div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">

View file

@ -1,3 +1,5 @@
"use client";
import { usePostHog } from "@rallly/posthog/client"; import { usePostHog } from "@rallly/posthog/client";
import { Button } from "@rallly/ui/button"; import { Button } from "@rallly/ui/button";
import { useToast } from "@rallly/ui/hooks/use-toast"; import { useToast } from "@rallly/ui/hooks/use-toast";

View file

@ -1,18 +1,16 @@
import { Button } from "@rallly/ui/button"; import { Button } from "@rallly/ui/button";
import Link from "next/link"; import Link from "next/link";
import { Trans } from "react-i18next/TransWithoutContext";
import type { Params } from "@/app/[locale]/types";
import { PollPageIcon } from "@/app/components/page-icons"; import { PollPageIcon } from "@/app/components/page-icons";
import { CreatePoll } from "@/components/create-poll"; import { CreatePoll } from "@/components/create-poll";
import { Trans } from "@/components/trans";
import { UserDropdown } from "@/components/user-dropdown"; import { UserDropdown } from "@/components/user-dropdown";
import { getTranslation } from "@/i18n/server"; import { getTranslation } from "@/i18n/server";
import { getLoggedIn } from "@/next-auth"; import { getLoggedIn } from "@/next-auth";
import { BackButton } from "./back-button"; import { BackButton } from "./back-button";
export default async function Page({ params }: { params: Params }) { export default async function Page() {
const { t } = await getTranslation(params.locale);
const isLoggedIn = await getLoggedIn(); const isLoggedIn = await getLoggedIn();
return ( return (
@ -27,7 +25,7 @@ export default async function Page({ params }: { params: Params }) {
<PollPageIcon size="sm" /> <PollPageIcon size="sm" />
<div className="flex items-baseline gap-x-8"> <div className="flex items-baseline gap-x-8">
<h1 className="font-semibold"> <h1 className="font-semibold">
<Trans t={t} i18nKey="poll" defaults="Poll" /> <Trans i18nKey="poll" defaults="Poll" />
</h1> </h1>
</div> </div>
</div> </div>
@ -41,7 +39,7 @@ export default async function Page({ params }: { params: Params }) {
<Link <Link
href={`/login?redirectTo=${encodeURIComponent("/new")}`} href={`/login?redirectTo=${encodeURIComponent("/new")}`}
> >
<Trans i18nKey="login" /> <Trans i18nKey="login" defaults="Login" />
</Link> </Link>
</Button> </Button>
<Button variant="primary" asChild> <Button variant="primary" asChild>

View file

@ -8,7 +8,7 @@ import {
SelectTrigger, SelectTrigger,
SelectValue, SelectValue,
} from "@rallly/ui/select"; } from "@rallly/ui/select";
import { GlobeIcon } from "lucide-react"; import { LanguagesIcon } from "lucide-react";
export const LanguageSelect: React.FunctionComponent<{ export const LanguageSelect: React.FunctionComponent<{
className?: string; className?: string;
@ -20,7 +20,7 @@ export const LanguageSelect: React.FunctionComponent<{
<SelectTrigger asChild className={className}> <SelectTrigger asChild className={className}>
<Button> <Button>
<Icon> <Icon>
<GlobeIcon /> <LanguagesIcon />
</Icon> </Icon>
<SelectValue /> <SelectValue />
</Button> </Button>

View file

@ -1,6 +1,7 @@
"use client"; "use client";
import type { SelectProps } from "@radix-ui/react-select"; import type { SelectProps } from "@radix-ui/react-select";
import { cn } from "@rallly/ui";
import { Badge } from "@rallly/ui/badge"; import { Badge } from "@rallly/ui/badge";
import { Button } from "@rallly/ui/button"; import { Button } from "@rallly/ui/button";
import { import {
@ -15,7 +16,7 @@ import {
import { useDialog } from "@rallly/ui/dialog"; import { useDialog } from "@rallly/ui/dialog";
import { Icon } from "@rallly/ui/icon"; import { Icon } from "@rallly/ui/icon";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { CheckIcon, ChevronsUpDownIcon, GlobeIcon } from "lucide-react"; import { CheckIcon, GlobeIcon } from "lucide-react";
import React from "react"; import React from "react";
import { Trans } from "@/components/trans"; import { Trans } from "@/components/trans";
@ -71,8 +72,10 @@ export const TimeZoneCommand = ({ onSelect, value }: TimeZoneCommandProps) => {
); );
}; };
export const TimeZoneSelect = React.forwardRef<HTMLButtonElement, SelectProps>( export const TimeZoneSelect = React.forwardRef<
({ value, onValueChange, disabled }, ref) => { HTMLButtonElement,
SelectProps & { className?: string }
>(({ value, onValueChange, className, disabled }, ref) => {
const dialog = useDialog(); const dialog = useDialog();
return ( return (
<> <>
@ -88,6 +91,7 @@ export const TimeZoneSelect = React.forwardRef<HTMLButtonElement, SelectProps>(
<Button <Button
ref={ref} ref={ref}
disabled={disabled} disabled={disabled}
className={cn("justify-start text-left", className)}
onClick={() => { onClick={() => {
dialog.trigger(); dialog.trigger();
}} }}
@ -95,14 +99,10 @@ export const TimeZoneSelect = React.forwardRef<HTMLButtonElement, SelectProps>(
<Icon> <Icon>
<GlobeIcon /> <GlobeIcon />
</Icon> </Icon>
{value} <span className="flex-1">{value}</span>
<Icon>
<ChevronsUpDownIcon />
</Icon>
</Button> </Button>
</> </>
); );
}, });
);
TimeZoneSelect.displayName = "TimeZoneSelect"; TimeZoneSelect.displayName = "TimeZoneSelect";

View file

@ -5,3 +5,5 @@ export const supportedLngs = Object.keys(languages);
export const defaultLocale = "en"; export const defaultLocale = "en";
export default languages; export default languages;
export { languages };