-
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 #2109 from ever-co/feat/activityTask
Feat: activity for Task
- Loading branch information
Showing
39 changed files
with
438 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
'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 useUserSelectedPage(id?: string) { | ||
const { activeTeam } = useOrganizationTeams(); | ||
const { activeTeamTask, updateTask } = useTeamTasks(); | ||
|
||
const { user: auth } = useAuthenticateUser(); | ||
const { getTasksStatsData } = useTaskStatistics(); | ||
|
||
const memberId: string = id || ''; | ||
|
||
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 useUserSelectedPage>; |
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,41 @@ | ||
'use client'; | ||
|
||
import SadCry from '@components/ui/svgs/sad-cry'; | ||
import { Text } from 'lib/components'; | ||
import { useTranslations } from 'next-intl'; | ||
import React from 'react'; | ||
|
||
function ErrorPage({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) { | ||
const t = useTranslations(); | ||
|
||
React.useEffect(() => { | ||
console.error(error); | ||
}, [error]); | ||
|
||
return ( | ||
<div className="mt-28 flex flex-col gap-7 items-center"> | ||
<div className="m-auto relative flex justify-center items-center gap-4 text-center "> | ||
<SadCry width={97} height={97} /> | ||
<Text className="text-[78px] font-semibold text-chetwodeBlue">{t('pages.error.TITLE')}</Text> | ||
</div> | ||
|
||
<Text className="text-[40px] font-bold text-center text-[#282048] dark:text-light--theme"> | ||
{t('pages.error.HEADING_TITLE')} | ||
</Text> | ||
<div className="flex flex-col gap-4"> | ||
<Text className="text-[20px] font-normal text-center text-gray-400"> | ||
{t('pages.error.HEADING_DESCRIPTION')} | ||
</Text> | ||
<button onClick={() => reset()}>Try again</button> | ||
</div> | ||
|
||
<div className="p-2 flex flex-col gap-y-3 container max-w-5xl border border-red-500 rounded mt-5"> | ||
<h4 className="text-2xl text-red-400 font-medium">{JSON.stringify(error.cause)}</h4> | ||
<p className="text-lg text-red-400 font-semibold">{error.message}</p> | ||
<p className="text-sm text-red-400">{error.stack}</p> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default ErrorPage; |
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.