Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 44 additions & 20 deletions src/components/UserProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ export const UserDetails = ({
allowEditing,
updateProfile
}) => {
const checkNull = (value) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codetheorem i think you were earlier checking for ? user.Name === 'null'
if the values are null and not string 'null' we dont need a separate function.

if (value === 'null') return true
else return false
}
return (
<div className='user-profile-details'>
{!user ? (
Expand All @@ -109,7 +113,11 @@ export const UserDetails = ({
placeholder='Your name'
>
<h2 className='user-profile-name'>
{user.Name ? user.Name : user.username}
{user.Name
? checkNull(user.Name)
? user.username
: user.Name
: user.username}
</h2>
</EditableLabel>
<EditableLabel
Expand All @@ -122,7 +130,7 @@ export const UserDetails = ({
placeholder='Say something about yourself'
>
<p>
{user.Bio ||
{(user.Bio && !checkNull(user.Bio)) ||
(allowEditing ? 'Say something about yourself' : 'Hi There!')}
</p>
</EditableLabel>
Expand All @@ -147,7 +155,11 @@ export const UserDetails = ({
placeholder='Your job title'
>
<span>
{!user.Profession ? 'Your job title' : user.Profession}
{!user.Profession
? 'Your job title'
: checkNull(user.Profession)
? 'Your job title'
: user.Profession}
</span>
</EditableLabel>
</li>
Expand All @@ -165,7 +177,11 @@ export const UserDetails = ({
placeholder='Your company name'
>
<span>
{!user.Company ? 'Your company name' : user.Company}
{!user.Company
? 'Your company name'
: checkNull(user.Company)
? 'Your company name'
: user.Company}
</span>
</EditableLabel>
</li>
Expand All @@ -184,14 +200,18 @@ export const UserDetails = ({
>
<span>
{user.LinkedIn ? (
<a
className='link link-default'
href={`https://www.linkedin.com/in/${user?.LinkedIn}`}
target='_blank'
rel='noopener noreferrer'
>
{user.LinkedIn}
</a>
checkNull(user.LinkedIn) ? (
'Your LinkedIn username'
) : (
<a
className='link link-default'
href={`https://www.linkedin.com/in/${user?.LinkedIn}`}
target='_blank'
rel='noopener noreferrer'
>
{user.LinkedIn}
</a>
)
) : (
'Your LinkedIn username'
)}
Expand All @@ -213,14 +233,18 @@ export const UserDetails = ({
>
<span>
{user.Twitter ? (
<a
className='link link-default'
href={`https://twitter.com/${user?.Twitter}`}
target='_blank'
rel='noopener noreferrer'
>
{user.Twitter ? `@${user.Twitter}` : ''}
</a>
checkNull(user.Twitter) ? (
'Your Twitter handle'
) : (
<a
className='link link-default'
href={`https://twitter.com/${user?.Twitter}`}
target='_blank'
rel='noopener noreferrer'
>
{user.Twitter ? `@${user.Twitter}` : ''}
</a>
)
) : (
'Your Twitter handle'
)}
Expand Down