Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use workspace name in team switcher #2719

Merged
merged 1 commit into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dashboard/app/(app)/desktop-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const DesktopSidebar: React.FC<Props> = ({ workspace, className }) => {
)}
>
<div className="flex min-w-full mt-2 -mx-2">
<WorkspaceSwitcher />
<WorkspaceSwitcher workspace={workspace} />
</div>
{workspace.planDowngradeRequest ? (
<div className="flex justify-center w-full mt-2">
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/app/(app)/mobile-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const MobileSideBar = ({ className, workspace }: Props) => {
<SheetTrigger>
<Menu className="w-6 h-6 " />
</SheetTrigger>
<WorkspaceSwitcher />
<WorkspaceSwitcher workspace={workspace} />
</div>
<UserButton />
</div>
Expand Down
19 changes: 10 additions & 9 deletions apps/dashboard/app/(app)/team-switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ import { useOrganization, useOrganizationList, useUser } from "@clerk/nextjs";
import { ScrollArea } from "@/components/ui/scroll-area";
import Link from "next/link";

export const WorkspaceSwitcher: React.FC = (): JSX.Element => {
type Props = {
workspace: {
name: string;
};
};
export const WorkspaceSwitcher: React.FC<Props> = (props): JSX.Element => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export const WorkspaceSwitcher: React.FC<Props> = (props): JSX.Element =>

It's a nitpick but maybe just this 👇🏻 ?
export const WorkspaceSwitcher = (props: Props) =>

const { isLoaded, setActive, userMemberships } = useOrganizationList({
userMemberships: {
infinite: true,
Expand Down Expand Up @@ -63,17 +68,15 @@ export const WorkspaceSwitcher: React.FC = (): JSX.Element => {
<div className="flex items-center gap-2 overflow-hidden whitespace-nowrap">
<Avatar className="w-5 h-5">
{currentOrg?.imageUrl ? (
<AvatarImage src={currentOrg.imageUrl} alt={currentOrg.name ?? "Profile picture"} />
<AvatarImage src={currentOrg.imageUrl} alt={props.workspace.name} />
) : user?.imageUrl ? (
<AvatarImage
src={user.imageUrl}
alt={user?.username ?? user?.fullName ?? "Profile picture"}
/>
) : null}
<AvatarFallback className="flex items-center justify-center w-8 h-8 text-gray-700 bg-gray-100 border border-gray-500 rounded">
{(currentOrg?.name ?? user?.username ?? user?.fullName ?? "")
.slice(0, 2)
.toUpperCase() ?? "P"}
{props.workspace.name.slice(0, 2).toUpperCase()}
</AvatarFallback>
</Avatar>
{!isLoaded ? (
Expand All @@ -82,13 +85,11 @@ export const WorkspaceSwitcher: React.FC = (): JSX.Element => {
<Tooltip>
<TooltipTrigger asChild>
<span className="overflow-hidden text-sm font-medium text-ellipsis">
{currentOrg?.name ?? "Personal Workspace"}
{props.workspace.name}
</span>
</TooltipTrigger>
<TooltipContent>
<span className="text-sm font-medium">
{currentOrg?.name ?? "Personal Workspace"}
</span>
<span className="text-sm font-medium">{props.workspace.name}</span>
</TooltipContent>
</Tooltip>
)}
Expand Down
Loading