Skip to content
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
13 changes: 11 additions & 2 deletions apps/app/src/components/Header/LoginNavigationLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@ export const LoginNavigationLink = ({
onClick?: MouseEventHandler<HTMLAnchorElement>;
}) => {
const pathname = usePathname();
const { userData, isLoading } = useUser();
const { userData, isLoading, logout } = useUser();

if (isLoading) {
return null;
}

if (userData) {
return <UserAvatar userData={userData} />;
return (
<button
type="button"
className="mx-auto flex transition-opacity hover:opacity-80"
onClick={() => logout.mutate({})}
>
<UserAvatar userData={userData} />
<span className="sr-only">wyloguj się</span>
</button>
);
}

return (
Expand Down
5 changes: 1 addition & 4 deletions apps/app/src/components/Header/UserAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client";

import { useUser } from "../../hooks/useUser";
import { UserData } from "../../types";
import { GitHubAvatar } from "../GitHubAvatar";

Expand All @@ -9,7 +8,6 @@ type UserAvatarProps = Readonly<{
}>;

export const UserAvatar = ({ userData }: UserAvatarProps) => {
const { logout } = useUser();
const { _user } = userData;

return (
Expand All @@ -18,8 +16,7 @@ export const UserAvatar = ({ userData }: UserAvatarProps) => {
width={38}
height={38}
title="Kliknij, aby się wylogować"
onClick={() => logout.mutate({})}
className="mx-auto cursor-pointer rounded-full transition-opacity hover:opacity-80"
className="mx-auto rounded-full"
/>
);
};