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
10 changes: 8 additions & 2 deletions src/frontend/apps/web/app/(main)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { LoginButton } from '@/src/features/auth';
import AuthWrapper from '@/src/features/auth/ui/auth-wrapper';
import { ProfilePopover } from '@/src/features/user';
import { Header } from '@/src/shared';
import '@workspace/ui/globals.css';

Expand All @@ -6,16 +9,19 @@ export default function RootLayout({
}: Readonly<{
children: React.ReactNode;
}>) {
const user = null;
return (
<html
lang="en"
suppressHydrationWarning
>
<body>
<header className="h-[68px] w-full flex items-center justify-between px-4 py-1 bg-muted">
<Header />
<Header authContent={user ? <ProfilePopover /> : <LoginButton />} />
</header>
<div className="flex flex-col h-[calc(100vh-68px)] overflow-hidden">{children}</div>
<div className="flex flex-col h-[calc(100vh-68px)] overflow-hidden">
<AuthWrapper> {children}</AuthWrapper>
</div>
</body>
</html>
);
Expand Down
1 change: 1 addition & 0 deletions src/frontend/apps/web/src/features/auth/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { LoginButton, LogoutButton } from './ui';
20 changes: 20 additions & 0 deletions src/frontend/apps/web/src/features/auth/ui/auth-wrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use client';

import { usePathname, useRouter } from 'next/navigation';
import { useEffect } from 'react';

//로그인이 안 되었을 경우 리디렉트용 wrapper
const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
const pathname = usePathname();
const router = useRouter();
const user = {};

useEffect(() => {
if (!user && pathname !== '/') {
router.push('/');
}
}, [user, pathname]);

return <>{children}</>;
};
export default AuthWrapper;
2 changes: 2 additions & 0 deletions src/frontend/apps/web/src/features/auth/ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as LoginButton } from './login-button';
export { default as LogoutButton } from './logout-button';
13 changes: 13 additions & 0 deletions src/frontend/apps/web/src/features/auth/ui/login-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Button } from '@workspace/ui/components';

const LoginButton = () => {
return (
<Button
variant="ghost"
className="text-xl font-bold hover:text-primary"
>
Login
</Button>
);
};
export default LoginButton;
14 changes: 14 additions & 0 deletions src/frontend/apps/web/src/features/auth/ui/logout-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Button } from '@workspace/ui/components';

const LogoutButton = () => {
return (
<Button
variant="outline"
size="sm"
className="w-full text-xs"
>
LOGOUT
</Button>
);
};
export default LogoutButton;
1 change: 1 addition & 0 deletions src/frontend/apps/web/src/features/user/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ProfilePopover } from './ui';
1 change: 1 addition & 0 deletions src/frontend/apps/web/src/features/user/ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as ProfilePopover } from './profile-popover';
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Button, Input, Label } from '@workspace/ui/components';
import { Pencil } from 'lucide-react';

const Nickname = () => {
const ProfileNickname = () => {
//임시변수
const isNameEditMode = false;
const name = '공작새';
Expand All @@ -26,4 +26,4 @@ const Nickname = () => {
</div>
);
};
export default Nickname;
export default ProfileNickname;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import ProfilePicture from './profile-picture';
import ProfileNickname from './profile-nickname';
import { LogoutButton } from '../../auth';

const ProfilePopoverContent = () => {
return (
<div className="flex flex-col items-start space-y-4">
<h4 className="font-semibold leading-none">My Account</h4>
<div className="flex flex-col items-center space-y-4">
<ProfilePicture />
<ProfileNickname />
</div>
<LogoutButton />
</div>
);
};
export default ProfilePopoverContent;
35 changes: 35 additions & 0 deletions src/frontend/apps/web/src/features/user/ui/profile-popover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
Avatar,
AvatarFallback,
AvatarImage,
Popover,
PopoverContent,
PopoverTrigger,
} from '@workspace/ui/components';
import { CircleUserRound } from 'lucide-react';
import ProfilePopoverContent from './profile-popover-content';

const ProfilePopover = () => {
return (
<Popover>
<PopoverTrigger asChild>
<Avatar
variant="default"
className="cursor-pointer"
>
<AvatarImage src="https://github.com/shadcn.png" />
<AvatarFallback>
<CircleUserRound size={40} />
</AvatarFallback>
</Avatar>
</PopoverTrigger>
<PopoverContent
align="end"
className="w-72 "
>
<ProfilePopoverContent />
</PopoverContent>
</Popover>
);
};
export default ProfilePopover;
34 changes: 3 additions & 31 deletions src/frontend/apps/web/src/shared/components/header/header.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
'use client';

import {
Avatar,
AvatarFallback,
AvatarImage,
Popover,
PopoverContent,
PopoverTrigger,
} from '@workspace/ui/components';
import ProfileContainer from './profile-container';
import { CircleUserRound } from 'lucide-react';
import { Avatar, AvatarFallback, AvatarImage } from '@workspace/ui/components';
import Link from 'next/link';

//로고 이미지 경로 변경 필요
const Header = () => {
const Header = ({ authContent }: { authContent: React.ReactNode }) => {
return (
<>
<Link href={'/'}>
Expand All @@ -24,26 +15,7 @@ const Header = () => {
</AvatarFallback>
</Avatar>
</Link>

<Popover>
<PopoverTrigger asChild>
<Avatar
variant="default"
className="cursor-pointer"
>
<AvatarImage src="https://github.com/shadcn.png" />
<AvatarFallback>
<CircleUserRound size={40} />
</AvatarFallback>
</Avatar>
</PopoverTrigger>
<PopoverContent
align="end"
className="w-72 "
>
<ProfileContainer />
</PopoverContent>
</Popover>
{authContent}
</>
);
};
Expand Down

This file was deleted.

Loading