diff --git a/src/components/member-profile/contribution-type/contributions-type.module.scss b/src/components/member-profile/contribution-type/contributions-type.module.scss index 06fbb6d7..ec146fdd 100644 --- a/src/components/member-profile/contribution-type/contributions-type.module.scss +++ b/src/components/member-profile/contribution-type/contributions-type.module.scss @@ -42,3 +42,7 @@ margin: 10px; } } +.emptyAccordianError { + margin-top: 24px; + color: #636363; +} diff --git a/src/components/member-profile/contribution-type/index.js b/src/components/member-profile/contribution-type/index.js index f94b5696..d2c90032 100644 --- a/src/components/member-profile/contribution-type/index.js +++ b/src/components/member-profile/contribution-type/index.js @@ -4,9 +4,40 @@ import PropTypes from 'prop-types'; import classNames from '@components/member-profile/contribution-type/contributions-type.module.scss'; import Contribution from '@components/member-profile/contribution/'; import ActiveTask from '@components/member-profile/active-task'; +import { + emptyActiveTasksError, + emptyContributionsError, + emptyNoteworthyContributionsError, +} from '@constants/error-messages'; -const renderContributions = (contributions, fullName, imageLink, devUser) => - contributions.map((noteWorthyContribution, index) => ( +const renderContributions = ( + contributions, + fullName, + imageLink, + devUser, + type +) => { + if (devUser) { + if (contributions?.length > 0) { + return contributions.map((noteWorthyContribution, index) => ( + + )); + } + return ( +

+ {type === 'All' + ? emptyContributionsError + : emptyNoteworthyContributionsError} +

+ ); + } + return contributions?.map((noteWorthyContribution, index) => ( devUser={devUser} /> )); +}; -const renderActiveTasks = (tasks) => { +const renderActiveTasks = (tasks, devUser) => { + if (devUser) { + if (tasks?.length > 0) { + return tasks.map((task, index) => { + return ; + }); + } + return ( +

{emptyActiveTasksError}

+ ); + } return ( tasks && tasks.map((task, index) => { @@ -39,14 +81,18 @@ const ContributionType = (props) => { }, [tasks.length, contributions.length]); const showMoreContentHandler = () => { - if (isContribution) { - if (contributions.length > 0) { + if (devUser) { + setShowMoreContent(!showMoreContent); + } else { + if (isContribution) { + if (contributions.length > 0) { + setShowMoreContent(!showMoreContent); + } + } + if (tasks.length > 0) { setShowMoreContent(!showMoreContent); } } - if (tasks.length > 0) { - setShowMoreContent(!showMoreContent); - } }; const showMoreContentClass = showMoreContent @@ -69,10 +115,23 @@ const ContributionType = (props) => {
{type !== 'Active tasks' ? (
- {renderContributions(contributions, fullName, imageLink, devUser)} + {devUser + ? renderContributions( + contributions, + fullName, + imageLink, + devUser, + type + ) + : renderContributions( + contributions, + fullName, + imageLink, + devUser + )}
) : ( -
{renderActiveTasks(tasks)}
+
{renderActiveTasks(tasks, devUser)}
)}

diff --git a/src/components/social-media-icon/index.js b/src/components/social-media-icon/index.js index c2c49e5d..401ec130 100644 --- a/src/components/social-media-icon/index.js +++ b/src/components/social-media-icon/index.js @@ -6,6 +6,14 @@ import classNames from '@components/social-media-icon/social-media-icon.module.s const SocialMediaIcon = (props) => { const { id, type } = props; + let checkId = id; + + if (checkId.includes('https') || checkId.includes('http')) { + checkId = checkId.split('/').pop(); + } else { + checkId = id; + } + const onClick = (e) => { e.stopPropagation(); }; @@ -17,7 +25,7 @@ const SocialMediaIcon = (props) => { target="_blank" rel="noreferrer" tabIndex="0" - href={`${iconMapper[type].href}/${[id]}`} + href={`${iconMapper[type].href}/${[checkId]}`} > `${baseURL}/contributions/${rdsId}`; * * @param {string} rdsId */ -const getActiveTasksURL = (rdsId) => `${baseURL}/tasks/${rdsId}?status=active`; +const getActiveTasksURL = (rdsId) => + `${baseURL}/tasks/${rdsId}?status=IN_PROGRESS`; /** * diff --git a/src/test/unit/components/member-profile/index.test.js b/src/test/unit/components/member-profile/index.test.js index d9537dc2..2ac65574 100644 --- a/src/test/unit/components/member-profile/index.test.js +++ b/src/test/unit/components/member-profile/index.test.js @@ -4,6 +4,11 @@ import { TaskContextProvider } from '@store/tasks/tasks-context'; import { UserContextProvider } from '@store/user/user-context'; import { KeyboardProvider } from '@store/keyboard/context'; import MemberRoleUpdate from '@components/member-role-update'; +import { + emptyActiveTasksError, + emptyContributionsError, + emptyNoteworthyContributionsError, +} from '@constants/error-messages'; const notaMember = { roles: { @@ -22,6 +27,13 @@ const initialUserContext = { isSuperUser: true, showMemberRoleUpdateModal: true, }; +const activeTasks = { + tasks: [], +}; +const contributions = { + noteworthy: [], + all: [], +}; jest.mock('next/router', () => { return { @@ -83,6 +95,39 @@ describe('Members Profile', () => { memberStatus = screen.getByText('User is a Member'); expect(memberStatus).toBeInTheDocument(); }); + it('Should render empty error message if no data inside accordion sections', () => { + render( + + + + + + + + ); + const emptyActiveTasksErrorElement = screen.getByText( + emptyActiveTasksError + ); + expect(emptyActiveTasksErrorElement).toBeInTheDocument(); + const emptyContributionsErrorElement = screen.getByText( + emptyContributionsError + ); + expect(emptyContributionsErrorElement).toBeInTheDocument(); + const emptyNoteworthyContributionsErrorElement = screen.getByText( + emptyNoteworthyContributionsError + ); + expect(emptyNoteworthyContributionsErrorElement).toBeInTheDocument(); + }); it('Should render the info icon correctly', () => { render(