Skip to content

Commit

Permalink
fix: DailyActivity by profile user
Browse files Browse the repository at this point in the history
Cedric921 committed Jan 15, 2024
1 parent bb13272 commit 7fce7ca
Showing 2 changed files with 12 additions and 10 deletions.
9 changes: 5 additions & 4 deletions apps/web/app/hooks/features/useTimeDailyActivity.ts
Original file line number Diff line number Diff line change
@@ -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,
13 changes: 7 additions & 6 deletions apps/web/app/hooks/features/useTimeSlot.ts
Original file line number Diff line number Diff line change
@@ -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(

0 comments on commit 7fce7ca

Please sign in to comment.