diff --git a/app/complete-profile/page.tsx b/app/complete-profile/page.tsx
index b119548..81ffeee 100644
--- a/app/complete-profile/page.tsx
+++ b/app/complete-profile/page.tsx
@@ -534,17 +534,21 @@ function RegisterComponent() {
-
-
-
-
My Profile
-
View and update your profile information
-
-
- Edit Profile
-
-
-
-
-
-
- Profile Picture
-
-
-
- {image ? (
-
- ) : (
-
-
- {name?.charAt(0).toUpperCase() || 'U'}
-
-
- )}
-
-
-
-
-
- Name
- -
- {name || 'Not provided'}
-
-
-
-
- Email
- -
- {email}
-
-
-
-
- Location
- -
- {location || 'Not provided'}
-
-
-
-
- About
- -
- {description || 'Not provided'}
-
-
-
-
- Gender
- -
- {gender || 'Not specified'}
-
-
-
-
- Personality Type
- -
- {personalityType || 'Not specified'}
-
-
-
-
- Conflict Style
- -
- {conflictStyle || 'Not specified'}
-
-
-
-
- Interests
-
-
- {intellectualInterests.length > 0 ? (
-
- {intellectualInterests.map((value: any, index: number) => (
-
- {value?.interest?.name}
-
- ))}
-
- ) : (
- 'No interests selected'
- )}
-
-
-
-
-
+
+ {getProfile(userData, image, header)}
- );
+ )
+ ;
} catch (error) {
console.error('Error fetching user data:', error);
return
Error loading profile. Please try again later.
;
diff --git a/app/profiles/[id]/page.tsx b/app/profiles/[id]/page.tsx
index 918bef0..43cee8e 100644
--- a/app/profiles/[id]/page.tsx
+++ b/app/profiles/[id]/page.tsx
@@ -2,16 +2,16 @@
import {useEffect, useState} from "react";
import {useParams} from "next/navigation";
-import Image from "next/image";
import LoadingSpinner from "@/lib/client/LoadingSpinner";
import {ProfileData} from "@/lib/client/schema";
import {parseImage} from "@/lib/client/media";
+import {getProfile} from "@/lib/client/profile";
export const dynamic = "force-dynamic"; // This disables SSG and ISR
export default function Post() {
const {id} = useParams();
- const [user, setUser] = useState
(null);
+ const [userData, setUserData] = useState(null);
const [image, setImage] = useState(null);
const [loading, setLoading] = useState(true);
@@ -21,7 +21,7 @@ export default function Post() {
console.log('res', res);
if (res.ok) {
const data = await res.json();
- setUser(data);
+ setUserData(data);
console.log('userData', data);
if (data?.image) {
await parseImage(data.image, setImage);
@@ -37,7 +37,7 @@ export default function Post() {
return ;
}
- if (!user) {
+ if (!userData) {
return
Profile not found
;
@@ -45,185 +45,10 @@ export default function Post() {
console.log(`Image: ${image}`)
- const pStyle = "mt-1 text-gray-800 dark:text-white whitespace-pre-line"
-
-
return (
+
-
- {/* Profile Header with Image */}
-
- {image ? (
-
-
- {
- // const target = e.target as HTMLImageElement;
- // target.onerror = null;
- // target.src = `https://ui-avatars.com/api/?name=${encodeURIComponent(profile.name || 'U')}&background=random`;
- // }}
- />
-
-
- ) : (
-
-
- {user.name ? user.name.charAt(0).toUpperCase() : 'U'}
-
-
- )}
-
-
- {/* Profile Content */}
-
-
- {user.name}
-
-
-
-
- {user?.profile?.desiredConnections && (
-
<
- h2 className="text-sm font-medium text-gray-500 uppercase tracking-wider">Desired Connections
-
-
- {user?.profile?.desiredConnections.map((value, idx) => (
- -
- {value?.connection?.name}
-
- ))}
-
-
- )}
-
- {user?.profile?.gender && (
-
-
Gender
-
{user.profile.gender}
-
- )}
-
- {user?.profile?.location && (
-
-
Location
-
{user.profile.location}
-
- )}
-
- {user?.profile?.occupation && (
-
-
Occupation
-
{user.profile.occupation}
-
- )}
-
- {user?.profile?.personalityType && (
-
-
Personality Type
-
{user.profile.personalityType}
-
- )}
-
- {user?.profile?.conflictStyle && (
-
-
Conflict Style
-
{user.profile.conflictStyle}
-
- )}
-
- {user?.profile?.intellectualInterests && (
-
<
- h2 className="text-sm font-medium text-gray-500 uppercase tracking-wider">Interests
-
-
- {user.profile.intellectualInterests.map((value, idx) => (
- -
- {value?.interest?.name}
-
- ))}
-
-
- )}
-
- {user?.profile?.causeAreas && (
-
<
- h2 className="text-sm font-medium text-gray-500 uppercase tracking-wider">Cause Areas
-
-
- {user.profile.causeAreas.map((value, idx) => (
- -
- {value?.causeArea?.name}
-
- ))}
-
-
- )}
-
- {user?.profile?.description && (
-
-
About
-
{user.profile.description}
-
- )}
-
- {user?.profile?.contactInfo && (
-
-
Contact
-
{user.profile.contactInfo}
-
- )}
-
- {user?.profile?.promptAnswers && (
-
<
- h2 className="text-sm font-medium text-gray-500 uppercase tracking-wider">Prompt Answers
-
-
- {user.profile.promptAnswers.map((value, idx) => (
- -
- • {value.prompt} {value.answer}
-
- ))}
-
-
- )}
-
- {/*
*/}
- {/*
Creation Date
*/}
- {/*
*/}
- {/* {user.profile.createdAt}*/}
- {/* {new Date(user.profile.createdAt).toLocaleDateString("en-US", {*/}
- {/* year: "numeric",*/}
- {/* month: "long",*/}
- {/* day: "numeric",*/}
- {/* })}*/}
- {/*
*/}
- {/*
*/}
-
-
-
-
-
-
-
-
+ {getProfile(userData, image)}
);
}
diff --git a/lib/client/constants.ts b/lib/client/constants.ts
index 545b9b8..d368973 100644
--- a/lib/client/constants.ts
+++ b/lib/client/constants.ts
@@ -1 +1,3 @@
-export const supportEmail = 'mysharktrash@gmail.com (official email to be created)';
\ No newline at end of file
+export const supportEmail = 'mysharktrash@gmail.com (official email to be created)';
+
+export const pStyle = "mt-1 text-gray-800 dark:text-white whitespace-pre-line";
\ No newline at end of file
diff --git a/lib/client/profile.tsx b/lib/client/profile.tsx
new file mode 100644
index 0000000..2ad7063
--- /dev/null
+++ b/lib/client/profile.tsx
@@ -0,0 +1,253 @@
+import {ProfileData} from "@/lib/client/schema";
+import Image from "next/image";
+import {pStyle} from "@/lib/client/constants";
+
+export function getProfile(userData: ProfileData, image, header = null) {
+ return (
+
+ {header}
+ {/* Profile Header with Image */}
+ < div
+ className="bg-gradient-to-r h-16 relative">
+ {
+ image ? (
+
+
+ {
+ // const target = e.target as HTMLImageElement;
+ // target.onerror = null;
+ // target.src = `https://ui-avatars.com/api/?name=${encodeURIComponent(profile.name || 'U')}&background=random`;
+ // }}
+ />
+
+
+ ) :
+ (
+
+
+ {userData.name ? userData.name.charAt(0).toUpperCase() : 'U'}
+
+
+ )
+ }
+
+
+ {/* Profile Content */
+ }
+
+
+ {userData.name}
+
+
+ < div
+ className="space-y-6 pt-4 border-t border-gray-200">
+
+ {userData?.profile?.desiredConnections && (
+
<
+ h2 className="text-sm font-medium text-gray-500 uppercase tracking-wider"> Desired
+ Connections
+
+ < ul
+ className="flex flex-wrap gap-2 mt-1">
+ {userData?.profile?.desiredConnections.map((value, idx) => (
+
+ {value?.connection?.name
+ }
+
+ ))
+ }
+
+
+ )
+ }
+
+ {
+ userData?.profile?.gender && (
+
+
Gender
+ < p
+ className="mt-1 capitalize"> {userData.profile.gender}
+
+ )
+ }
+
+ {
+ userData?.profile?.location && (
+
+
Location
+ < p
+ className={pStyle}> {userData.profile.location}
+
+ )
+ }
+
+ {
+ userData?.profile?.occupation && (
+
+
Occupation
+ < p
+ className={pStyle}> {userData.profile.occupation}
+
+ )
+ }
+
+ {
+ userData?.profile?.personalityType && (
+
+
Personality
+ Type
+ < p
+ className={pStyle}> {userData.profile.personalityType}
+
+ )
+ }
+
+ {
+ userData?.profile?.conflictStyle && (
+
+
Conflict
+ Style
+ < p
+ className={pStyle}> {userData.profile.conflictStyle}
+
+ )
+ }
+
+ {
+ userData?.profile?.intellectualInterests && (
+
<
+ h2 className="text-sm font-medium text-gray-500 uppercase tracking-wider"> Interests
+
+ < ul
+ className="flex flex-wrap gap-2 mt-1">
+ {
+ userData.profile.intellectualInterests.map((value, idx) => (
+
+ {value?.interest?.name
+ }
+
+ ))
+ }
+
+
+ )
+ }
+
+ {
+ userData?.profile?.causeAreas && (
+
<
+ h2 className="text-sm font-medium text-gray-500 uppercase tracking-wider"> Cause
+ Areas
+
+ < ul
+ className="flex flex-wrap gap-2 mt-1">
+ {
+ userData.profile.causeAreas.map((value, idx) => (
+
+ {value?.causeArea?.name
+ }
+
+ ))
+ }
+
+
+ )
+ }
+
+ {
+ userData?.profile?.description && (
+
+
About
+ < p
+ className={pStyle}> {userData.profile.description}
+
+ )
+ }
+
+ {
+ userData?.profile?.contactInfo && (
+
+
Contact
+ < p
+ className={pStyle}> {userData.profile.contactInfo}
+
+ )
+ }
+
+ {
+ userData?.profile?.promptAnswers && (
+
<
+ h2 className="text-sm font-medium text-gray-500 uppercase tracking-wider"> Prompt
+ Answers
+
+ < ul
+ className="flex flex-wrap gap-2 mt-1">
+ {
+ userData.profile.promptAnswers.map((value, idx) => (
+
+ • {
+ value.prompt
+ }
+ {
+ value.answer
+ }
+
+ ))
+ }
+
+
+ )
+ }
+
+ {/*
*/
+ }
+ {/*
Creation Date
*/
+ }
+ {/*
*/
+ }
+ {/* {user.profile.createdAt}*/
+ }
+ {/* {new Date(user.profile.createdAt).toLocaleDateString("en-US", {*/
+ }
+ {/* year: "numeric",*/
+ }
+ {/* month: "long",*/
+ }
+ {/* day: "numeric",*/
+ }
+ {/* })}*/
+ }
+ {/*
*/
+ }
+ {/*
*/
+ }
+
+
+
+
+
+
+
+
+ )
+ ;
+}
\ No newline at end of file