This repository has been archived by the owner on May 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
193 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import HeaderSearch from "./header/Header"; | ||
|
||
interface LayoutProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const Layout = ({ children }: LayoutProps) => { | ||
return ( | ||
<> | ||
<HeaderSearch /> | ||
{children} | ||
</> | ||
); | ||
}; | ||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { api } from "@/utils/api"; | ||
import { Avatar, Button, Menu } from "@mantine/core"; | ||
import { | ||
IconHomeSignal, | ||
IconLogout, | ||
IconMessageCircle, | ||
IconSettings, | ||
} from "@tabler/icons-react"; | ||
import { signIn, signOut, useSession } from "next-auth/react"; | ||
import Link from "next/link"; | ||
|
||
const AccountHeaderMenu = () => { | ||
const { data: sessionData } = useSession(); | ||
const { data: userInfo } = api.user.getMyHeaderInfo.useQuery( | ||
undefined, // no input | ||
{ enabled: sessionData?.user !== undefined } | ||
); | ||
const id = userInfo?.id.toString(); | ||
const menu = ( | ||
<Menu> | ||
<Menu.Target> | ||
{userInfo?.image ? ( | ||
<Avatar component="button" src={userInfo.image} radius="xl" /> | ||
) : ( | ||
<Avatar component="button"> | ||
{userInfo?.name?.slice(0, 2).toUpperCase()} | ||
</Avatar> | ||
)} | ||
</Menu.Target> | ||
<Menu.Dropdown> | ||
<Menu.Label>User Actions</Menu.Label> | ||
<Menu.Item | ||
icon={<IconSettings size={14} />} | ||
component={Link} | ||
href="/settings" | ||
> | ||
Settings | ||
</Menu.Item> | ||
<Menu.Item | ||
icon={<IconMessageCircle size={14} />} | ||
component={Link} | ||
href="/chat" | ||
> | ||
Messages | ||
</Menu.Item> | ||
<Menu.Item | ||
icon={<IconHomeSignal size={14} />} | ||
component={Link} | ||
href={"/profile/" + id!} | ||
> | ||
Profile | ||
</Menu.Item> | ||
|
||
<Menu.Divider /> | ||
|
||
<Menu.Item | ||
color="red" | ||
icon={<IconLogout size={14} />} | ||
onClick={() => void signOut()} | ||
> | ||
Logout | ||
</Menu.Item> | ||
</Menu.Dropdown> | ||
</Menu> | ||
); | ||
const SignIn = ( | ||
<Button variant="subtle" onClick={() => void signIn()}></Button> | ||
); | ||
return sessionData === null ? SignIn : menu; | ||
}; | ||
|
||
export default AccountHeaderMenu; |
Oops, something went wrong.