Skip to content

Commit

Permalink
Merge pull request #564 from Real-Dev-Squad/develop
Browse files Browse the repository at this point in the history
dev to main sync
  • Loading branch information
iamitprakash authored Oct 22, 2023
2 parents 2d5f1ff + 4699129 commit 0b596fd
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@
margin: 10px;
}
}
.emptyAccordianError {
margin-top: 24px;
color: #636363;
}
79 changes: 69 additions & 10 deletions src/components/member-profile/contribution-type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => (
<Contribution
contribution={noteWorthyContribution}
key={index}
fullName={fullName}
imageLink={imageLink}
devUser={devUser}
/>
));
}
return (
<p className={classNames.emptyAccordianError}>
{type === 'All'
? emptyContributionsError
: emptyNoteworthyContributionsError}
</p>
);
}
return contributions?.map((noteWorthyContribution, index) => (
<Contribution
contribution={noteWorthyContribution}
key={index}
Expand All @@ -15,8 +46,19 @@ const renderContributions = (contributions, fullName, imageLink, devUser) =>
devUser={devUser}
/>
));
};

const renderActiveTasks = (tasks) => {
const renderActiveTasks = (tasks, devUser) => {
if (devUser) {
if (tasks?.length > 0) {
return tasks.map((task, index) => {
return <ActiveTask key={index} taskDetails={task} />;
});
}
return (
<p className={classNames.emptyAccordianError}>{emptyActiveTasksError}</p>
);
}
return (
tasks &&
tasks.map((task, index) => {
Expand All @@ -39,14 +81,18 @@ const ContributionType = (props) => {
}, [tasks.length, contributions.length]);

Check warning on line 81 in src/components/member-profile/contribution-type/index.js

View workflow job for this annotation

GitHub Actions / build (16.x)

React Hook useEffect has a missing dependency: 'isContribution'. Either include it or remove the dependency array

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
Expand All @@ -69,10 +115,23 @@ const ContributionType = (props) => {
<div className={showMoreContentClass}>
{type !== 'Active tasks' ? (
<div>
{renderContributions(contributions, fullName, imageLink, devUser)}
{devUser
? renderContributions(
contributions,
fullName,
imageLink,
devUser,
type
)
: renderContributions(
contributions,
fullName,
imageLink,
devUser
)}
</div>
) : (
<div>{renderActiveTasks(tasks)}</div>
<div>{renderActiveTasks(tasks, devUser)}</div>
)}
</div>
<hr className={classNames.hrLine} />
Expand Down
10 changes: 9 additions & 1 deletion src/components/social-media-icon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand All @@ -17,7 +25,7 @@ const SocialMediaIcon = (props) => {
target="_blank"
rel="noreferrer"
tabIndex="0"
href={`${iconMapper[type].href}/${[id]}`}
href={`${iconMapper[type].href}/${[checkId]}`}
>
<img
className={classNames.iconImage}
Expand Down
5 changes: 5 additions & 0 deletions src/constants/error-messages.js
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
export const unAuthorizedPageViewError = 'Unauthorized to view this page.';
export const emptyActiveTasksError = 'No active task.';
export const emptyContributionsError =
'No Contributions have been received yet.';
export const emptyNoteworthyContributionsError =
'It would be wonderful to see some noteworthy contributions made.';
3 changes: 2 additions & 1 deletion src/helper-functions/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const getContributionsURL = (rdsId) => `${baseURL}/contributions/${rdsId}`;
*
* @param {string} rdsId
*/
const getActiveTasksURL = (rdsId) => `${baseURL}/tasks/${rdsId}?status=active`;
const getActiveTasksURL = (rdsId) =>
`${baseURL}/tasks/${rdsId}?status=IN_PROGRESS`;

/**
*
Expand Down
45 changes: 45 additions & 0 deletions src/test/unit/components/member-profile/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -22,6 +27,13 @@ const initialUserContext = {
isSuperUser: true,
showMemberRoleUpdateModal: true,
};
const activeTasks = {
tasks: [],
};
const contributions = {
noteworthy: [],
all: [],
};

jest.mock('next/router', () => {
return {
Expand Down Expand Up @@ -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(
<KeyboardProvider
initialValue={{
isOptionKeyPressed: true,
setIsOptionKeyPressed: jest.fn(),
}}
>
<UserContextProvider value={initialUserContext}>
<TaskContextProvider>
<Profile
membersData={isaMember}
devUser
activeTasks={activeTasks}
contributions={contributions}
/>
</TaskContextProvider>
</UserContextProvider>
</KeyboardProvider>
);
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(
Expand Down

2 comments on commit 0b596fd

@vercel
Copy link

@vercel vercel bot commented on 0b596fd Oct 22, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 0b596fd Oct 22, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

members-app – ./

members-app-rds-team.vercel.app
members.realdevsquad.com
members-app-git-main-rds-team.vercel.app

Please sign in to comment.