diff --git a/apps/web/app/hooks/features/useTimeDailyActivity.ts b/apps/web/app/hooks/features/useTimeDailyActivity.ts index 05fb4c129..ee2509123 100644 --- a/apps/web/app/hooks/features/useTimeDailyActivity.ts +++ b/apps/web/app/hooks/features/useTimeDailyActivity.ts @@ -9,7 +9,7 @@ import { useAuthenticateUser } from './useAuthenticateUser'; import { getTimerDailyRequestAPI } from '@app/services/client/api'; import { activityTypeState } from '@app/stores/activity-type'; -export function useTimeDailyActivity(type: string) { +export function useTimeDailyActivity(type?: string) { const { user } = useAuthenticateUser(); const [visitedApps, setVisitedApps] = useRecoilState(timeAppsState); const activityFilter = useRecoilValue(activityTypeState); @@ -22,7 +22,10 @@ export function useTimeDailyActivity(type: string) { const todayStart = moment().startOf('day').toDate(); const todayEnd = moment().endOf('day').toDate(); const employeeId = activityFilter.member ? activityFilter.member?.employeeId : user?.employee?.id; - if (activityFilter.member?.id === user?.id || user?.role?.name?.toUpperCase() == 'MANAGER') { + if ( + activityFilter.member?.employeeId === user?.employee.id || + user?.role?.name?.toUpperCase() == 'MANAGER' + ) { queryCall({ tenantId: user?.tenantId ?? '', organizationId: user?.employee.organizationId ?? '', diff --git a/apps/web/app/hooks/features/useTimeSlot.ts b/apps/web/app/hooks/features/useTimeSlot.ts index 9da075c82..54deda3f3 100644 --- a/apps/web/app/hooks/features/useTimeSlot.ts +++ b/apps/web/app/hooks/features/useTimeSlot.ts @@ -22,8 +22,8 @@ export function useTimeSlots(hasFilter?: boolean) { const getTimeSlots = useCallback(() => { const todayStart = moment().startOf('day').toDate(); const todayEnd = moment().endOf('day').toDate(); - const employeeId = hasFilter ? activityFilter.member?.employeeId : profile.member?.employeeId; - if (profile.userProfile?.id === user?.id || user?.role?.name?.toUpperCase() == 'MANAGER') { + const employeeId = activityFilter.member ? activityFilter.member?.employeeId : user?.employee?.id; + if (activityFilter.member?.employeeId === user?.employee.id || user?.role?.name?.toUpperCase() == 'MANAGER') { queryCall({ tenantId: user?.tenantId ?? '', organizationId: user?.employee.organizationId ?? '', @@ -37,18 +37,8 @@ export function useTimeSlots(hasFilter?: boolean) { } }); } - }, [ - hasFilter, - activityFilter.member?.employeeId, - profile.member?.employeeId, - profile.userProfile?.id, - user?.id, - user?.role?.name, - user?.tenantId, - user?.employee.organizationId, - queryCall, - setTimeSlots - ]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [hasFilter, activityFilter.member?.employeeId, profile.member?.employeeId, user?.id, queryCall, setTimeSlots]); const deleteTimeSlots = useCallback( (ids: string[]) => { diff --git a/apps/web/app/services/client/api/activity/activity.ts b/apps/web/app/services/client/api/activity/activity.ts index f64309313..755b37019 100644 --- a/apps/web/app/services/client/api/activity/activity.ts +++ b/apps/web/app/services/client/api/activity/activity.ts @@ -16,7 +16,7 @@ export async function getTimerDailyRequestAPI({ employeeId: string; todayEnd: Date; todayStart: Date; - type: string; + type?: string | undefined; title?: string; }) { const params: { @@ -25,18 +25,19 @@ export async function getTimerDailyRequestAPI({ 'employeeIds[0]': string; startDate: string; endDate: string; - 'types[0]': string; + 'types[0]'?: string; 'title[0]'?: string; } = { tenantId: tenantId, organizationId: organizationId, 'employeeIds[0]': employeeId, startDate: todayStart.toISOString(), - endDate: todayEnd.toISOString(), - 'types[0]': type + endDate: todayEnd.toISOString() }; + if (type) params['types[0]'] = type; if (title) params['title[0]'] = title; const query = new URLSearchParams(params); + console.log('QUERY', query); const endpoint = GAUZY_API_BASE_SERVER_URL.value ? `/timesheet/activity/daily?${query.toString()}` : `/timer/daily?${query.toString()}`; diff --git a/apps/web/lib/features/activity/apps.tsx b/apps/web/lib/features/activity/apps.tsx index 5bdcdb820..f274d5126 100644 --- a/apps/web/lib/features/activity/apps.tsx +++ b/apps/web/lib/features/activity/apps.tsx @@ -6,10 +6,9 @@ import AppVisitedItem from './components/app-visited-Item'; // import { AppVisitedModal } from './components/app-visited-details'; export function AppsTab() { - const { visitedApps, loading } = useTimeDailyActivity('APPS'); + const { visitedApps, loading } = useTimeDailyActivity(); const t = useTranslations(); const apps = groupAppsByHour(visitedApps); - console.log('INTO APP TAB'); return (
{/* TODO: Filters components */}
diff --git a/apps/web/lib/features/team/user-team-card/user-worked-task.tsx b/apps/web/lib/features/team/user-team-card/user-worked-task.tsx index d277b31ec..9f46000b4 100644 --- a/apps/web/lib/features/team/user-team-card/user-worked-task.tsx +++ b/apps/web/lib/features/team/user-team-card/user-worked-task.tsx @@ -9,5 +9,7 @@ export function UserWorkedTaskTab() { const profile = useUserDetails(activityFilter.member?.employeeId ?? ''); const hook = useTaskFilter(profile); + console.log({ hook, profile }); + return ; }