Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed null values from profile #121

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all 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 @@ -110,7 +114,11 @@ export const UserDetails = ({
data-cy='edit-Name'
>
<h2 className='user-profile-name' data-cy='user-Name'>
{user.Name ? user.Name : user.username}
{user.Name
? checkNull(user.Name)
? user.username
: user.Name
: user.username}
</h2>
</EditableLabel>
<EditableLabel
Expand All @@ -124,7 +132,7 @@ export const UserDetails = ({
data-cy='edit-Bio'
>
<p data-cy='user-Bio'>
{user.Bio ||
{(user.Bio && !checkNull(user.Bio)) ||
(allowEditing ? 'Say something about yourself' : 'Hi There!')}
</p>
</EditableLabel>
Expand All @@ -150,7 +158,11 @@ export const UserDetails = ({
data-cy='edit-Profession'
>
<span data-cy='user-Profession'>
{!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 @@ -169,7 +181,11 @@ export const UserDetails = ({
data-cy='edit-Company'
>
<span data-cy='user-Company'>
{!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 @@ -189,14 +205,18 @@ export const UserDetails = ({
>
<span data-cy='user-LinkedIn'>
{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 @@ -219,14 +239,18 @@ export const UserDetails = ({
>
<span data-cy='user-Twitter'>
{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