From ce518001b3b10bc83e9ec90701c49011ac0268c4 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 7 Aug 2024 22:07:36 +0200 Subject: [PATCH] fix: fix the number of outstanding tasks in notifications --- .../features/team/team-outstanding-notifications.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/web/lib/features/team/team-outstanding-notifications.tsx b/apps/web/lib/features/team/team-outstanding-notifications.tsx index 69dbef22a..2017b53ea 100644 --- a/apps/web/lib/features/team/team-outstanding-notifications.tsx +++ b/apps/web/lib/features/team/team-outstanding-notifications.tsx @@ -6,6 +6,7 @@ import { Tooltip } from 'lib/components'; import { useTranslations } from 'next-intl'; import Link from 'next/link'; import { useEffect, useState } from 'react'; +import { estimatedTotalTime } from '../task/daily-plan'; interface IEmployeeWithOutstanding { employeeId: string | undefined; @@ -25,7 +26,7 @@ export function TeamOutstandingNotifications() { return (
{outstandingPlans && outstandingPlans.length > 0 && ( - + )} {dailyPlan.items && dailyPlan.items.length > 0 && isTeamManager && ( @@ -35,7 +36,7 @@ export function TeamOutstandingNotifications() { ); } -function UserOutstandingNotification({ outstandingTasks, user }: { outstandingTasks: IDailyPlan[]; user?: IUser }) { +function UserOutstandingNotification({ outstandingPlans, user }: { outstandingPlans: IDailyPlan[]; user?: IUser }) { const t = useTranslations(); // Notification will be displayed 6 hours after the user closed it @@ -45,7 +46,9 @@ function UserOutstandingNotification({ outstandingTasks, user }: { outstandingTa const name = user?.name || user?.firstName || user?.lastName || user?.username; const [visible, setVisible] = useState(false); - const tasks = outstandingTasks.flatMap((plan) => plan.tasks); + const outStandingTasksCount = estimatedTotalTime( + outstandingPlans.map((plan) => plan.tasks?.map((task) => task)) + ).totalTasks; useEffect(() => { const checkNotification = () => { @@ -73,7 +76,7 @@ function UserOutstandingNotification({ outstandingTasks, user }: { outstandingTa {visible && (
- {t('pages.home.OUTSTANDING_NOTIFICATIONS.SUBJECT')} {tasks?.length}{' '} + {t('pages.home.OUTSTANDING_NOTIFICATIONS.SUBJECT')} {outStandingTasksCount}{' '} {t('pages.home.OUTSTANDING_NOTIFICATIONS.USER_LABEL')}{' '} {t('pages.home.OUTSTANDING_NOTIFICATIONS.OUTSTANDING_VIEW')}