-
Notifications
You must be signed in to change notification settings - Fork 3
86b1vx0v2: Add Card and Avatar Components with Conditional Rendering for Login Page #25
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
base: development
Are you sure you want to change the base?
Changes from 25 commits
d7f3e6c
7667e5e
6cea914
4186b7c
d87a8ee
4f3a40b
59f46ce
5063490
dc2f06b
b8b8bb0
eabfa47
b248ef9
f7d0bf4
c172329
ae6ad1c
5df067f
f56a359
f1a0c25
4604ab2
c63bae5
0f92b49
f569066
d80bd87
9feb7d6
fefe3e2
9674436
eb4cfb0
a5bb525
7f0b682
2ae304c
57e513a
6a536cf
c3a828e
081a80d
12a473c
01f6928
fd76e9f
c58a27a
ba2f304
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| "@radix-ui/react-scroll-area": "^1.1.0", | ||
| "@radix-ui/react-slot": "^1.1.0", | ||
| "@shadcn/ui": "^0.0.4", | ||
| "antd": "^5.20.4", | ||
| "bcrypt": "^5.1.1", | ||
| "bcrypt-ts": "^5.0.2", | ||
| "class-variance-authority": "^0.7.0", | ||
|
|
@@ -33,6 +34,7 @@ | |
| "dotenv": "^16.4.5", | ||
| "dotenv-cli": "^7.4.2", | ||
| "jose": "^5.8.0", | ||
| "lib_test": "file:", | ||
|
||
| "lucide-react": "^0.436.0", | ||
| "next": "14.2.5", | ||
| "react": "^18", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,27 @@ | ||
| `use client` | ||
|
|
||
| // src/app/page.tsx | ||
| import TaskCalendar from "@/components/calendar"; | ||
| import { Button } from "antd"; | ||
| import Title from "antd/es/typography/Title"; | ||
| import { getSession } from "@/server_actions/getSession"; | ||
|
|
||
| export default async function Home() { | ||
| const session = await getSession(); | ||
| const role = session?.getRole(); | ||
|
|
||
| const role = session?.getRole(); | ||
|
|
||
| return ( | ||
| <div className="p-2"> | ||
| <div className="flex gap-2 justify-between"> | ||
| <Title level={3}>Dashboard</Title> | ||
| <form action="/auth/logout" method="post"> | ||
| <Button htmlType="submit">Logout</Button> | ||
| </form> | ||
| </div> | ||
| <div className="flex flex-col h-full"> | ||
| {role === 'student' && <div className="text-sm text-green-700">Student</div>} | ||
| {role === 'mentor' && <div className="text-sm text-green-700">Mentor</div>} | ||
| {role === 'admin' && <div className="text-sm text-green-700">Super Admin</div>} | ||
| </div> | ||
| <TaskCalendar /> | ||
| return ( | ||
| <div className="p-6 h-[80vh] gap-4"> {/* Increased padding and set height to 80% of viewport height */} | ||
| <div className="flex flex-col gap-8"> {/* Increased gap for more spacing */} | ||
| <Title level={3} className="mb-8">Dashboard</Title> {/* Increased margin-bottom */} | ||
| {/* <form action="/auth/logout" method="post"> | ||
| <Button htmlType="submit">Logout</Button> | ||
| </form> */} | ||
| <div className="flex flex-col flex-grow"> {/* Used flex-grow to take up available space */} | ||
| {role === 'student' && <div className="text-sm text-green-700 mb-2">Student</div>} | ||
| {role === 'mentor' && <div className="text-sm text-green-700 mb-2">Mentor</div>} | ||
| {role === 'admin' && <div className="text-sm text-green-700 mb-2">Super Admin</div>} | ||
| </div> | ||
| ); | ||
| <TaskCalendar /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // src/components/ConditionalLayout.tsx | ||
| import { getSession } from '@/server_actions/getSession'; | ||
| import ProfileCard from "@/components/ProfileCard"; | ||
|
|
||
|
|
||
| const ConditionalLayout: React.FC<{ children: React.ReactNode }> = async ({ children }) => { | ||
| const session = await getSession(); // Fetch session directly on the server | ||
| const authenticated = session.isAuthenticated(); | ||
|
|
||
| return ( | ||
| <> | ||
| {authenticated && ( | ||
| <> | ||
| {/* Logo in the top-left corner */} | ||
| <div className="absolute top-4 left-4 mb-15" > | ||
| <img | ||
| src="../t2t logo.png" // Ensure correct file path and name | ||
| alt="T2T Logo" | ||
| className="w-24 h-auto" // Adjust size as needed | ||
| /> | ||
| </div> | ||
|
|
||
| {/* ProfileCard component in the top-right corner */} | ||
| <div className="absolute top-4 right-4"> | ||
| <ProfileCard /> | ||
| </div> | ||
| </> | ||
| )} | ||
| <main className="p-4"> | ||
| {children} | ||
| </main> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default ConditionalLayout; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| "use client"; | ||
|
|
||
| import { useState } from "react"; | ||
| import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; | ||
| import { Card, CardContent, CardHeader, CardTitle, CardFooter } from "@/components/ui/card"; | ||
|
|
||
| export default function ProfileCard() { | ||
| const [isCardVisible, setIsCardVisible] = useState(false); | ||
|
|
||
| // Toggle the visibility of the card | ||
| const toggleCardVisibility = () => { | ||
| setIsCardVisible(!isCardVisible); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="relative"> | ||
| {/* Button to toggle the visibility of the profile card */} | ||
| <button onClick={toggleCardVisibility} className="absolute top-4 right-4"> | ||
| <Avatar> | ||
| <AvatarImage src="https://github.com/shadcn.png" /> | ||
| <AvatarFallback>CN</AvatarFallback> | ||
| </Avatar> | ||
| </button> | ||
|
|
||
| {/* Conditional rendering of the profile card */} | ||
| {isCardVisible && ( | ||
| <div className="absolute top-16 right-0 bg-gradient-to-b from-blue-100 to-blue-200 p-3 border border-gray-200 rounded shadow-lg"> | ||
| <Card className="w-56 rounded-lg overflow-hidden shadow-xl"> | ||
| {/* Card header with avatar and green background */} | ||
| <CardHeader className="relative flex flex-col items-center justify-center bg-green-400 h-28 p-3"> | ||
| <Avatar className="w-20 h-20 border-4 border-white absolute -bottom-10"> | ||
| <AvatarImage src="https://github.com/shadcn.png" /> | ||
| <AvatarFallback>CN</AvatarFallback> | ||
| </Avatar> | ||
| </CardHeader> | ||
|
|
||
| {/* Card content displaying the user's name and email */} | ||
| <CardContent className="mt-12 text-center p-2"> | ||
| <CardTitle className="text-md font-semibold">Mohamed Asfik</CardTitle> | ||
| <p className="text-xs text-gray-700">[email protected]</p> | ||
| </CardContent> | ||
|
|
||
| {/* Card footer with the logout button */} | ||
| <CardFooter className="flex justify-center p-2"> | ||
| {/* Remove the logout functionality */} | ||
| <button | ||
| className="bg-gray-500 text-white py-1 px-3 rounded-md hover:bg-gray-600" | ||
|
|
||
| > | ||
| Logout | ||
| </button> | ||
| </CardFooter> | ||
| </Card> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be added.