From 7fce7ca87451d9b757a7025c5f4d8306a43be7b8 Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Mon, 15 Jan 2024 17:43:53 +0200 Subject: [PATCH] fix: DailyActivity by profile user --- apps/web/app/hooks/features/useTimeDailyActivity.ts | 9 +++++---- apps/web/app/hooks/features/useTimeSlot.ts | 13 +++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/web/app/hooks/features/useTimeDailyActivity.ts b/apps/web/app/hooks/features/useTimeDailyActivity.ts index aadf0efc7..59aa81626 100644 --- a/apps/web/app/hooks/features/useTimeDailyActivity.ts +++ b/apps/web/app/hooks/features/useTimeDailyActivity.ts @@ -10,23 +10,24 @@ import { getTimerDailyRequestAPI } from '@app/services/client/api'; import { useUserProfilePage } from './useUserProfilePage'; export function useTimeDailyActivity(type: string) { + const profile = useUserProfilePage(); const { user } = useAuthenticateUser(); const [visitedApps, setVisitedApps] = useRecoilState(timeAppsState); const [visitedAppDetail, setVisitedAppDetail] = useRecoilState(timeAppVisitedDetail); const [visitedSites, setVisitedSites] = useRecoilState(timeVisitedSitesState); - const profile = useUserProfilePage(); const { loading, queryCall } = useQuery(getTimerDailyRequestAPI); const getVisitedApps = useCallback( - ({ userId, title }: { userId?: string; title?: string }) => { + ({ title }: { title?: string }) => { const todayStart = moment().startOf('day').toDate(); const todayEnd = moment().endOf('day').toDate(); + const employeeId = profile.member?.employeeId ?? ''; if (profile.userProfile?.id === user?.id) { queryCall({ tenantId: user?.tenantId ?? '', organizationId: user?.employee.organizationId ?? '', - employeeId: userId ?? user?.employee.id ?? '', + employeeId: employeeId, todayEnd, type, todayStart, @@ -44,11 +45,11 @@ export function useTimeDailyActivity(type: string) { } }, [ + profile.member?.employeeId, profile.userProfile?.id, user?.id, user?.tenantId, user?.employee.organizationId, - user?.employee.id, queryCall, type, setVisitedAppDetail, diff --git a/apps/web/app/hooks/features/useTimeSlot.ts b/apps/web/app/hooks/features/useTimeSlot.ts index 7243d6e70..92b2267d4 100644 --- a/apps/web/app/hooks/features/useTimeSlot.ts +++ b/apps/web/app/hooks/features/useTimeSlot.ts @@ -20,11 +20,12 @@ export function useTimeSlots() { const getTimeSlots = useCallback(() => { const todayStart = moment().startOf('day').toDate(); const todayEnd = moment().endOf('day').toDate(); + const employeeId = profile.member?.employeeId ?? ''; if (profile.userProfile?.id === user?.id) { queryCall({ tenantId: user?.tenantId ?? '', organizationId: user?.employee.organizationId ?? '', - employeeId: user?.employee.id ?? '', + employeeId: employeeId, todayEnd, todayStart }).then((response) => { @@ -35,13 +36,13 @@ export function useTimeSlots() { }); } }, [ + profile.member?.employeeId, profile.userProfile?.id, - queryCall, - setTimeSlots, - user?.employee.id, - user?.employee.organizationId, user?.id, - user?.tenantId + user?.tenantId, + user?.employee.organizationId, + queryCall, + setTimeSlots ]); const deleteTimeSlots = useCallback(