-
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
7d1eda6
commit 67915e9
Showing
10 changed files
with
114 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"use client"; | ||
|
||
import { useEffect, useState } from "react"; | ||
import { useSearchParams } from "next/navigation"; | ||
|
||
import Profile from "@components/Profile"; | ||
|
||
const UserProfile = ({ params }) => { | ||
const searchParams = useSearchParams(); | ||
const userName = searchParams.get("name"); | ||
|
||
const [userPosts, setUserPosts] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchPosts = async () => { | ||
const response = await fetch(`/api/users/${params?.id}/posts`); | ||
const data = await response.json(); | ||
|
||
setUserPosts(data); | ||
}; | ||
|
||
if (params?.id) fetchPosts(); | ||
}, [params.id]); | ||
|
||
return ( | ||
<Profile | ||
name={userName} | ||
desc={`Welcome to ${userName}'s personalized profile page. Explore ${userName}'s prompts`} | ||
data={userPosts} | ||
/> | ||
); | ||
}; | ||
|
||
export default UserProfile; |
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,17 @@ | ||
import Image from "next/image"; | ||
|
||
const Loading = () => { | ||
return ( | ||
<div className='w-full flex-center'> | ||
<Image | ||
src='assets/icons/loader.svg' | ||
width={50} | ||
height={50} | ||
alt='loader' | ||
className='object-contain' | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Loading; |
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
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes