-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
dd10c86
commit 3aa5878
Showing
11 changed files
with
349 additions
and
103 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
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
64 changes: 64 additions & 0 deletions
64
ui_tailwind_shadecn/src/components/custom_ui/NavBar/NavProfile.tsx
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,64 @@ | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from "@/components/ui/dropdown-menu" | ||
|
||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" | ||
|
||
import { | ||
CircleUser | ||
} from "lucide-react" | ||
import { Button } from "../../ui/button" | ||
import { useLoginStore, useLoginUserInfo } from "@/store/Auth" | ||
import { Link } from "react-router-dom" | ||
|
||
export const NavProfile = ()=>{ | ||
const user = useLoginStore((state) => state.isLogin); | ||
const userInfo = useLoginUserInfo((state) => state); | ||
return( | ||
<> | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="secondary" size="icon" className="rounded-full"> | ||
{user? <> | ||
<Avatar> | ||
<AvatarImage src={userInfo.avatar_url || "Please login"} /> | ||
<AvatarFallback>Profile</AvatarFallback> | ||
</Avatar> | ||
</>:<CircleUser className="h-5 w-5" />} | ||
<span className="sr-only">Toggle user menu</span> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end"> | ||
<DropdownMenuLabel>Info</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
{ | ||
user ? | ||
<DropdownMenuItem> | ||
<Link to={`/profile`}> | ||
{userInfo.name} | ||
</Link> | ||
</DropdownMenuItem> | ||
: <></> | ||
} | ||
<DropdownMenuItem> | ||
<Link to={`/settings`}> | ||
Settings | ||
</Link> | ||
</DropdownMenuItem> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem> | ||
<Link to={`/${user ? "Logout" : "Login"}`}> | ||
{user ? "Logout" : "Login"} | ||
</Link> | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
|
||
</> | ||
) | ||
} |
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
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
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
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
Oops, something went wrong.