sendou.ink/app/components/layout/UserItem.tsx
Kalle 323a1ea5e3 Remove useTranslation wrapper Closes #1595
This broke after upgrading deps and couldn't figure it out with a quick look.

It just makes it a bit more convenient when adding new pages & debugging
but not really that necessary so decided to delete it for now.
2023-12-07 20:33:59 +02:00

42 lines
1.0 KiB
TypeScript

import { Link } from "@remix-run/react";
import { useTranslation } from "react-i18next";
import { useUser } from "~/features/auth/core";
import { userPage } from "~/utils/urls";
import { Avatar } from "../Avatar";
import { LogInIcon } from "../icons/LogIn";
import { LogInButtonContainer } from "./LogInButtonContainer";
import { useRootLoaderData } from "~/hooks/useRootLoaderData";
export function UserItem() {
const data = useRootLoaderData();
const { t } = useTranslation();
const user = useUser();
if (user) {
return (
<Link to={userPage(user)} prefetch="intent">
<Avatar
user={user}
alt={t("header.loggedInAs", {
userName: `${user.discordName}`,
})}
className="layout__avatar"
size="sm"
/>
</Link>
);
}
if (data.loginDisabled) {
return false;
}
return (
<LogInButtonContainer>
<button type="submit" className="layout__log-in-button">
<LogInIcon /> {t("header.login")}
</button>
</LogInButtonContainer>
);
}