sendou.ink/app/components/layout/UserItem.tsx
Kalle 185295d54e
User page initial with SQLite3 (#822)
* Clean away prisma migrations

* Way to migrate WIP

* SQLite3 seeding script initial

* Fetch tournament data in loader

* CheckinActions new loader data model

* Virtual banner text color columns

* Logged in user

* Count teams

* ownTeam

* Map pool tab fully working

* Teams tab

* Fix timestamp default

* Register page

* Manage team page

* Camel case checkedInTimestamp

* Clean slate

* Add .nvmrc

* Add favicon

* Package lock file version 2

* Update tsconfig

* Add Tailwind

* Add StrictMode

* Add background color

* Auth without DB

* Revert "Add Tailwind"

This reverts commit 204713c602.

* Auth with DB

* Switch back to tilde absolute import

* Import layout

* Camel case for database columns

* Move auth routes to folder

* User popover links working

* Import linters

* User page initial

* User edit page with country

* Script to delete db files before migration in dev

* Remove "youtubeName" column

* Correct avatar size on desktop

* Fix SubNav not spanning the whole page

* Remove duplicate files

* Update README
2022-05-16 17:52:54 +03:00

50 lines
1.4 KiB
TypeScript

import { Link } from "@remix-run/react";
import { useUser } from "~/hooks/useUser";
import { LOG_IN_URL, LOG_OUT_URL, userPage } from "~/utils/urls";
import { Avatar } from "../Avatar";
import { Button } from "../Button";
import { DiscordIcon } from "../icons/Discord";
import { LogOutIcon } from "../icons/LogOut";
import { UserIcon } from "../icons/User";
import { Popover } from "../Popover";
export function UserItem() {
const user = useUser();
if (user && user.discordAvatar)
return (
<Popover trigger={<Avatar {...user} />}>
<div className="layout__user-popover">
{/* TODO: make the Button component transformable to Link instead of creating a wrapper */}
<Link to={userPage(user.discordId)}>
<Button
className="w-full"
tiny
variant="outlined"
icon={<UserIcon />}
>
Profile
</Button>
</Link>
<form method="post" action={LOG_OUT_URL}>
<Button tiny variant="outlined" icon={<LogOutIcon />} type="submit">
Log out
</Button>
</form>
</div>
</Popover>
);
return (
<form action={LOG_IN_URL} method="post" data-cy="log-in-form">
<button
type="submit"
className="layout__log-in-button"
data-cy="log-in-button"
>
<DiscordIcon /> Log in
</button>
</form>
);
}