diff --git a/src/components/Activity/ActivityPage.tsx b/src/components/Activity/ActivityPage.tsx index da8da197d..354a0bdae 100644 --- a/src/components/Activity/ActivityPage.tsx +++ b/src/components/Activity/ActivityPage.tsx @@ -52,7 +52,7 @@ export function ActivityPage() { async function loadActivity() { const { error, response } = await httpGet( - `${import.meta.env.PUBLIC_API_URL}/v1-get-user-stats` + `${import.meta.env.PUBLIC_API_URL}/v1-get-user-stats`, ); if (!response || error) { @@ -79,6 +79,25 @@ export function ActivityPage() { return null; } + const learningRoadmapsToShow = learningRoadmaps + .sort((a, b) => { + const updatedAtA = new Date(a.updatedAt); + const updatedAtB = new Date(b.updatedAt); + + return updatedAtB.getTime() - updatedAtA.getTime(); + }) + .filter((roadmap) => roadmap.learning > 0 || roadmap.done > 0); + + const learningBestPracticesToShow = learningBestPractices + .sort((a, b) => { + const updatedAtA = new Date(a.updatedAt); + const updatedAtB = new Date(b.updatedAt); + + return updatedAtB.getTime() - updatedAtA.getTime(); + }) + .filter((bestPractice) => bestPractice.learning > 0 || bestPractice.done > 0); + + return ( <>
- {learningRoadmaps.length === 0 && - learningBestPractices.length === 0 && } + {learningRoadmapsToShow.length === 0 && + learningBestPracticesToShow.length === 0 && } - {(learningRoadmaps.length > 0 || learningBestPractices.length > 0) && ( + {(learningRoadmapsToShow.length > 0 || learningBestPracticesToShow.length > 0) && ( <>

Continue Following @@ -104,26 +123,38 @@ export function ActivityPage() { return updatedAtB.getTime() - updatedAtA.getTime(); }) - .map((roadmap) => ( - { - pageProgressMessage.set('Updating activity'); - loadActivity().finally(() => { - pageProgressMessage.set(''); - }); - }} - /> - ))} + .filter((roadmap) => roadmap.learning > 0 || roadmap.done > 0) + .map((roadmap) => { + const learningCount = roadmap.learning || 0; + const doneCount = roadmap.done || 0; + const totalCount = roadmap.total || 0; + const skippedCount = roadmap.skipped || 0; + + return ( + totalCount ? totalCount : doneCount + } + learningCount={ + learningCount > totalCount ? totalCount : learningCount + } + totalCount={totalCount} + skippedCount={skippedCount} + resourceId={roadmap.id} + resourceType={'roadmap'} + updatedAt={roadmap.updatedAt} + title={roadmap.title} + onCleared={() => { + pageProgressMessage.set('Updating activity'); + loadActivity().finally(() => { + pageProgressMessage.set(''); + }); + }} + /> + ); + })} {learningBestPractices .sort((a, b) => { @@ -132,6 +163,10 @@ export function ActivityPage() { return updatedAtB.getTime() - updatedAtA.getTime(); }) + .filter( + (bestPractice) => + bestPractice.learning > 0 || bestPractice.done > 0, + ) .map((bestPractice) => (