-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2100 from ever-co/feat/activity
Feat: Display Worked Tasks to Activity section in Team Member Card
- Loading branch information
Showing
18 changed files
with
282 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
'use client'; | ||
|
||
import { ITeamTask } from '@app/interfaces'; | ||
import { useCallback, useEffect } from 'react'; | ||
import { useAuthenticateUser } from './useAuthenticateUser'; | ||
import { useAuthTeamTasks } from './useAuthTeamTasks'; | ||
import { useOrganizationTeams } from './useOrganizationTeams'; | ||
import { useTaskStatistics } from './useTaskStatistics'; | ||
import { useTeamTasks } from './useTeamTasks'; | ||
|
||
export function useUserDetails(memberId: string) { | ||
const { activeTeam } = useOrganizationTeams(); | ||
const { activeTeamTask, updateTask } = useTeamTasks(); | ||
|
||
const { user: auth } = useAuthenticateUser(); | ||
const { getTasksStatsData } = useTaskStatistics(); | ||
|
||
const members = activeTeam?.members || []; | ||
|
||
const matchUser = members.find((m) => { | ||
return m.employee.userId === memberId; | ||
}); | ||
|
||
const isAuthUser = auth?.employee?.userId === memberId; | ||
|
||
const activeUserTeamTask = isAuthUser ? activeTeamTask : matchUser?.lastWorkedTask; | ||
|
||
const userProfile = isAuthUser ? auth : matchUser?.employee.user; | ||
|
||
const employeeId = isAuthUser ? auth?.employee?.id : matchUser?.employeeId; | ||
|
||
/* Filtering the tasks */ | ||
const tasksGrouped = useAuthTeamTasks(userProfile); | ||
|
||
useEffect(() => { | ||
if (employeeId) { | ||
getTasksStatsData(employeeId); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [employeeId]); | ||
|
||
const assignTask = useCallback( | ||
(task: ITeamTask) => { | ||
if (!matchUser?.employeeId) { | ||
return Promise.resolve(); | ||
} | ||
|
||
return updateTask({ | ||
...task, | ||
members: [...task.members, (matchUser?.employeeId ? { id: matchUser?.employeeId } : {}) as any] | ||
}); | ||
}, | ||
[updateTask, matchUser] | ||
); | ||
|
||
return { | ||
isAuthUser, | ||
activeUserTeamTask, | ||
userProfile, | ||
tasksGrouped, | ||
member: matchUser, | ||
assignTask | ||
}; | ||
} | ||
|
||
export type I_UserProfilePage = ReturnType<typeof useUserDetails>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { OT_Member } from './IOrganizationTeam'; | ||
|
||
export interface IActivityFilter { | ||
type: 'DATE' | 'TICKET'; | ||
member: OT_Member | null; | ||
taskId?: string; | ||
dateStart?: Date; | ||
dateStop?: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.