import { Grid, Row } from '@freecodecamp/react-bootstrap'; import React from 'react'; import Helmet from 'react-helmet'; import { TFunction, useTranslation } from 'react-i18next'; import { FullWidthRow, Link, Spacer } from '../helpers'; import { User } from './../../redux/prop-types'; import Timeline from './components/time-line'; import Camper from './components/camper'; import Certifications from './components/certifications'; import HeatMap from './components/heat-map'; import Portfolio from './components/portfolio'; interface ProfileProps { isSessionUser: boolean; user: User; } function renderMessage( isSessionUser: boolean, username: string, t: TFunction ): JSX.Element { return isSessionUser ? ( <>

{t('profile.you-not-public')}

{t('profile.you-change-privacy')}

) : ( <>

{t('profile.username-not-public', { username: username })}

{t('profile.username-change-privacy', { username: username })}

); } function renderProfile(user: ProfileProps['user']): JSX.Element { const { profileUI: { showAbout = false, showCerts = false, showDonation = false, showHeatMap = false, showLocation = false, showName = false, showPoints = false, showPortfolio = false, showTimeLine = false }, // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment calendar, completedChallenges, githubProfile, isLinkedIn, isGithub, isTwitter, isWebsite, linkedin, twitter, website, name, username, joinDate, location, points, picture, portfolio, about, yearsTopContributor, isDonating } = user; return ( <> {/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */} {showHeatMap ? : null} {showCerts ? : null} {showPortfolio ? : null} {showTimeLine ? ( ) : null} ); } function Profile({ user, isSessionUser }: ProfileProps): JSX.Element { const { t } = useTranslation(); const { profileUI: { isLocked = true }, username } = user; return ( <> {t('buttons.profile')} | freeCodeCamp.org {isLocked ? renderMessage(isSessionUser, username, t) : null} {!isLocked || isSessionUser ? renderProfile(user) : null} {isSessionUser ? null : ( {t('buttons.flag-user')} )} ); } Profile.displayName = 'Profile'; export default Profile;