Skip to content

Commit

Permalink
Merge pull request #571 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 28, 2023
2 parents 69eeb20 + 4602f5d commit 19671bf
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 100 deletions.
12 changes: 3 additions & 9 deletions src/components/member-profile/active-task/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@ import { percentageofDaysRemaining } from '@helper-functions/taskProgress';
import { estimatedDays } from '@helper-functions/estimated-days';
import { progressIndicator } from '@helper-functions/progressIndicator';

const ActiveTask = ({ taskDetails, devUser }) => {
const ActiveTask = ({ taskDetails }) => {
const { title, purpose, startedOn, endsOn, percentCompleted } = taskDetails;
const completedDate = timeWas(
startedOn * 1000,
false,
endsOn * 1000,
devUser
);
const completedDate = timeWas(startedOn * 1000, false, endsOn * 1000);
const percentOfTaskLeft = 100 - percentCompleted;
const percentageOfDaysRemaining = percentageofDaysRemaining(
startedOn,
endsOn,
completedDate,
devUser
completedDate
);
const showEstimatedDay = estimatedDays(
percentageOfDaysRemaining,
Expand Down
101 changes: 32 additions & 69 deletions src/components/member-profile/contribution-type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,34 @@ const renderContributions = (
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>
);
if (contributions?.length > 0) {
return contributions.map((noteWorthyContribution, index) => (
<Contribution
contribution={noteWorthyContribution}
key={index}
fullName={fullName}
imageLink={imageLink}
devUser={devUser}
/>
));
}
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>
);
};

const renderActiveTasks = (tasks, devUser) => {
if (devUser) {
if (tasks?.length > 0) {
return tasks.map((task, index) => {
return <ActiveTask key={index} taskDetails={task} devUser={devUser} />;
});
}
return (
<p className={classNames.emptyAccordianError}>{emptyActiveTasksError}</p>
);
const renderActiveTasks = (tasks) => {
if (tasks?.length > 0) {
return tasks.map((task, index) => {
return <ActiveTask key={index} taskDetails={task} />;
});
}
return (
tasks &&
tasks.map((task, index) => {
return <ActiveTask key={index} taskDetails={task} />;
})
<p className={classNames.emptyAccordianError}>{emptyActiveTasksError}</p>
);
};

Expand All @@ -81,18 +62,7 @@ const ContributionType = (props) => {
}, [tasks.length, contributions.length]);

Check warning on line 62 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 (devUser) {
setShowMoreContent(!showMoreContent);
} else {
if (isContribution) {
if (contributions.length > 0) {
setShowMoreContent(!showMoreContent);
}
}
if (tasks.length > 0) {
setShowMoreContent(!showMoreContent);
}
}
setShowMoreContent(!showMoreContent);
};

const showMoreContentClass = showMoreContent
Expand All @@ -115,23 +85,16 @@ const ContributionType = (props) => {
<div className={showMoreContentClass}>
{type !== 'Active tasks' ? (
<div>
{devUser
? renderContributions(
contributions,
fullName,
imageLink,
devUser,
type
)
: renderContributions(
contributions,
fullName,
imageLink,
devUser
)}
{renderContributions(
contributions,
fullName,
imageLink,
devUser,
type
)}
</div>
) : (
<div>{renderActiveTasks(tasks, devUser)}</div>
<div>{renderActiveTasks(tasks)}</div>
)}
</div>
<hr className={classNames.hrLine} />
Expand Down
10 changes: 5 additions & 5 deletions src/components/member-profile/contribution/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,22 @@ const ContributionCard = ({
if (isTitleAvailable) {
if (status !== 'VERIFIED') {
completedText = <span>Estimated Completion: </span>;
completedDate = timeWas(startedOn * 1000, false, endsOn * 1000, devUser);
completedDate = timeWas(startedOn * 1000, false, endsOn * 1000);
} else {
completedDate = timeWas(startedOn * 1000, false, endsOn * 1000, devUser);
completedDate = timeWas(startedOn * 1000, false, endsOn * 1000);
completedText = <span>Completed in: </span>;
featureLiveDate = timeWas(endsOn * 1000, true, Date.now(), devUser);
featureLiveDate = timeWas(endsOn * 1000, true, Date.now());
featureLiveOnText = featureLiveDate;
}
} else {
const createdAt = +new Date(prList[0].createdAt);
const updatedAt = +new Date(prList[0].updatedAt);
if (prList[0].state === 'closed') {
completedDate = timeWas(createdAt, false, updatedAt, devUser);
completedDate = timeWas(createdAt, false, updatedAt);
completedText = (
<span className={classNames.completedText}>Completed in </span>
);
featureLiveDate = timeWas(updatedAt, true, Date.now(), devUser);
featureLiveDate = timeWas(updatedAt, true, Date.now());
featureLiveOnText = featureLiveDate;
}
}
Expand Down
11 changes: 3 additions & 8 deletions src/helper-functions/taskProgress.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { timeWas } from '@helper-functions/time-was';

const percentageofDaysRemaining = (
startedOn,
endsOn,
completedDate,
devUser
) => {
const startDate = timeWas(startedOn * 1000, true, endsOn * 1000, devUser);
const endDate = timeWas(endsOn * 1000, true, startDate * 1000, devUser);
const percentageofDaysRemaining = (startedOn, endsOn, completedDate) => {
const startDate = timeWas(startedOn * 1000, true, endsOn * 1000);
const endDate = timeWas(endsOn * 1000, true, startDate * 1000);
const date1 = new Date(startDate);
const date2 = new Date(endDate);
const diffTime = Math.abs(date2 - date1);
Expand Down
9 changes: 2 additions & 7 deletions src/helper-functions/time-was.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ import { notAvailableError } from '@constants/error-messages';

const calc = (interval, cycle) => Math.floor(cycle / interval);

function timeWas(
timestamp,
completeDate = false,
differentNow = Date.now(),
devUser
) {
if (devUser && (!timestamp || timestamp === 0)) {
function timeWas(timestamp, completeDate = false, differentNow = Date.now()) {
if (!timestamp || timestamp === 0 || !differentNow) {
return notAvailableError;
}
const timeInSec = Math.floor(differentNow - timestamp) / 1000;
Expand Down
2 changes: 0 additions & 2 deletions src/test/unit/components/member-profile/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ describe('Members Profile', () => {
<TaskContextProvider>
<Profile
membersData={isaMember}
devUser
activeTasks={activeTasks}
contributions={contributions}
/>
Expand Down Expand Up @@ -199,7 +198,6 @@ describe('Members Profile', () => {
<TaskContextProvider>
<Profile
membersData={isaMember}
devUser
tasks={tasksWithEmptyStartDateAsFalsy}
contributions={contributionsWithStartDateAsFalsy}
/>
Expand Down

2 comments on commit 19671bf

@vercel
Copy link

@vercel vercel bot commented on 19671bf Oct 28, 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 19671bf Oct 28, 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-git-main-rds-team.vercel.app
members-app-rds-team.vercel.app
members.realdevsquad.com

Please sign in to comment.