diff --git a/src/components/member-profile/active-task/index.js b/src/components/member-profile/active-task/index.js index c3f8c22e..f011890e 100644 --- a/src/components/member-profile/active-task/index.js +++ b/src/components/member-profile/active-task/index.js @@ -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, diff --git a/src/components/member-profile/contribution-type/index.js b/src/components/member-profile/contribution-type/index.js index 3051e5bb..f359a10e 100644 --- a/src/components/member-profile/contribution-type/index.js +++ b/src/components/member-profile/contribution-type/index.js @@ -17,53 +17,34 @@ const renderContributions = ( devUser, type ) => { - if (devUser) { - if (contributions?.length > 0) { - return contributions.map((noteWorthyContribution, index) => ( - - )); - } - return ( -

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

- ); + if (contributions?.length > 0) { + return contributions.map((noteWorthyContribution, index) => ( + + )); } - return contributions?.map((noteWorthyContribution, index) => ( - - )); + return ( +

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

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

{emptyActiveTasksError}

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

{emptyActiveTasksError}

); }; @@ -81,18 +62,7 @@ const ContributionType = (props) => { }, [tasks.length, contributions.length]); 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 @@ -115,23 +85,16 @@ const ContributionType = (props) => {
{type !== 'Active tasks' ? (
- {devUser - ? renderContributions( - contributions, - fullName, - imageLink, - devUser, - type - ) - : renderContributions( - contributions, - fullName, - imageLink, - devUser - )} + {renderContributions( + contributions, + fullName, + imageLink, + devUser, + type + )}
) : ( -
{renderActiveTasks(tasks, devUser)}
+
{renderActiveTasks(tasks)}
)}

diff --git a/src/components/member-profile/contribution/index.js b/src/components/member-profile/contribution/index.js index 25d43aa7..afad425a 100644 --- a/src/components/member-profile/contribution/index.js +++ b/src/components/member-profile/contribution/index.js @@ -115,22 +115,22 @@ const ContributionCard = ({ if (isTitleAvailable) { if (status !== 'VERIFIED') { completedText = Estimated Completion: ; - 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 = Completed in: ; - 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 = ( Completed in ); - featureLiveDate = timeWas(updatedAt, true, Date.now(), devUser); + featureLiveDate = timeWas(updatedAt, true, Date.now()); featureLiveOnText = featureLiveDate; } } diff --git a/src/helper-functions/taskProgress.js b/src/helper-functions/taskProgress.js index d8715305..63bd75b0 100644 --- a/src/helper-functions/taskProgress.js +++ b/src/helper-functions/taskProgress.js @@ -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); diff --git a/src/helper-functions/time-was.js b/src/helper-functions/time-was.js index ad9f4033..31439cf3 100644 --- a/src/helper-functions/time-was.js +++ b/src/helper-functions/time-was.js @@ -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; diff --git a/src/test/unit/components/member-profile/index.test.js b/src/test/unit/components/member-profile/index.test.js index 361d9d49..651a3cba 100644 --- a/src/test/unit/components/member-profile/index.test.js +++ b/src/test/unit/components/member-profile/index.test.js @@ -108,7 +108,6 @@ describe('Members Profile', () => { @@ -199,7 +198,6 @@ describe('Members Profile', () => {