Skip to content
Open
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
4 changes: 3 additions & 1 deletion apps/frontend/src/components/layout/settings.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import clsx from 'clsx';
import { TeamsComponent } from '@gitroom/frontend/components/settings/teams.component';
import { useUser } from '@gitroom/frontend/components/layout/user.context';
import { LogoutComponent } from '@gitroom/frontend/components/layout/logout.component';
import { UserInfo } from '@gitroom/frontend/components/layout/user-info.component';
import { useSearchParams } from 'next/navigation';
import { useVariables } from '@gitroom/react/helpers/variable.context';
import { PublicComponent } from '@gitroom/frontend/components/public-api/public.component';
Expand Down Expand Up @@ -141,7 +142,8 @@ export const SettingsPopup: FC<{
</div>
<div>
{showLogout && (
<div className="mt-4">
<div className="mt-4 flex flex-col gap-[12px]">
<UserInfo />
<LogoutComponent />
</div>
)}
Expand Down
65 changes: 65 additions & 0 deletions apps/frontend/src/components/layout/user-info.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
'use client';

import { FC } from 'react';
import { useUser } from '@gitroom/frontend/components/layout/user.context';
import clsx from 'clsx';

interface UserInfoProps {
compact?: boolean;
showEmail?: boolean;
}

export const UserInfo: FC<UserInfoProps> = ({ compact = false, showEmail = true }) => {
const user = useUser();

if (!user) {
return null;
}

const displayName = user.name
? (user.lastName ? `${user.name} ${user.lastName}` : user.name)
: null;

const hasName = !!displayName;
const hasEmail = !!user.email && showEmail;

// If nothing to display, return null
if (!hasName && !hasEmail) {
return null;
}

const avatarSize = compact ? 'w-[32px] h-[32px]' : 'w-[40px] h-[40px]';
const textSize = compact ? 'text-[12px]' : 'text-[14px]';
const emailSize = compact ? 'text-[10px]' : 'text-[12px]';

return (
<div className={clsx(
'flex items-center gap-[12px]',
compact ? 'p-[8px]' : 'p-[12px]'
)}>

{/* Name and Email */}
{(hasName || hasEmail) && (
<div className="flex flex-col min-w-0 flex-1">
{hasName && (
<div className={clsx(
'font-[500] text-newTextColor truncate',
textSize
)}>
{displayName}
</div>
)}
{hasEmail && (
<div className={clsx(
'text-textItemBlur truncate',
emailSize
)}>
{user.email}
</div>
)}
</div>
)}
</div>
);
};