-
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.
Update [user] route, add separate UserProfile Component, add function…
… to get users favorite tv series + total by username instead of active session.
- Loading branch information
1 parent
596d264
commit 2ab1f74
Showing
6 changed files
with
118 additions
and
22 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
import { getSession } from "@/app/actions/actions"; | ||
import { notFound } from "next/navigation"; | ||
import UserProfile from "@/components/ui/UserProfile"; | ||
import { Loader2 } from "lucide-react"; | ||
import { Suspense } from "react"; | ||
|
||
interface Params { | ||
user: string; | ||
} | ||
|
||
export default async function UserPage({ params }: { params: Params }) { | ||
const userData = await getSession(); | ||
|
||
if (!userData) { | ||
notFound(); | ||
} | ||
|
||
export default function UserPage({ params }: { params: Params }) { | ||
return ( | ||
<div className="flex-col gap-2"> | ||
<div>You are on the profile page of user: {userData.username}</div> | ||
</div> | ||
<section className="mt-20 flex justify-center"> | ||
<Suspense fallback={<Loader2 />}> | ||
<UserProfile username={params.user} /> | ||
</Suspense> | ||
</section> | ||
); | ||
} |
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,77 @@ | ||
import { Button } from "@/components/ui/shad-cn/button"; | ||
import { | ||
Avatar, | ||
AvatarFallback, | ||
AvatarImage, | ||
} from "@/components/ui/shad-cn/avatar"; | ||
import { | ||
Card, | ||
CardHeader, | ||
CardContent, | ||
CardFooter, | ||
} from "@/components/ui/shad-cn/card"; | ||
import { Badge } from "@/components/ui/shad-cn/badge"; | ||
import { | ||
CalendarIcon, | ||
MapPinIcon, | ||
BriefcaseIcon, | ||
MailIcon, | ||
} from "lucide-react"; | ||
import { getUserByName } from "@/app/api/memberApi"; | ||
import { getFavoriteTVSeriesByUsername } from "@/app/actions/tvSeriesActions"; | ||
|
||
interface UserProfileProps { | ||
username: string; | ||
} | ||
|
||
export default async function UserProfile({ username }: UserProfileProps) { | ||
const userData = await getUserByName(username); | ||
const usernameShort = userData?.username.slice(0, 2); | ||
const FavoriteSeries = await getFavoriteTVSeriesByUsername(username); | ||
|
||
return ( | ||
<> | ||
{!userData ? ( | ||
<div>No user found.</div> | ||
) : ( | ||
<Card className="mx-auto w-full max-w-3xl"> | ||
<CardHeader className="flex flex-col items-center space-y-4"> | ||
<Avatar className="h-32 w-32"> | ||
<AvatarImage | ||
src="/images/cards/card_anime.webp?height=128&width=128" | ||
alt="User profile picture" | ||
className="object-cover" | ||
/> | ||
<AvatarFallback>{usernameShort}</AvatarFallback> | ||
</Avatar> | ||
<div className="text-center"> | ||
<h1 className="text-2xl font-bold"></h1> | ||
<p className="text-muted-foreground">{userData?.username}</p> | ||
</div> | ||
<Button disabled variant="outline"> | ||
Add to friends | ||
</Button> | ||
</CardHeader> | ||
<CardContent className="space-y-4"> | ||
<div className="flex items-center space-x-2"> | ||
<BriefcaseIcon className="text-muted-foreground" /> | ||
<span>Works at TechCorp</span> | ||
</div> | ||
<div className="flex items-center space-x-2"> | ||
<MapPinIcon className="text-muted-foreground" /> | ||
<span>San Francisco, CA</span> | ||
</div> | ||
<div className="flex items-center space-x-2"> | ||
<CalendarIcon className="text-muted-foreground" /> | ||
<span>Joined January 2020</span> | ||
</div> | ||
<div className="flex items-center space-x-2"> | ||
<MailIcon className="text-muted-foreground" /> | ||
<span>jane.doe@example.com</span> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
)} | ||
</> | ||
); | ||
} |