Skip to content

Commit d7ef972

Browse files
committed
"Conditionally render profile sections based on content and current user state, ensuring cleaner UI and improved logic."
1 parent 0146755 commit d7ef972

1 file changed

Lines changed: 53 additions & 40 deletions

File tree

web/components/profile/profile-info.tsx

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ export function ProfileInfo(props: {
174174
<div className="from-canvas-50 absolute bottom-0 h-12 w-full bg-gradient-to-t to-transparent" />
175175
</Col>
176176
<Row className="gap-2">
177-
<SignUpButton text={t('profile.info.signup_to_see', 'Sign up to see profile')} />
177+
<SignUpButton
178+
text={t('profile.info.signup_to_see', 'Sign up to see their full profile')}
179+
/>
178180
</Row>
179181
</Col>
180182
)}
@@ -259,7 +261,7 @@ function ProfileContent(props: {
259261
refreshProfile,
260262
fromProfilePage,
261263
fromSignup,
262-
isProfileVisible,
264+
// isProfileVisible,
263265
// likesGiven,
264266
// likesReceived,
265267
// ships,
@@ -282,9 +284,11 @@ function ProfileContent(props: {
282284
/>
283285
</ProfileCard>
284286

285-
<ProfileCard title={t('profile.interests_and_causes', 'Interests')} className="p-5">
286-
<ProfileInterestsAndCauses profile={profile} />
287-
</ProfileCard>
287+
{(!!profile.interests?.length || !!profile.causes?.length) && (
288+
<ProfileCard title={t('profile.interests_and_causes', 'Interests')} className="p-5">
289+
<ProfileInterestsAndCauses profile={profile} />
290+
</ProfileCard>
291+
)}
288292

289293
{(profile.mbti || profile.big5_agreeableness) && (
290294
<ProfileCard title={t('profile.personality', 'Personality')} className="p-5">
@@ -299,48 +303,57 @@ function ProfileContent(props: {
299303
)}
300304
</Col>
301305
<Col className="gap-6">
302-
<ProfileCard title={t('profile.bio.about_me', 'About Me')} className="p-0">
303-
<ProfileBio
304-
isCurrentUser={isCurrentUser}
305-
profile={profile}
306-
refreshProfile={refreshProfile}
307-
fromProfilePage={fromProfilePage}
308-
/>
309-
</ProfileCard>
306+
{profile.bio && (
307+
<ProfileCard title={t('profile.bio.about_me', 'About Me')} className="p-0">
308+
<ProfileBio
309+
isCurrentUser={isCurrentUser}
310+
profile={profile}
311+
refreshProfile={refreshProfile}
312+
fromProfilePage={fromProfilePage}
313+
/>
314+
</ProfileCard>
315+
)}
310316

311-
{isProfileVisible && (
317+
{currentUser && (
312318
// <ProfileCard className="!p-0">
313319
<ProfileCarousel profile={profile} refreshProfile={refreshProfile} />
314320
// </ProfileCard>
315321
)}
316322

317-
<ProfileCard
318-
className="p-5"
319-
title={
320-
isCurrentUser
321-
? t('answers.display.your_prompts', 'Compatibility Prompts')
322-
: t('answers.display.user_prompts', 'Compatibility Prompts', {
323-
name: shortenName(user.name),
324-
})
325-
}
326-
>
327-
<ProfileAnswers
328-
isCurrentUser={isCurrentUser}
329-
user={user}
330-
fromSignup={fromSignup}
331-
fromProfilePage={fromProfilePage}
332-
profile={profile}
333-
/>
334-
</ProfileCard>
323+
{currentUser && (
324+
<ProfileCard
325+
className="p-5"
326+
title={
327+
isCurrentUser
328+
? t('answers.display.your_prompts', 'Compatibility Prompts')
329+
: t('answers.display.user_prompts', 'Compatibility Prompts', {
330+
name: shortenName(user.name),
331+
})
332+
}
333+
>
334+
<ProfileAnswers
335+
isCurrentUser={isCurrentUser}
336+
user={user}
337+
fromSignup={fromSignup}
338+
fromProfilePage={fromProfilePage}
339+
profile={profile}
340+
/>
341+
</ProfileCard>
342+
)}
335343

336-
<ProfileCard className="p-5" title={t('profile.comments.section_title', 'Endorsements')}>
337-
<ProfileCommentSection
338-
onUser={user}
339-
profile={profile}
340-
currentUser={currentUser}
341-
simpleView={!!fromProfilePage}
342-
/>
343-
</ProfileCard>
344+
{currentUser && (
345+
<ProfileCard
346+
className="p-5"
347+
title={t('profile.comments.section_title', 'Endorsements')}
348+
>
349+
<ProfileCommentSection
350+
onUser={user}
351+
profile={profile}
352+
currentUser={currentUser}
353+
simpleView={!!fromProfilePage}
354+
/>
355+
</ProfileCard>
356+
)}
344357

345358
{!isCurrentUser && currentUser && (
346359
<ProfileCard title={t('profile.connect.title', 'Connect')}>

0 commit comments

Comments
 (0)