-
Notifications
You must be signed in to change notification settings - Fork 51
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 #2111 from ever-co/develop
Release
- Loading branch information
Showing
49 changed files
with
674 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
'use client'; | ||
|
||
const Error = () => { | ||
return <>Error Page...</>; | ||
import ErrorPage from '@components/pages/error'; | ||
|
||
const Error = ({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) => { | ||
return ( | ||
<> | ||
<ErrorPage error={error} reset={reset} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default Error; |
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,6 @@ | ||
import { getDefaultRequest } from '@app/services/server/requests/default'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
export async function GET() { | ||
return NextResponse.json(await getDefaultRequest()); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use client'; | ||
|
||
import React, { useCallback, useEffect } from 'react'; | ||
import { useQuery } from './useQuery'; | ||
import { getDefaultAPI } from '@app/services/client/api'; | ||
|
||
export function useCheckAPI() { | ||
const { queryCall } = useQuery(getDefaultAPI); | ||
const [isApiWork, setIsApiWork] = React.useState(true); | ||
|
||
const checkAPI = useCallback(() => { | ||
queryCall() | ||
.then(() => { | ||
setIsApiWork(true); | ||
}) | ||
.catch(() => { | ||
setIsApiWork(false); | ||
}); | ||
}, [queryCall]); | ||
|
||
useEffect(() => { | ||
checkAPI(); | ||
}, [checkAPI]); | ||
|
||
return { | ||
isApiWork | ||
}; | ||
} |
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,5 @@ | ||
import api from '../axios'; | ||
|
||
export function getDefaultAPI() { | ||
return api.get(`/`); | ||
} |
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,8 @@ | ||
import { serverFetch } from '../fetch'; | ||
|
||
export function getDefaultRequest() { | ||
return serverFetch({ | ||
path: `/`, | ||
method: 'GET' | ||
}); | ||
} |
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; |
Oops, something went wrong.