Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added profile dropdown in login #34

Merged
merged 2 commits into from
Dec 21, 2023
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
12 changes: 0 additions & 12 deletions src/components/Auth/LogoutButton.tsx

This file was deleted.

1 change: 1 addition & 0 deletions src/components/Home/IconNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const IconNav = () => {
{details.map((item) => {
return (
<IconNavElement
key={item.title}
title={item.title}
image={item.image}
link={item.link}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { FaBars } from 'react-icons/fa'
import logo from '../../assets/logo.png'
import LoginButton from '../Auth/LoginButton.tsx'
import SessionWrapper from '../Auth/SessionWrapper.tsx'
import LogoutButton from '../Auth/LogoutButton.tsx'
import ProfileMenu from './ProfileMenu.tsx'

export const Navigation = () => {
return (
<div className="flex w-full justify-between bg-white p-8 md:justify-center">
<div className="flex w-full items-center justify-between bg-white p-8 md:justify-center">
<div className="justify-self-start">
<img src={logo} alt="logo" className="h-12" />
</div>
Expand All @@ -20,7 +20,7 @@ export const Navigation = () => {
</div>
<div className="hidden md:block">
<SessionWrapper
ifSession={<LogoutButton />}
ifSession={<ProfileMenu />}
notSession={<LoginButton />}
/>
</div>
Expand Down
35 changes: 35 additions & 0 deletions src/components/Navigation/ProfileMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { FaUser } from 'react-icons/fa'
import client from '@/database/client'
import { Dropdown } from 'flowbite-react'
import { Link } from 'react-router-dom'
export default function ProfileMenu() {
const signOut = async () => {
const { error } = await client.auth.signOut()
if (error) throw error
}

const TriggerDropdown = (
<button
id="dropdownDefaultButton"
data-dropdown-toggle="dropdown-button"
className="inline-flex items-center rounded-full bg-orange-500 p-4 text-center text-orange-50"
type="button"
>
<FaUser />
</button>
)
return (
<div>
<Dropdown
label=""
dismissOnClick={false}
renderTrigger={() => TriggerDropdown}
>
<Dropdown.Item as={Link} to="/change-password">
Change Password
</Dropdown.Item>
<Dropdown.Item onClick={signOut}>Sign out</Dropdown.Item>
</Dropdown>
</div>
)
}
Loading