11"use client" ;
2+
23import { TopHeader } from "@/components/TopHeader" ;
34import { Avatar , AvatarFallback , AvatarImage } from "@radix-ui/react-avatar" ;
45import axios from "axios" ;
@@ -8,6 +9,9 @@ import { AiOutlineLink } from "react-icons/ai";
89import { GrLocation } from "react-icons/gr" ;
910import { IoCalendarOutline } from "react-icons/io5" ;
1011import { PiBalloon } from "react-icons/pi" ;
12+ import { Button } from "../button" ;
13+ import { TweetComp } from "../TweetComp" ;
14+ import { NextResponse } from "next/server" ;
1115
1216interface UserDataProps {
1317 DOB : string ;
@@ -17,9 +21,18 @@ interface UserDataProps {
1721 username : string ;
1822 biolink : string ;
1923}
24+ interface Tweet {
25+ id : number ;
26+ content : string ;
27+ userID : number ;
28+ likes : number ;
29+ createdDate : string ;
30+ user : { name : string } ;
31+ }
2032export const UserInfo = ( ) => {
2133 const { data : session } = useSession ( ) ;
2234 const [ userData , setUserData ] = useState < UserDataProps [ ] | null > ( null ) ;
35+ const [ userTweet , setUserTweet ] = useState < Tweet [ ] > ( [ ] ) ;
2336 const [ error , setError ] = useState ( "" ) ;
2437 const [ loading , setLoading ] = useState ( false ) ;
2538
@@ -31,7 +44,7 @@ export const UserInfo = () => {
3144 const u_Data = response . data . data ;
3245 if ( Array . isArray ( u_Data ) && response . data . data . length > 0 ) {
3346 setUserData ( u_Data ) ;
34- console . log ( u_Data , "Here it is" ) ;
47+ // console.log(u_Data, "Here it is");
3548 } else {
3649 setError ( "No user data found" ) ;
3750 }
@@ -42,30 +55,53 @@ export const UserInfo = () => {
4255 }
4356 } ;
4457 fetchUserData ( ) ;
58+
59+ const fetchUserTweet = async ( ) => {
60+ try {
61+ const response = await axios . get ( `api/post/$[userID]` ) ;
62+ const tweetsByUser = response . data . data ;
63+ console . log ( tweetsByUser , "This is from user" ) ;
64+ setUserTweet ( tweetsByUser ) ;
65+ } catch ( error ) {
66+ console . log ( error ) ;
67+ }
68+ } ;
69+ fetchUserTweet ( ) ;
4570 } , [ ] ) ;
4671
4772 return (
4873 < div >
4974 < div >
5075 < div className = "" > </ div >
5176 < div >
52- < div
53- className = "w-full h-64 bg-cover bg-center object-cover relative"
54- style = { {
55- backgroundImage : `url('https://github.com/mscode07.png')` ,
56- } }
57- >
58- < div className = "absolute -bottom-16 left-4" >
59- < Avatar >
60- < AvatarImage
61- src = "https://github.com/mscode07.png"
62- className = "rounded-full h-36 w-36 border-black border-4 "
63- />
64- < AvatarFallback > </ AvatarFallback >
65- </ Avatar >
77+ < div >
78+ < div
79+ className = "w-full h-64 bg-cover bg-center object-cover relative"
80+ style = { {
81+ backgroundImage : `url('https://github.com/mscode07.png')` ,
82+ } }
83+ >
84+ < div className = "" >
85+ < div className = " w-full" >
86+ < Avatar className = "absolute -bottom-20 left-4" >
87+ < AvatarImage
88+ src = "https://github.com/mscode07.png"
89+ className = "rounded-full h-36 w-36 border-black border-4 "
90+ />
91+ < AvatarFallback > </ AvatarFallback >
92+ </ Avatar >
93+ </ div >
94+ </ div >
95+ </ div >
96+ < div className = "text-right pr-4 mt-4" >
97+ < div >
98+ < Button className = "bg-black text-white rounded-2xl border px-7 border-white hover:bg-neutral-900 transition duration-200 font-bold text-md" >
99+ Edit Profile
100+ </ Button >
101+ </ div >
66102 </ div >
67103 </ div >
68- < div className = "mt-20 ml-3" >
104+ < div className = "mt-10 ml-3" >
69105 < p className = "text-2xl font-bold" > { session ?. user ?. name } </ p >
70106 < p className = "text-gray-500" > @{ session ?. user ?. username } </ p >
71107 </ div >
@@ -109,8 +145,145 @@ export const UserInfo = () => {
109145 </ div >
110146 </ div >
111147 </ div >
148+
149+ { /* <div className="mb-4 border-b border-gray-200 dark:border-gray-700">
150+ <ul
151+ className="flex flex-wrap -mb-px text-sm font-medium text-center"
152+ id="default-styled-tab"
153+ data-tabs-toggle="#default-styled-tab-content"
154+ data-tabs-active-classes="text-purple-600 hover:text-purple-600 dark:text-purple-500 dark:hover:text-purple-500 border-purple-600 dark:border-purple-500"
155+ data-tabs-inactive-classes="dark:border-transparent text-gray-500 hover:text-gray-600 dark:text-gray-400 border-gray-100 hover:border-gray-300 dark:border-gray-700 dark:hover:text-gray-300"
156+ role="tablist"
157+ >
158+ <li className="me-2" role="presentation">
159+ <button
160+ className="inline-block p-4 border-b-2 rounded-t-lg"
161+ id="profile-styled-tab"
162+ data-tabs-target="#styled-profile"
163+ type="button"
164+ role="tab"
165+ aria-controls="profile"
166+ aria-selected="false"
167+ >
168+ Profile
169+ </button>
170+ </li>
171+ <li className="me-2" role="presentation">
172+ <button
173+ className="inline-block p-4 border-b-2 rounded-t-lg hover:text-gray-600 hover:border-gray-300 dark:hover:text-gray-300"
174+ id="dashboard-styled-tab"
175+ data-tabs-target="#styled-dashboard"
176+ type="button"
177+ role="tab"
178+ aria-controls="dashboard"
179+ aria-selected="false"
180+ >
181+ Dashboard
182+ </button>
183+ </li>
184+ <li className="me-2" role="presentation">
185+ <button
186+ className="inline-block p-4 border-b-2 rounded-t-lg hover:text-gray-600 hover:border-gray-300 dark:hover:text-gray-300"
187+ id="settings-styled-tab"
188+ data-tabs-target="#styled-settings"
189+ type="button"
190+ role="tab"
191+ aria-controls="settings"
192+ aria-selected="false"
193+ >
194+ Settings
195+ </button>
196+ </li>
197+ <li role="presentation">
198+ <button
199+ className="inline-block p-4 border-b-2 rounded-t-lg hover:text-gray-600 hover:border-gray-300 dark:hover:text-gray-300"
200+ id="contacts-styled-tab"
201+ data-tabs-target="#styled-contacts"
202+ type="button"
203+ role="tab"
204+ aria-controls="contacts"
205+ aria-selected="false"
206+ >
207+ Contacts
208+ </button>
209+ </li>
210+ </ul>
211+ </div>
212+ <div id="default-styled-tab-content">
213+ <div
214+ className="hidden p-4 rounded-lg bg-gray-50 dark:bg-gray-800"
215+ id="styled-profile"
216+ role="tabpanel"
217+ aria-labelledby="profile-tab"
218+ >
219+ <p className="text-sm text-gray-500 dark:text-gray-400">
220+ This is some placeholder content the{" "}
221+ <strong className="font-medium text-gray-800 dark:text-white">
222+ Profile tab associated content
223+ </strong>
224+ . Clicking another tab will toggle the visibility of this one
225+ for the next. The tab JavaScript swaps classes to control the
226+ content visibility and styling.
227+ </p>
228+ </div>
229+ <div
230+ className="hidden p-4 rounded-lg bg-gray-50 dark:bg-gray-800"
231+ id="styled-dashboard"
232+ role="tabpanel"
233+ aria-labelledby="dashboard-tab"
234+ >
235+ <p className="text-sm text-gray-500 dark:text-gray-400">
236+ This is some placeholder content the{" "}
237+ <strong className="font-medium text-gray-800 dark:text-white">
238+ Dashboard tabs associated content
239+ </strong>
240+ . Clicking another tab will toggle the visibility of this one
241+ for the next. The tab JavaScript swaps classes to control the
242+ content visibility and styling.
243+ </p>
244+ </div>
245+ <div
246+ className="hidden p-4 rounded-lg bg-gray-50 dark:bg-gray-800"
247+ id="styled-settings"
248+ role="tabpanel"
249+ aria-labelledby="settings-tab"
250+ >
251+ <p className="text-sm text-gray-500 dark:text-gray-400">
252+ This is some placeholder content the{" "}
253+ <strong className="font-medium text-gray-800 dark:text-white">
254+ Settings tabs associated content
255+ </strong>
256+ . Clicking another tab will toggle the visibility of this one
257+ for the next. The tab JavaScript swaps classNamees to control
258+ the content visibility and styling.
259+ </p>
260+ </div>
261+ <div
262+ className="hidden p-4 rounded-lg bg-gray-50 dark:bg-gray-800"
263+ id="styled-contacts"
264+ role="tabpanel"
265+ aria-labelledby="contacts-tab"
266+ >
267+ <p className="text-sm text-gray-500 dark:text-gray-400">
268+ This is some placeholder content the{" "}
269+ <strong className="font-medium text-gray-800 dark:text-white">
270+ Contacts tabs associated content
271+ </strong>
272+ . Clicking another tab will toggle the visibility of this one
273+ for the next. The tab JavaScript swaps classes to control the
274+ content visibility and styling.
275+ </p>
276+ </div>
277+ </div> */ }
112278 </ div >
113279 </ div >
280+ < br />
281+ < hr />
282+ < div >
283+ { userTweet . map ( ( tweet ) => (
284+ < TweetComp key = { tweet . id } tweet = { tweet } />
285+ ) ) }
286+ </ div >
114287 </ div >
115288 ) ;
116289} ;
0 commit comments