Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/components/app/ProfileBanner.tsx
T

57 lines
2.5 KiB
TypeScript

import { useTranslation } from "react-i18next";
import { Link, useParams } from "react-router";
import UserDisplayUtils from "~/utils/app/UserDisplayUtils";
import { UserWithoutPassword } from "~/utils/db/users.db.server";
import UrlUtils from "~/utils/app/UrlUtils";
import { GlobeIcon } from "~/components/ui/icons/vendor";
interface Props {
user: UserWithoutPassword;
}
export default function ProfileBanner({ user }: Props) {
const { t } = useTranslation();
const params = useParams();
return (
<div className="mx-auto max-w-5xl px-4 sm:px-8">
<div className="py-2 md:flex md:items-center md:justify-between">
<div className="min-w-0 flex-1">
{/*Profile */}
<div className="flex items-center">
<Link to={UrlUtils.currentTenantUrl(params, `settings/profile`)} aria-label={t("models.user.avatarAlt")}>
{user?.avatar && <img className="hidden h-12 w-12 rounded-full sm:block" src={user?.avatar} alt={t("models.user.avatarAlt")} />}
</Link>
<div>
<div className="flex items-center">
<div>
{(() => {
if (user?.avatar) {
return <img className="h-12 w-12 rounded-sm sm:hidden" src={user?.avatar} alt={t("models.user.avatarAlt")} />;
} else {
return (
<span className="inline-flex h-12 w-12 items-center justify-center rounded-sm bg-slate-800 shadow-xl sm:hidden">
<span className="text-sm font-medium leading-none text-white">{UserDisplayUtils.avatarText(user)}</span>
</span>
);
}
})()}
</div>
<h1 className="text-foreground ml-3 text-lg font-bold leading-7 sm:truncate sm:leading-9">
{t("shared.hi")} {user?.firstName && <span>{user?.firstName} 👋!</span>}
</h1>
</div>
<dl className="flex flex-col sm:ml-3 sm:flex-row sm:flex-wrap">
<dt className="sr-only">{t("models.user.email")}</dt>
<dd className="text-muted-foreground flex items-center text-xs font-medium lowercase sm:mr-6">
<GlobeIcon className="text-muted-foreground mr-0.5 h-3.5 w-3.5 shrink-0" aria-hidden="true" />
{user?.email}
</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
);
}