-
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.
Refactor Header and Login Screen, Add Logout Functionality
- Loading branch information
1 parent
e4c9276
commit b2e5a73
Showing
17 changed files
with
456 additions
and
79 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
40 changes: 40 additions & 0 deletions
40
app/[locale]/(loggedIn)/components/layout/userMenu/LogoutButton.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,40 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
import { signOut } from "next-auth/react"; | ||
import LogoutDialog from "./LogoutDialog"; | ||
|
||
export interface LogoutButtonProps { | ||
logoutText: string; | ||
logoutProgressMessageText: string; | ||
} | ||
|
||
const LogoutButton = ({ | ||
logoutText, | ||
logoutProgressMessageText, | ||
}: LogoutButtonProps) => { | ||
const [isDialogOpen, setIsDialogOpen] = useState(false); | ||
|
||
const handleSignOut = async () => { | ||
setIsDialogOpen(true); | ||
await signOut(); | ||
setIsDialogOpen(false); | ||
}; | ||
|
||
return ( | ||
<> | ||
<LogoutDialog | ||
isOpen={isDialogOpen} | ||
logoutProgressMessageText={logoutProgressMessageText} | ||
/> | ||
<button | ||
className="block w-full text-left px-2 py-1.5 text-sm focus:bg-slate-100 focus:text-slate-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-slate-800 dark:focus:text-slate-50" | ||
onClick={handleSignOut} | ||
> | ||
{logoutText} | ||
</button> | ||
</> | ||
); | ||
}; | ||
|
||
export default LogoutButton; |
44 changes: 44 additions & 0 deletions
44
app/[locale]/(loggedIn)/components/layout/userMenu/LogoutDialog.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,44 @@ | ||
import { Skeleton } from "@/components/ui/skeleton"; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogHeader, | ||
DialogTitle, | ||
} from "@/components/ui/dialog"; | ||
|
||
export interface LogoutDialogProps { | ||
isOpen: boolean; | ||
logoutProgressMessageText: string; | ||
} | ||
|
||
const LogoutDialog = ({ | ||
isOpen, | ||
logoutProgressMessageText, | ||
}: LogoutDialogProps) => { | ||
return ( | ||
<Dialog open={isOpen}> | ||
<DialogContent | ||
hasCloseButton={false} | ||
className="DialogContentFit" | ||
> | ||
<DialogHeader className="space-y-5 select-none"> | ||
<DialogTitle className="text-center"> | ||
{logoutProgressMessageText} | ||
</DialogTitle> | ||
<DialogDescription> | ||
<div className="flex items-center space-x-4"> | ||
<Skeleton className="h-12 w-12 rounded-full" /> | ||
<div className="space-y-2"> | ||
<Skeleton className="h-4 w-[250px]" /> | ||
<Skeleton className="h-4 w-[200px]" /> | ||
</div> | ||
</div> | ||
</DialogDescription> | ||
</DialogHeader> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default LogoutDialog; |
52 changes: 52 additions & 0 deletions
52
app/[locale]/(loggedIn)/components/layout/userMenu/UserMenu.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,52 @@ | ||
"use client"; | ||
import { useSession } from "next-auth/react"; | ||
import { useMemo, type ReactNode } from "react"; | ||
import { getUserInitials } from "@/utils/userSessionUtils"; | ||
|
||
import { Button } from "@/components/ui/button"; | ||
|
||
import { Avatar, AvatarFallback } from "@/components/ui/avatar"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from "@/components/ui/dropdown-menu"; | ||
|
||
export interface UserMenuProps { | ||
children?: ReactNode; | ||
} | ||
|
||
const UserMenu = ({ children }: UserMenuProps) => { | ||
const { data: session } = useSession(); | ||
|
||
const userName = session?.user?.name; | ||
const userInitials = useMemo(() => getUserInitials(userName), [userName]); | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button | ||
variant="none" | ||
size="content" | ||
> | ||
<Avatar> | ||
<AvatarFallback className="text-slate-800"> | ||
{userInitials} | ||
</AvatarFallback> | ||
</Avatar> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent className="w-56"> | ||
<DropdownMenuLabel className="text-center"> | ||
{userName} | ||
</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
{children} | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}; | ||
|
||
export default UserMenu; |
19 changes: 0 additions & 19 deletions
19
app/[locale]/(loggedIn)/layoutComponents/sidebar/LogoImage.tsx
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 |
---|---|---|
@@ -1,3 +1,43 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
.DialogOverlay { | ||
background: rgba(0 0 0 / 0.5); | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
display: grid; | ||
place-items: center; | ||
overflow-y: auto; | ||
z-index: 9998; | ||
} | ||
|
||
.DialogContent { | ||
min-width: 300px; | ||
width: calc(100% - 60px); | ||
position: relative; | ||
background: white; | ||
margin-top: 30px; | ||
margin-right: 30px; | ||
margin-bottom: 30px; | ||
margin-left: 30px; | ||
padding: 30px; | ||
border-radius: 4px; | ||
z-index: 9999; | ||
} | ||
|
||
.DialogContentFit { | ||
min-width: 300px; | ||
position: relative; | ||
background: white; | ||
margin-top: 30px; | ||
margin-right: 30px; | ||
margin-bottom: 30px; | ||
margin-left: 30px; | ||
padding: 30px; | ||
border-radius: 4px; | ||
z-index: 9999; | ||
} |
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.