diff --git a/client/src/client-only-routes/show-settings.tsx b/client/src/client-only-routes/show-settings.tsx index ce34aac2c8d..f5da23e8812 100644 --- a/client/src/client-only-routes/show-settings.tsx +++ b/client/src/client-only-routes/show-settings.tsx @@ -198,7 +198,6 @@ export function ShowSettings(props: ShowSettingsProps): JSX.Element { website={website} /> - {/* @ts-expect-error Portfolio types mismatch */} diff --git a/client/src/components/profile/components/portfolio.css b/client/src/components/profile/components/portfolio-projects.css similarity index 100% rename from client/src/components/profile/components/portfolio.css rename to client/src/components/profile/components/portfolio-projects.css diff --git a/client/src/components/profile/components/portfolio.tsx b/client/src/components/profile/components/portfolio-projects.tsx similarity index 71% rename from client/src/components/profile/components/portfolio.tsx rename to client/src/components/profile/components/portfolio-projects.tsx index f5edd7ae43a..04a68c032f3 100644 --- a/client/src/components/profile/components/portfolio.tsx +++ b/client/src/components/profile/components/portfolio-projects.tsx @@ -2,24 +2,26 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faArrowUpRightFromSquare } from '@fortawesome/free-solid-svg-icons'; -import type { Portfolio as PortfolioData } from '../../../redux/prop-types'; +import type { PortfolioProjectData } from '../../../redux/prop-types'; import { FullWidthRow } from '../../helpers'; -import './portfolio.css'; +import './portfolio-projects.css'; -interface PortfolioProps { - portfolio: PortfolioData[]; +interface PortfolioProjectsProps { + portfolioProjects: PortfolioProjectData[]; } -function Portfolio({ portfolio = [] }: PortfolioProps): JSX.Element | null { +export const PortfolioProjects = ({ + portfolioProjects +}: PortfolioProjectsProps): JSX.Element | null => { const { t } = useTranslation(); - if (!portfolio.length) { + if (!portfolioProjects.length) { return null; } return (

{t('profile.portfolio')}

- {portfolio.map(({ title, url, image, description, id }) => ( + {portfolioProjects.map(({ title, url, image, description, id }) => (

{title}

{description}

@@ -39,8 +41,4 @@ function Portfolio({ portfolio = [] }: PortfolioProps): JSX.Element | null {
); -} - -Portfolio.displayName = 'Portfolio'; - -export default Portfolio; +}; diff --git a/client/src/components/profile/profile.tsx b/client/src/components/profile/profile.tsx index ec68412886b..4276946b086 100644 --- a/client/src/components/profile/profile.tsx +++ b/client/src/components/profile/profile.tsx @@ -9,7 +9,7 @@ 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'; +import { PortfolioProjects } from './components/portfolio-projects'; interface ProfileProps { isSessionUser: boolean; @@ -61,7 +61,6 @@ function renderProfile(user: ProfileProps['user']): JSX.Element { showPortfolio = false, showTimeLine = false }, - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment calendar, completedChallenges, githubProfile, @@ -96,10 +95,11 @@ function renderProfile(user: ProfileProps['user']): JSX.Element { website={website} yearsTopContributor={yearsTopContributor} /> - {/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */} {showHeatMap ? : null} {showCerts ? : null} - {showPortfolio ? : null} + {showPortfolio ? ( + + ) : null} {showTimeLine ? ( ) : null} diff --git a/client/src/components/settings/portfolio.tsx b/client/src/components/settings/portfolio.tsx index 191744f6ba7..a353b5cfd3c 100644 --- a/client/src/components/settings/portfolio.tsx +++ b/client/src/components/settings/portfolio.tsx @@ -11,6 +11,7 @@ import { nanoid } from 'nanoid'; import React, { Component } from 'react'; import { TFunction, withTranslation } from 'react-i18next'; import isURL from 'validator/lib/isURL'; +import { PortfolioProjectData } from '../../redux/prop-types'; import { hasProtocolRE } from '../../utils'; @@ -18,28 +19,20 @@ import { FullWidthRow, Spacer } from '../helpers'; import BlockSaveButton from '../helpers/form/block-save-button'; import SectionHeader from './section-header'; -type PortfolioItem = { - id: string; - description: string; - image: string; - title: string; - url: string; -}; - type PortfolioProps = { picture?: string; - portfolio: PortfolioItem[]; + portfolio: PortfolioProjectData[]; t: TFunction; - updatePortfolio: (obj: { portfolio: PortfolioItem[] }) => void; + updatePortfolio: (obj: { portfolio: PortfolioProjectData[] }) => void; username?: string; }; type PortfolioState = { - portfolio: PortfolioItem[]; + portfolio: PortfolioProjectData[]; unsavedItemId: string | null; }; -function createEmptyPortfolioItem(): PortfolioItem { +function createEmptyPortfolioItem(): PortfolioProjectData { return { id: nanoid(), title: '', @@ -50,7 +43,7 @@ function createEmptyPortfolioItem(): PortfolioItem { } function createFindById(id: string) { - return (p: PortfolioItem) => p.id === id; + return (p: PortfolioProjectData) => p.id === id; } class PortfolioSettings extends Component { @@ -178,7 +171,7 @@ class PortfolioSettings extends Component { : { state: 'warning', message: t('validation.use-valid-url') }; } - formCorrect(portfolio: PortfolioItem) { + formCorrect(portfolio: PortfolioProjectData) { const { id, title, description, url, image } = portfolio; const { state: titleState, message: titleMessage } = @@ -229,9 +222,9 @@ class PortfolioSettings extends Component { } renderPortfolio = ( - portfolio: PortfolioItem, + portfolio: PortfolioProjectData, index: number, - arr: PortfolioItem[] + arr: PortfolioProjectData[] ) => { const { t } = this.props; const { id, title, description, url, image } = portfolio; diff --git a/client/src/redux/prop-types.ts b/client/src/redux/prop-types.ts index 2ded4abfafd..13a4b278336 100644 --- a/client/src/redux/prop-types.ts +++ b/client/src/redux/prop-types.ts @@ -207,7 +207,7 @@ export type User = { name: string; picture: string; points: number; - portfolio: Portfolio[]; + portfolio: PortfolioProjectData[]; profileUI: ProfileUI; progressTimestamps: Array; savedChallenges: SavedChallenges; @@ -301,12 +301,12 @@ export type ChallengeMeta = { helpCategory: string; }; -export type Portfolio = { +export type PortfolioProjectData = { id: string; - title?: string; - url?: string; - image?: string; - description?: string; + title: string; + url: string; + image: string; + description: string; }; type FileKeyChallenge = {