From 82f806838ed3814a69c82dc1f1398f754b28c8ec Mon Sep 17 00:00:00 2001 From: Ruslan K Date: Sun, 25 Feb 2024 14:37:15 +0100 Subject: [PATCH] Revert "Feat/Static build (#2233)" This reverts commit 6534e6033ed4f3d4dc523890925e274c5c541db1. --- apps/web/app/[locale]/[...rest]/page.tsx | 5 - .../app/[locale]/auth/passcode/component.tsx | 388 ----------------- apps/web/app/[locale]/auth/passcode/page.tsx | 390 +++++++++++++++++- apps/web/app/[locale]/auth/team/component.tsx | 199 --------- apps/web/app/[locale]/auth/team/page.tsx | 201 ++++++++- apps/web/app/[locale]/board/component.tsx | 25 -- apps/web/app/[locale]/board/page.tsx | 29 +- .../[locale]/integration/github/component.tsx | 71 ---- .../app/[locale]/integration/github/page.tsx | 77 +++- apps/web/app/[locale]/meet/component.tsx | 71 ---- apps/web/app/[locale]/meet/page.tsx | 73 +++- apps/web/app/[locale]/page-component.tsx | 142 ------- apps/web/app/[locale]/page.tsx | 143 ++++++- .../app/[locale]/permissions/component.tsx | 293 ------------- apps/web/app/[locale]/permissions/page.tsx | 297 ++++++++++++- .../api/image-assets/upload/[folder]/route.ts | 7 +- .../app/api/integration-tenant/[id]/route.ts | 17 +- apps/web/app/api/invite/[id]/route.ts | 18 +- apps/web/app/api/issue-types/[id]/route.ts | 20 +- .../api/organization-projects/[id]/route.ts | 8 +- .../setting/[id]/route.ts | 11 +- .../[id]/active-task/route.ts | 27 +- .../organization-team-employee/[id]/route.ts | 37 +- .../[id]/[action]/route.ts | 28 +- .../app/api/organization-team/[id]/route.ts | 87 ++-- .../organization-team/employee/[id]/route.ts | 30 +- .../api/organization-team/teams/[id]/route.ts | 17 +- .../team/[profileLink]/[teamId]/route.ts | 19 +- .../app/api/role-permissions/[id]/route.ts | 21 +- apps/web/app/api/roles/[id]/route.ts | 19 +- apps/web/app/api/tags/[id]/route.ts | 35 +- .../web/app/api/task-priorities/[id]/route.ts | 26 +- .../task-related-issue-types/[id]/route.ts | 34 +- apps/web/app/api/task-sizes/[id]/route.ts | 30 +- apps/web/app/api/task-statuses/[id]/route.ts | 32 +- apps/web/app/api/task-versions/[id]/route.ts | 32 +- apps/web/app/api/tasks/[id]/route.ts | 24 +- .../api/tasks/employee/[employeeId]/route.ts | 35 +- apps/web/app/api/user/[id]/route.ts | 36 +- apps/web/app/constants.ts | 3 - .../hooks/auth/useAuthenticationPasscode.ts | 1 - .../app/hooks/auth/useAuthenticationTeam.ts | 9 +- apps/web/app/hooks/features/useTimeSlot.ts | 5 +- .../app/services/client/api/task-status.ts | 9 +- apps/web/middleware.ts | 3 +- apps/web/next.config.js | 4 +- 46 files changed, 1419 insertions(+), 1669 deletions(-) delete mode 100644 apps/web/app/[locale]/auth/passcode/component.tsx delete mode 100644 apps/web/app/[locale]/auth/team/component.tsx delete mode 100644 apps/web/app/[locale]/board/component.tsx delete mode 100644 apps/web/app/[locale]/integration/github/component.tsx delete mode 100644 apps/web/app/[locale]/meet/component.tsx delete mode 100644 apps/web/app/[locale]/page-component.tsx delete mode 100644 apps/web/app/[locale]/permissions/component.tsx diff --git a/apps/web/app/[locale]/[...rest]/page.tsx b/apps/web/app/[locale]/[...rest]/page.tsx index 404797c6e..302287916 100644 --- a/apps/web/app/[locale]/[...rest]/page.tsx +++ b/apps/web/app/[locale]/[...rest]/page.tsx @@ -1,10 +1,5 @@ -import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants'; import { notFound } from 'next/navigation'; export default function CatchAllPage() { notFound(); } - -export async function generateStaticParams() { - return [{ locale: APPLICATION_DEFAULT_LANGUAGE, rest: [] }]; -} diff --git a/apps/web/app/[locale]/auth/passcode/component.tsx b/apps/web/app/[locale]/auth/passcode/component.tsx deleted file mode 100644 index 5b286ec54..000000000 --- a/apps/web/app/[locale]/auth/passcode/component.tsx +++ /dev/null @@ -1,388 +0,0 @@ -'use client'; - -import { getAccessTokenCookie, getActiveUserIdCookie } from '@app/helpers'; -import { TAuthenticationPasscode, useAuthenticationPasscode } from '@app/hooks'; -import { IClassName } from '@app/interfaces'; -import { clsxm } from '@app/utils'; -import { AuthCodeInputField, Avatar, BackButton, Button, Card, InputField, SpinnerLoader, Text } from 'lib/components'; -import { CircleIcon, TickCircleIconV2 } from 'lib/components/svgs'; -import { AuthLayout } from 'lib/layout'; -import { useTranslations } from 'next-intl'; -import Link from 'next/link'; -import { useRouter } from 'next/navigation'; -import { FormEvent, useCallback, useEffect, useRef, useState } from 'react'; - -import stc from 'string-to-color'; - -function AuthPasscode() { - const form = useAuthenticationPasscode(); - const t = useTranslations(); - const router = useRouter(); - - useEffect(() => { - const userId = getActiveUserIdCookie(); - if (userId) { - router.replace('/'); - } - }, [router]); - - return ( - - {t('pages.authLogin.HEADING_WORKSPACE_LINE1')} -
- {t('pages.authLogin.HEADING_WORKSPACE_LINE2')} - - ) : ( - t('pages.authLogin.HEADING_DESCRIPTION') - ) - } - > -
-
- {form.authScreen.screen === 'email' && } - {form.authScreen.screen === 'passcode' && ( - - )} - - {form.authScreen.screen === 'workspace' && ( - - )} -
-
-
- ); -} - -function EmailScreen({ form, className }: { form: TAuthenticationPasscode } & IClassName) { - const t = useTranslations(); - - const handleSendCode = useCallback( - (e: FormEvent) => { - e.preventDefault(); - - form.sendAuthCodeHandler().then(() => { - form.authScreen.setScreen('passcode'); - }); - }, - [form] - ); - - return ( -
- -
- - {t('pages.auth.ENTER_EMAIL')} - - - {/* Email input */} - - -
- {/* Send code */} -
-
- {t('common.DONT_HAVE_ACCOUNT')} - - {t('common.REGISTER')} - -
-
- - -
-
-
-
- ); -} - -function PasscodeScreen({ form, className }: { form: TAuthenticationPasscode } & IClassName) { - const t = useTranslations(); - const inputsRef = useRef>([]); - const resetForm = () => { - if (inputsRef.current) { - for (let i = 0; i < inputsRef.current.length; i++) { - inputsRef.current[i].value = ''; - } - inputsRef.current[0].focus(); - } - }; - return ( -
- -
- - {t('pages.auth.LOGIN')} - - - {/* Auth code input */} -
-
- - {t('pages.auth.INPUT_INVITE_CODE')} - - resetForm()} - className="text-xs font-normal cursor-pointer hover:underline text-gray-400" - > - {t('common.RESET')} - -
- - { - form.setFormValues((v) => ({ ...v, code })); - }} - hintType={ - form.errors['code'] || form.errors['email'] - ? 'error' - : form.authenticated - ? 'success' - : undefined - } - autoFocus={form.authScreen.screen === 'passcode'} - /> - {(form.errors['code'] || form.errors['email']) && ( - - {form.errors['code'] || form.errors['email']} - - )} -
- -
- {/* Send code */} -
-
- - {t('pages.auth.UNRECEIVED_CODE')} - - - {!form.sendCodeLoading && ( - - )} - {form.sendCodeLoading && } -
- -
- { - form.authScreen.setScreen('email'); - form.setErrors({}); - }} - /> -
-
- - -
-
-
-
- ); -} - -function WorkSpaceScreen({ form, className }: { form: TAuthenticationPasscode } & IClassName) { - const t = useTranslations(); - - const [selectedWorkspace, setSelectedWorkspace] = useState(0); - const [selectedTeam, setSelectedTeam] = useState(''); - const router = useRouter(); - - const signInToWorkspace = useCallback( - (e: any) => { - if (typeof selectedWorkspace !== 'undefined') { - form.handleWorkspaceSubmit(e, form.workspaces[selectedWorkspace].token, selectedTeam); - } - }, - [selectedWorkspace, selectedTeam, form] - ); - - useEffect(() => { - if (form.workspaces.length === 1) { - setSelectedWorkspace(0); - } - - const currentTeams = form.workspaces[0]?.current_teams; - - if (form.workspaces.length === 1 && currentTeams?.length === 1) { - setSelectedTeam(currentTeams[0].team_id); - } - if (form.workspaces.length === 1 && (currentTeams?.length || 0) <= 1) { - setTimeout(() => { - document.getElementById('continue-to-workspace')?.click(); - }, 100); - } - }, [form.workspaces]); - - useEffect(() => { - if (form.authScreen.screen === 'workspace') { - const accessToken = getAccessTokenCookie(); - if (accessToken && accessToken.length > 100) { - router.refresh(); - } - } - }, [form.authScreen, router]); - - console.log(form); - - return ( -
- -
- - {t('pages.auth.SELECT_WORKSPACE')} - - -
- {form.workspaces?.map((worksace, index) => ( -
-
-
- {worksace.user.tenant.name} - { - setSelectedWorkspace(index); - if ( - selectedTeam && - !worksace.current_teams - ?.map((team) => team.team_id) - .includes(selectedTeam) - ) { - setSelectedTeam(worksace.current_teams[0].team_id); - } - }} - > - {selectedWorkspace === index ? ( - - ) : ( - - )} - -
- - {/*
*/} -
- {worksace.current_teams?.map((team) => ( -
- - -
- - {team.team_name} - - ({team.team_member_count}) -
-
- { - setSelectedTeam(team.team_id); - if (selectedWorkspace !== index) { - setSelectedWorkspace(index); - } - }} - > - {selectedTeam === team.team_id ? ( - - ) : ( - - )} - -
- ))} -
-
-
- ))} -
- -
-
-
- { - form.authScreen.setScreen('email'); - form.setErrors({}); - }} - /> -
-
- - -
-
-
-
- ); -} - -export default AuthPasscode; diff --git a/apps/web/app/[locale]/auth/passcode/page.tsx b/apps/web/app/[locale]/auth/passcode/page.tsx index 79cbc90df..43b673bc2 100644 --- a/apps/web/app/[locale]/auth/passcode/page.tsx +++ b/apps/web/app/[locale]/auth/passcode/page.tsx @@ -1,10 +1,388 @@ -import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants'; -import AuthPasscode from './component'; +'use client'; -export async function generateStaticParams() { - return [{ locale: APPLICATION_DEFAULT_LANGUAGE }]; +import { getAccessTokenCookie, getActiveUserIdCookie } from '@app/helpers'; +import { TAuthenticationPasscode, useAuthenticationPasscode } from '@app/hooks'; +import { IClassName } from '@app/interfaces'; +import { clsxm } from '@app/utils'; +import { AuthCodeInputField, Avatar, BackButton, Button, Card, InputField, SpinnerLoader, Text } from 'lib/components'; +import { CircleIcon, TickCircleIconV2 } from 'lib/components/svgs'; +import { AuthLayout } from 'lib/layout'; +import { useTranslations } from 'next-intl'; +import Link from 'next/link'; +import { useRouter } from 'next/navigation'; +import { FormEvent, useCallback, useEffect, useRef, useState } from 'react'; + +import stc from 'string-to-color'; + +function AuthPasscode() { + const form = useAuthenticationPasscode(); + const t = useTranslations(); + const router = useRouter(); + + useEffect(() => { + const userId = getActiveUserIdCookie(); + if (userId) { + router.replace('/'); + } + }, [router]); + + return ( + + {t('pages.authLogin.HEADING_WORKSPACE_LINE1')} +
+ {t('pages.authLogin.HEADING_WORKSPACE_LINE2')} + + ) : ( + t('pages.authLogin.HEADING_DESCRIPTION') + ) + } + > +
+
+ {form.authScreen.screen === 'email' && } + {form.authScreen.screen === 'passcode' && ( + + )} + + {form.authScreen.screen === 'workspace' && ( + + )} +
+
+
+ ); } -export default function Page() { - return ; +export default AuthPasscode; + +function EmailScreen({ form, className }: { form: TAuthenticationPasscode } & IClassName) { + const t = useTranslations(); + + const handleSendCode = useCallback( + (e: FormEvent) => { + e.preventDefault(); + + form.sendAuthCodeHandler().then(() => { + form.authScreen.setScreen('passcode'); + }); + }, + [form] + ); + + return ( +
+ +
+ + {t('pages.auth.ENTER_EMAIL')} + + + {/* Email input */} + + +
+ {/* Send code */} +
+
+ {t('common.DONT_HAVE_ACCOUNT')} + + {t('common.REGISTER')} + +
+
+ + +
+
+
+
+ ); +} + +function PasscodeScreen({ form, className }: { form: TAuthenticationPasscode } & IClassName) { + const t = useTranslations(); + const inputsRef = useRef>([]); + const resetForm = () => { + if (inputsRef.current) { + for (let i = 0; i < inputsRef.current.length; i++) { + inputsRef.current[i].value = ''; + } + inputsRef.current[0].focus(); + } + }; + return ( +
+ +
+ + {t('pages.auth.LOGIN')} + + + {/* Auth code input */} +
+
+ + {t('pages.auth.INPUT_INVITE_CODE')} + + resetForm()} + className="text-xs font-normal cursor-pointer hover:underline text-gray-400" + > + {t('common.RESET')} + +
+ + { + form.setFormValues((v) => ({ ...v, code })); + }} + hintType={ + form.errors['code'] || form.errors['email'] + ? 'error' + : form.authenticated + ? 'success' + : undefined + } + autoFocus={form.authScreen.screen === 'passcode'} + /> + {(form.errors['code'] || form.errors['email']) && ( + + {form.errors['code'] || form.errors['email']} + + )} +
+ +
+ {/* Send code */} +
+
+ + {t('pages.auth.UNRECEIVED_CODE')} + + + {!form.sendCodeLoading && ( + + )} + {form.sendCodeLoading && } +
+ +
+ { + form.authScreen.setScreen('email'); + form.setErrors({}); + }} + /> +
+
+ + +
+
+
+
+ ); +} + +function WorkSpaceScreen({ form, className }: { form: TAuthenticationPasscode } & IClassName) { + const t = useTranslations(); + + const [selectedWorkspace, setSelectedWorkspace] = useState(0); + const [selectedTeam, setSelectedTeam] = useState(''); + const router = useRouter(); + + const signInToWorkspace = useCallback( + (e: any) => { + if (typeof selectedWorkspace !== 'undefined') { + form.handleWorkspaceSubmit(e, form.workspaces[selectedWorkspace].token, selectedTeam); + } + }, + [selectedWorkspace, selectedTeam, form] + ); + + useEffect(() => { + if (form.workspaces.length === 1) { + setSelectedWorkspace(0); + } + + const currentTeams = form.workspaces[0]?.current_teams; + + if (form.workspaces.length === 1 && currentTeams?.length === 1) { + setSelectedTeam(currentTeams[0].team_id); + } + if (form.workspaces.length === 1 && (currentTeams?.length || 0) <= 1) { + setTimeout(() => { + document.getElementById('continue-to-workspace')?.click(); + }, 100); + } + }, [form.workspaces]); + + useEffect(() => { + if (form.authScreen.screen === 'workspace') { + const accessToken = getAccessTokenCookie(); + if (accessToken && accessToken.length > 100) { + router.refresh(); + } + } + }, [form.authScreen, router]); + + console.log(form); + + return ( +
+ +
+ + {t('pages.auth.SELECT_WORKSPACE')} + + +
+ {form.workspaces?.map((worksace, index) => ( +
+
+
+ {worksace.user.tenant.name} + { + setSelectedWorkspace(index); + if ( + selectedTeam && + !worksace.current_teams + ?.map((team) => team.team_id) + .includes(selectedTeam) + ) { + setSelectedTeam(worksace.current_teams[0].team_id); + } + }} + > + {selectedWorkspace === index ? ( + + ) : ( + + )} + +
+ + {/*
*/} +
+ {worksace.current_teams?.map((team) => ( +
+ + +
+ + {team.team_name} + + ({team.team_member_count}) +
+
+ { + setSelectedTeam(team.team_id); + if (selectedWorkspace !== index) { + setSelectedWorkspace(index); + } + }} + > + {selectedTeam === team.team_id ? ( + + ) : ( + + )} + +
+ ))} +
+
+
+ ))} +
+ +
+
+
+ { + form.authScreen.setScreen('email'); + form.setErrors({}); + }} + /> +
+
+ + +
+
+
+
+ ); } diff --git a/apps/web/app/[locale]/auth/team/component.tsx b/apps/web/app/[locale]/auth/team/component.tsx deleted file mode 100644 index 057a36221..000000000 --- a/apps/web/app/[locale]/auth/team/component.tsx +++ /dev/null @@ -1,199 +0,0 @@ -'use client'; - -import { RECAPTCHA_SITE_KEY } from '@app/constants'; -import { useAuthenticationTeam, IStepProps } from '@app/hooks'; -import { IClassName } from '@app/interfaces'; -import { clsxm } from '@app/utils'; -import { BackButton, BackdropLoader, Button, Card, InputField, SiteReCAPTCHA, Text } from 'lib/components'; -import { AuthLayout } from 'lib/layout'; -import { useState } from 'react'; -import { useTranslations } from 'next-intl'; - -function AuthTeam() { - const { - handleSubmit, - step, - FIRST_STEP, - // SECOND_STEP, - handleOnChange, - setStep, - errors, - formValues, - loading - } = useAuthenticationTeam(); - - const t = useTranslations(); - - return ( - <> - -
-
-
-
- -
- -
- setStep(FIRST_STEP)} - loading={loading} - /> -
-
-
-
- -
- - ); -} - -/** - * First step form Component - * - * @param param0 - * @returns - */ -function FillTeamNameForm({ - form, - errors, - handleOnChange, - className -}: IStepProps & { errors: Record } & IClassName) { - const t = useTranslations(); - - return ( - -
- - {t('pages.authTeam.INPUT_TEAM_NAME')} - - - - -
- - {t('pages.auth.LOGIN')} - - - -
-
-
- ); -} - -/** - * Second step form component - * - * @param param0 - * @returns - */ -function FillUserDataForm({ - form, - errors, - handleOnChange, - onPreviousStep, - loading, - className -}: IStepProps & { - errors: Record; - onPreviousStep?: () => void; - loading?: boolean; -} & IClassName) { - const t = useTranslations(); - - return ( - -
- - {t('pages.authTeam.CREATE_FIRST_TEAM')} - - -
- - - -
- -
- - - -
-
-
- ); -} - -function ReCAPTCHA({ handleOnChange, errors }: { handleOnChange: any; errors: any }) { - const t = useTranslations(); - const [feedback, setFeedback] = useState(''); - - const content = RECAPTCHA_SITE_KEY.value && ( -
-
- { - handleOnChange({ target: { name: 'recaptcha', value: res } }); - setFeedback(''); - }} - onErrored={() => setFeedback(t('errors.NETWORK_ISSUE'))} - /> - {(errors['recaptcha'] || feedback) && ( - {errors['recaptcha'] || feedback} - )} -
-
- ); - - return content || <>; -} - -export default AuthTeam; diff --git a/apps/web/app/[locale]/auth/team/page.tsx b/apps/web/app/[locale]/auth/team/page.tsx index 92a1bdd3e..057a36221 100644 --- a/apps/web/app/[locale]/auth/team/page.tsx +++ b/apps/web/app/[locale]/auth/team/page.tsx @@ -1,10 +1,199 @@ -import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants'; -import AuthTeam from './component'; +'use client'; -export async function generateStaticParams() { - return [{ locale: APPLICATION_DEFAULT_LANGUAGE }]; +import { RECAPTCHA_SITE_KEY } from '@app/constants'; +import { useAuthenticationTeam, IStepProps } from '@app/hooks'; +import { IClassName } from '@app/interfaces'; +import { clsxm } from '@app/utils'; +import { BackButton, BackdropLoader, Button, Card, InputField, SiteReCAPTCHA, Text } from 'lib/components'; +import { AuthLayout } from 'lib/layout'; +import { useState } from 'react'; +import { useTranslations } from 'next-intl'; + +function AuthTeam() { + const { + handleSubmit, + step, + FIRST_STEP, + // SECOND_STEP, + handleOnChange, + setStep, + errors, + formValues, + loading + } = useAuthenticationTeam(); + + const t = useTranslations(); + + return ( + <> + +
+
+
+
+ +
+ +
+ setStep(FIRST_STEP)} + loading={loading} + /> +
+
+
+
+ +
+ + ); } -export default function Page() { - return ; +/** + * First step form Component + * + * @param param0 + * @returns + */ +function FillTeamNameForm({ + form, + errors, + handleOnChange, + className +}: IStepProps & { errors: Record } & IClassName) { + const t = useTranslations(); + + return ( + +
+ + {t('pages.authTeam.INPUT_TEAM_NAME')} + + + + +
+ + {t('pages.auth.LOGIN')} + + + +
+
+
+ ); } + +/** + * Second step form component + * + * @param param0 + * @returns + */ +function FillUserDataForm({ + form, + errors, + handleOnChange, + onPreviousStep, + loading, + className +}: IStepProps & { + errors: Record; + onPreviousStep?: () => void; + loading?: boolean; +} & IClassName) { + const t = useTranslations(); + + return ( + +
+ + {t('pages.authTeam.CREATE_FIRST_TEAM')} + + +
+ + + +
+ +
+ + + +
+
+
+ ); +} + +function ReCAPTCHA({ handleOnChange, errors }: { handleOnChange: any; errors: any }) { + const t = useTranslations(); + const [feedback, setFeedback] = useState(''); + + const content = RECAPTCHA_SITE_KEY.value && ( +
+
+ { + handleOnChange({ target: { name: 'recaptcha', value: res } }); + setFeedback(''); + }} + onErrored={() => setFeedback(t('errors.NETWORK_ISSUE'))} + /> + {(errors['recaptcha'] || feedback) && ( + {errors['recaptcha'] || feedback} + )} +
+
+ ); + + return content || <>; +} + +export default AuthTeam; diff --git a/apps/web/app/[locale]/board/component.tsx b/apps/web/app/[locale]/board/component.tsx deleted file mode 100644 index b6fefefae..000000000 --- a/apps/web/app/[locale]/board/component.tsx +++ /dev/null @@ -1,25 +0,0 @@ -'use client'; - -import { withAuthentication } from 'lib/app/authenticator'; -import { BackdropLoader, Meta } from 'lib/components'; -import dynamic from 'next/dynamic'; - -const Board = dynamic(() => import('lib/features/integrations/boards'), { - ssr: false, - loading: () => -}); - -function BoardPage() { - return ( - <> -
- - -
- - ); -} - -export default withAuthentication(BoardPage, { - displayName: 'BoardIntegrationPage' -}); diff --git a/apps/web/app/[locale]/board/page.tsx b/apps/web/app/[locale]/board/page.tsx index 832a406e6..b6fefefae 100644 --- a/apps/web/app/[locale]/board/page.tsx +++ b/apps/web/app/[locale]/board/page.tsx @@ -1,10 +1,25 @@ -import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants'; -import BoardPage from './component'; +'use client'; -export async function generateStaticParams() { - return [{ locale: APPLICATION_DEFAULT_LANGUAGE }]; -} +import { withAuthentication } from 'lib/app/authenticator'; +import { BackdropLoader, Meta } from 'lib/components'; +import dynamic from 'next/dynamic'; + +const Board = dynamic(() => import('lib/features/integrations/boards'), { + ssr: false, + loading: () => +}); -export default function Page() { - return ; +function BoardPage() { + return ( + <> +
+ + +
+ + ); } + +export default withAuthentication(BoardPage, { + displayName: 'BoardIntegrationPage' +}); diff --git a/apps/web/app/[locale]/integration/github/component.tsx b/apps/web/app/[locale]/integration/github/component.tsx deleted file mode 100644 index 666fa38db..000000000 --- a/apps/web/app/[locale]/integration/github/component.tsx +++ /dev/null @@ -1,71 +0,0 @@ -'use client'; - -import { useIntegrationTenant, useIntegrationTypes } from '@app/hooks'; -import { useGitHubIntegration } from '@app/hooks/integrations/useGitHubIntegration'; -import { withAuthentication } from 'lib/app/authenticator'; -import { BackdropLoader } from 'lib/components'; -import { useTranslations } from 'next-intl'; -import { useRouter, useSearchParams } from 'next/navigation'; -import { useCallback, useEffect, useRef } from 'react'; - -const GitHub = () => { - const router = useRouter(); - const searchParams = useSearchParams(); - const installation_id = searchParams?.get('installation_id'); - const setup_action = searchParams?.get('setup_action'); - - const t = useTranslations(); - - const installing = useRef(false); - - const { installGitHub, getRepositories } = useGitHubIntegration(); - const { getIntegrationTenant, loading: integrationTenantLoading, integrationTenant } = useIntegrationTenant(); - const { loading: loadingIntegrationTypes, integrationTypes, getIntegrationTypes } = useIntegrationTypes(); - - const handleInstallGitHub = useCallback(() => { - installing.current = true; - - if (installation_id && setup_action) { - setTimeout(() => { - installGitHub(installation_id as string, setup_action as string).then(() => { - router.replace('/settings/team#integrations'); - }); - }, 100); - } - }, [installGitHub, router, installation_id, setup_action]); - - useEffect(() => { - if (installing.current) { - return; - } - - handleInstallGitHub(); - }, [handleInstallGitHub]); - - useEffect(() => { - if (!integrationTenantLoading && integrationTenant && integrationTenant.length && integrationTenant[0]?.id) { - getRepositories(integrationTenant[0].id); - } - }, [integrationTenantLoading, integrationTenant, getRepositories]); - - useEffect(() => { - if (!loadingIntegrationTypes && integrationTypes.length === 0) { - getIntegrationTypes().then((types) => { - const allIntegrations = types.find((item: any) => item.name === 'All Integrations'); - if (allIntegrations && allIntegrations?.id) { - getIntegrationTenant('Github'); - } - }); - } - }, [loadingIntegrationTypes, integrationTypes, getIntegrationTypes, getIntegrationTenant]); - - return ( -
- -
- ); -}; - -export default withAuthentication(GitHub, { - displayName: 'GitHubIntegrationPage' -}); diff --git a/apps/web/app/[locale]/integration/github/page.tsx b/apps/web/app/[locale]/integration/github/page.tsx index 01902a261..666fa38db 100644 --- a/apps/web/app/[locale]/integration/github/page.tsx +++ b/apps/web/app/[locale]/integration/github/page.tsx @@ -1,10 +1,71 @@ -import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants'; -import GitHubPage from './component'; +'use client'; -export async function generateStaticParams() { - return [{ locale: APPLICATION_DEFAULT_LANGUAGE }]; -} +import { useIntegrationTenant, useIntegrationTypes } from '@app/hooks'; +import { useGitHubIntegration } from '@app/hooks/integrations/useGitHubIntegration'; +import { withAuthentication } from 'lib/app/authenticator'; +import { BackdropLoader } from 'lib/components'; +import { useTranslations } from 'next-intl'; +import { useRouter, useSearchParams } from 'next/navigation'; +import { useCallback, useEffect, useRef } from 'react'; -export default function Page() { - return ; -} +const GitHub = () => { + const router = useRouter(); + const searchParams = useSearchParams(); + const installation_id = searchParams?.get('installation_id'); + const setup_action = searchParams?.get('setup_action'); + + const t = useTranslations(); + + const installing = useRef(false); + + const { installGitHub, getRepositories } = useGitHubIntegration(); + const { getIntegrationTenant, loading: integrationTenantLoading, integrationTenant } = useIntegrationTenant(); + const { loading: loadingIntegrationTypes, integrationTypes, getIntegrationTypes } = useIntegrationTypes(); + + const handleInstallGitHub = useCallback(() => { + installing.current = true; + + if (installation_id && setup_action) { + setTimeout(() => { + installGitHub(installation_id as string, setup_action as string).then(() => { + router.replace('/settings/team#integrations'); + }); + }, 100); + } + }, [installGitHub, router, installation_id, setup_action]); + + useEffect(() => { + if (installing.current) { + return; + } + + handleInstallGitHub(); + }, [handleInstallGitHub]); + + useEffect(() => { + if (!integrationTenantLoading && integrationTenant && integrationTenant.length && integrationTenant[0]?.id) { + getRepositories(integrationTenant[0].id); + } + }, [integrationTenantLoading, integrationTenant, getRepositories]); + + useEffect(() => { + if (!loadingIntegrationTypes && integrationTypes.length === 0) { + getIntegrationTypes().then((types) => { + const allIntegrations = types.find((item: any) => item.name === 'All Integrations'); + if (allIntegrations && allIntegrations?.id) { + getIntegrationTenant('Github'); + } + }); + } + }, [loadingIntegrationTypes, integrationTypes, getIntegrationTypes, getIntegrationTenant]); + + return ( +
+ +
+ ); +}; + +export default withAuthentication(GitHub, { + displayName: 'GitHubIntegrationPage' +}); diff --git a/apps/web/app/[locale]/meet/component.tsx b/apps/web/app/[locale]/meet/component.tsx deleted file mode 100644 index 6ae1fd1fc..000000000 --- a/apps/web/app/[locale]/meet/component.tsx +++ /dev/null @@ -1,71 +0,0 @@ -'use client'; - -import { useCollaborative, useQuery } from '@app/hooks'; -import { getMeetJwtAuthTokenAPI } from '@app/services/client/api'; -import { withAuthentication } from 'lib/app/authenticator'; -import { BackdropLoader, Meta } from 'lib/components'; -import dynamic from 'next/dynamic'; -import { useRouter, usePathname } from 'next/navigation'; -import { useEffect, useMemo, useRef, useState } from 'react'; - -const Meet = dynamic(() => import('lib/features/integrations/meet'), { - ssr: false, - loading: () => -}); - -function useMeetJwtToken() { - const [token, setToken] = useState(); - const { queryCall, loading } = useQuery(getMeetJwtAuthTokenAPI); - - useEffect(() => { - queryCall().then((res) => setToken(res.data.token)); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - return { loading, token }; -} - -function MeetPage() { - const router = useRouter(); - const pathname = usePathname(); - const { token } = useMeetJwtToken(); - const { randomMeetName } = useCollaborative(); - const replaced = useRef(false); - - const room = useMemo(() => { - if (!pathname) { - return false; - } - - const urlParams = pathname.substring(pathname.indexOf('?')); - const searchParams = new URLSearchParams(urlParams); - - return searchParams.get('room'); - }, [pathname]); - - useEffect(() => { - if (!room && pathname?.startsWith('/meet') && !replaced.current) { - const url = new URL(window.location.href); - url.searchParams.set('room', btoa(randomMeetName())); - - router.replace(url.pathname + url.search); - replaced.current = true; - } - }, [room, router, randomMeetName, pathname]); - - const roomName = useMemo(() => { - return room ? atob(room) : undefined; - }, [room]); - - return ( - <> - - {token && roomName && } - - ); -} - -export default withAuthentication(MeetPage, { - displayName: 'MeetPage', - showPageSkeleton: false -}); diff --git a/apps/web/app/[locale]/meet/page.tsx b/apps/web/app/[locale]/meet/page.tsx index 10f29fab0..6ae1fd1fc 100644 --- a/apps/web/app/[locale]/meet/page.tsx +++ b/apps/web/app/[locale]/meet/page.tsx @@ -1,10 +1,71 @@ -import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants'; -import MeetPage from './component'; +'use client'; -export default function Page() { - return ; +import { useCollaborative, useQuery } from '@app/hooks'; +import { getMeetJwtAuthTokenAPI } from '@app/services/client/api'; +import { withAuthentication } from 'lib/app/authenticator'; +import { BackdropLoader, Meta } from 'lib/components'; +import dynamic from 'next/dynamic'; +import { useRouter, usePathname } from 'next/navigation'; +import { useEffect, useMemo, useRef, useState } from 'react'; + +const Meet = dynamic(() => import('lib/features/integrations/meet'), { + ssr: false, + loading: () => +}); + +function useMeetJwtToken() { + const [token, setToken] = useState(); + const { queryCall, loading } = useQuery(getMeetJwtAuthTokenAPI); + + useEffect(() => { + queryCall().then((res) => setToken(res.data.token)); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + return { loading, token }; } -export async function generateStaticParams() { - return [{ locale: APPLICATION_DEFAULT_LANGUAGE }]; +function MeetPage() { + const router = useRouter(); + const pathname = usePathname(); + const { token } = useMeetJwtToken(); + const { randomMeetName } = useCollaborative(); + const replaced = useRef(false); + + const room = useMemo(() => { + if (!pathname) { + return false; + } + + const urlParams = pathname.substring(pathname.indexOf('?')); + const searchParams = new URLSearchParams(urlParams); + + return searchParams.get('room'); + }, [pathname]); + + useEffect(() => { + if (!room && pathname?.startsWith('/meet') && !replaced.current) { + const url = new URL(window.location.href); + url.searchParams.set('room', btoa(randomMeetName())); + + router.replace(url.pathname + url.search); + replaced.current = true; + } + }, [room, router, randomMeetName, pathname]); + + const roomName = useMemo(() => { + return room ? atob(room) : undefined; + }, [room]); + + return ( + <> + + {token && roomName && } + + ); } + +export default withAuthentication(MeetPage, { + displayName: 'MeetPage', + showPageSkeleton: false +}); diff --git a/apps/web/app/[locale]/page-component.tsx b/apps/web/app/[locale]/page-component.tsx deleted file mode 100644 index 8b9b40e64..000000000 --- a/apps/web/app/[locale]/page-component.tsx +++ /dev/null @@ -1,142 +0,0 @@ -/* eslint-disable no-mixed-spaces-and-tabs */ - -'use client'; - -import React, { useEffect } from 'react'; -import { useOrganizationTeams } from '@app/hooks'; -import { clsxm } from '@app/utils'; -import NoTeam from '@components/pages/main/no-team'; -import { withAuthentication } from 'lib/app/authenticator'; -import { Breadcrumb, Card, Container } from 'lib/components'; -import { PeopleIcon } from 'lib/components/svgs'; -import { - AuthUserTaskInput, - TeamInvitations, - TeamMembers, - Timer, - UnverifiedEmail, - UserTeamCardHeader, - UserTeamBlockHeader -} from 'lib/features'; -import { MainHeader, MainLayout } from 'lib/layout'; -import { IssuesView } from '@app/constants'; -import { useNetworkState } from '@uidotdev/usehooks'; -import Offline from '@components/pages/offline'; -import UserTeamTableHeader from 'lib/features/team/user-team-table/user-team-table-header'; -import { useTranslations } from 'next-intl'; - -import { Analytics } from '@vercel/analytics/react'; -import ChatwootWidget from 'lib/features/integrations/chatwoot'; - -import 'react-loading-skeleton/dist/skeleton.css'; -import '../../styles/globals.css'; - -import { useRecoilState, useRecoilValue } from 'recoil'; -import { fullWidthState } from '@app/stores/fullWidth'; -import { ChevronDown } from 'lucide-react'; -import HeaderTabs from '@components/pages/main/header-tabs'; -import { headerTabs } from '@app/stores/header-tabs'; -import { usePathname } from 'next/navigation'; - -function MainPage() { - const t = useTranslations(); - const { isTeamMember, isTrackingEnabled, activeTeam } = useOrganizationTeams(); - const fullWidth = useRecoilValue(fullWidthState); - const [view, setView] = useRecoilState(headerTabs); - const path = usePathname(); - const breadcrumb = [ - { title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/' }, - { title: activeTeam?.name || '', href: '/' }, - { title: t(`common.${view}`), href: `/` } - ]; - const { online } = useNetworkState(); - console.log(path, 'path'); - useEffect(() => { - if (view == IssuesView.KANBAN && path == '/') { - setView(IssuesView.CARDS); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [path, setView]); - if (!online) { - return ; - } - return ( - <> - - - -
-
- - -
-
- -
-
- - - -
- -
- - {isTeamMember ? : null} - {view === IssuesView.CARDS && isTeamMember ? ( - - ) : view === IssuesView.BLOCKS ? ( - - ) : view === IssuesView.TABLE ? ( - - ) : null} - - - {/* Divider */} -
-
- - - {isTeamMember ? : } - -
- - - - ); -} - -function TaskTimerSection({ isTrackingEnabled }: { isTrackingEnabled: boolean }) { - const [showInput, setShowInput] = React.useState(false); - return ( - - -
setShowInput((p) => !p)} - className="border dark:border-[#26272C] w-full rounded p-2 md:hidden flex justify-center mt-2" - > - - {showInput ? 'hide the issue input' : 'show the issue input'} - -
- {isTrackingEnabled ? ( -
- -
- ) : null} -
- ); -} - -export default withAuthentication(MainPage, { displayName: 'MainPage' }); diff --git a/apps/web/app/[locale]/page.tsx b/apps/web/app/[locale]/page.tsx index d14938210..7ae07954d 100644 --- a/apps/web/app/[locale]/page.tsx +++ b/apps/web/app/[locale]/page.tsx @@ -1,10 +1,141 @@ -import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants'; -import MainPage from './page-component'; +/* eslint-disable no-mixed-spaces-and-tabs */ -export async function generateStaticParams() { - return [{ locale: APPLICATION_DEFAULT_LANGUAGE }]; +'use client'; + +import React, { useEffect } from 'react'; +import { useOrganizationTeams } from '@app/hooks'; +import { clsxm } from '@app/utils'; +import NoTeam from '@components/pages/main/no-team'; +import { withAuthentication } from 'lib/app/authenticator'; +import { Breadcrumb, Card, Container } from 'lib/components'; +import { PeopleIcon } from 'lib/components/svgs'; +import { + AuthUserTaskInput, + TeamInvitations, + TeamMembers, + Timer, + UnverifiedEmail, + UserTeamCardHeader, + UserTeamBlockHeader +} from 'lib/features'; +import { MainHeader, MainLayout } from 'lib/layout'; +import { IssuesView } from '@app/constants'; +import { useNetworkState } from '@uidotdev/usehooks'; +import Offline from '@components/pages/offline'; +import UserTeamTableHeader from 'lib/features/team/user-team-table/user-team-table-header'; +import { useTranslations } from 'next-intl'; + +import { Analytics } from '@vercel/analytics/react'; +import ChatwootWidget from 'lib/features/integrations/chatwoot'; + +import 'react-loading-skeleton/dist/skeleton.css'; +import '../../styles/globals.css'; + +import { useRecoilState, useRecoilValue } from 'recoil'; +import { fullWidthState } from '@app/stores/fullWidth'; +import { ChevronDown } from 'lucide-react'; +import HeaderTabs from '@components/pages/main/header-tabs'; +import { headerTabs } from '@app/stores/header-tabs'; +import { usePathname } from 'next/navigation'; + +function MainPage() { + const t = useTranslations(); + const { isTeamMember, isTrackingEnabled, activeTeam } = useOrganizationTeams(); + const fullWidth = useRecoilValue(fullWidthState); + const [view, setView] = useRecoilState(headerTabs); + const path = usePathname(); + const breadcrumb = [ + { title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/' }, + { title: activeTeam?.name || '', href: '/' }, + { title: t(`common.${view}`), href: `/` } + ]; + const { online } = useNetworkState(); + console.log(path, 'path'); + useEffect(() => { + if (view == IssuesView.KANBAN && path == '/') { + setView(IssuesView.CARDS); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [path, setView]); + if (!online) { + return ; + } + return ( + <> + + + +
+
+ + +
+
+ +
+
+ + + +
+ +
+ + {isTeamMember ? : null} + {view === IssuesView.CARDS && isTeamMember ? ( + + ) : view === IssuesView.BLOCKS ? ( + + ) : view === IssuesView.TABLE ? ( + + ) : null} + + + {/* Divider */} +
+
+ + + {isTeamMember ? : } + +
+ + + + ); } -export default function Page() { - return ; +function TaskTimerSection({ isTrackingEnabled }: { isTrackingEnabled: boolean }) { + const [showInput, setShowInput] = React.useState(false); + return ( + + +
setShowInput((p) => !p)} + className="border dark:border-[#26272C] w-full rounded p-2 md:hidden flex justify-center mt-2" + > + + {showInput ? 'hide the issue input' : 'show the issue input'} + +
+ {isTrackingEnabled ? ( +
+ +
+ ) : null} +
+ ); } +export default withAuthentication(MainPage, { displayName: 'MainPage' }); diff --git a/apps/web/app/[locale]/permissions/component.tsx b/apps/web/app/[locale]/permissions/component.tsx deleted file mode 100644 index 39e802d77..000000000 --- a/apps/web/app/[locale]/permissions/component.tsx +++ /dev/null @@ -1,293 +0,0 @@ -'use client'; - -import { useIsMemberManager, useOrganizationTeams, useRolePermissions } from '@app/hooks'; -import { useRoles } from '@app/hooks/features/useRoles'; -import { IRole } from '@app/interfaces'; -import { userState } from '@app/stores'; -import NotFound from '@components/pages/404'; -import { withAuthentication } from 'lib/app/authenticator'; -import { Breadcrumb, Card, CommonToggle, Container, Divider, Text } from 'lib/components'; -import { MainHeader, MainLayout } from 'lib/layout'; -import { useCallback, useEffect, useState } from 'react'; -import { useTranslations } from 'next-intl'; -import { useRecoilState, useRecoilValue } from 'recoil'; - -import { fullWidthState } from '@app/stores/fullWidth'; - -const Permissions = () => { - const t = useTranslations(); - const { activeTeamManagers } = useOrganizationTeams(); - const { rolePermissionsFormated, getRolePermissions, updateRolePermission } = useRolePermissions(); - - const [selectedRole, setSelectedRole] = useState(null); - const fullWidth = useRecoilValue(fullWidthState); - - const [user] = useRecoilState(userState); - const { isTeamManager } = useIsMemberManager(user); - - useEffect(() => { - selectedRole && selectedRole?.id && getRolePermissions(selectedRole.id); - }, [selectedRole, getRolePermissions]); - - const { getRoles, roles } = useRoles(); - useEffect(() => { - getRoles(); - }, [getRoles]); - - const handleToggleRolePermission = useCallback( - (name: string) => { - const permission = rolePermissionsFormated[name]; - - updateRolePermission({ - ...permission, - enabled: !permission.enabled - }).then(() => { - selectedRole && selectedRole?.id && getRolePermissions(selectedRole.id); - }); - }, - [rolePermissionsFormated, selectedRole, getRolePermissions, updateRolePermission] - ); - - if (activeTeamManagers && activeTeamManagers.length && !isTeamManager) { - return ( - - - - ); - } - - return ( - - - - - - -
- {roles.map((role) => ( -
{ - setSelectedRole(role); - }} - > - {role?.name} -
- ))} -
- - - -
- {selectedRole && ( -
-
- - {t('pages.settingsTeam.TRACK_TIME')} - -
- { - handleToggleRolePermission('TIME_TRACKER'); - }} - /> -
-
-
- - Estimate issue - -
- { - handleToggleRolePermission('ORG_TASK_ADD'); - handleToggleRolePermission('ORG_TASK_EDIT'); - }} - /> -
-
-
- - {t('pages.settingsTeam.EPICS_CREATE_CLOSE')} - -
- { - handleToggleRolePermission('ORG_TASK_ADD'); - handleToggleRolePermission('ORG_TASK_EDIT'); - }} - /> -
-
-
- - {t('pages.settingsTeam.ISSUE_CREATE_CLOSE')} - -
- { - handleToggleRolePermission('ORG_TASK_ADD'); - handleToggleRolePermission('ORG_TASK_EDIT'); - }} - /> -
-
-
- - {t('pages.settingsTeam.ISSUE_ASSIGN_UNASSIGN')} - -
- { - handleToggleRolePermission('ORG_TASK_ADD'); - handleToggleRolePermission('ORG_TASK_EDIT'); - }} - /> -
-
-
- - {t('pages.settingsTeam.INVITE_MEMBERS')} - -
- { - handleToggleRolePermission('ORG_INVITE_EDIT'); - }} - /> -
-
-
- - {t('pages.settingsTeam.REMOVE_MEMBERS')} - -
- { - handleToggleRolePermission('ORG_EMPLOYEES_EDIT'); - handleToggleRolePermission('CHANGE_SELECTED_EMPLOYEE'); - }} - /> -
-
-
- - {t('pages.settingsTeam.HANDLE_REQUESTS')} - -
- { - handleToggleRolePermission('ORG_TEAM_JOIN_REQUEST_EDIT'); - }} - /> -
-
-
- - {t('pages.settingsTeam.ROLES_POSITIONS_CHANGE')} - -
- { - handleToggleRolePermission('ORG_EMPLOYEES_EDIT'); - }} - /> -
-
-
- - {t('pages.settingsTeam.VIEW_DETAILS')} - -
- { - handleToggleRolePermission('ORG_TASK_VIEW'); - }} - /> -
-
-
- )} - {!selectedRole && } -
-
-
-
- ); -}; - -function SelectRole() { - return ( -
-
- ! -
- - - Please Select any Role - -
- ); -} - -export default withAuthentication(Permissions, { - displayName: 'PermissionPage' -}); diff --git a/apps/web/app/[locale]/permissions/page.tsx b/apps/web/app/[locale]/permissions/page.tsx index 3cb2520a5..39e802d77 100644 --- a/apps/web/app/[locale]/permissions/page.tsx +++ b/apps/web/app/[locale]/permissions/page.tsx @@ -1,10 +1,293 @@ -import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants'; -import PermissionPage from './component'; +'use client'; -export default function Page() { - return ; -} +import { useIsMemberManager, useOrganizationTeams, useRolePermissions } from '@app/hooks'; +import { useRoles } from '@app/hooks/features/useRoles'; +import { IRole } from '@app/interfaces'; +import { userState } from '@app/stores'; +import NotFound from '@components/pages/404'; +import { withAuthentication } from 'lib/app/authenticator'; +import { Breadcrumb, Card, CommonToggle, Container, Divider, Text } from 'lib/components'; +import { MainHeader, MainLayout } from 'lib/layout'; +import { useCallback, useEffect, useState } from 'react'; +import { useTranslations } from 'next-intl'; +import { useRecoilState, useRecoilValue } from 'recoil'; + +import { fullWidthState } from '@app/stores/fullWidth'; + +const Permissions = () => { + const t = useTranslations(); + const { activeTeamManagers } = useOrganizationTeams(); + const { rolePermissionsFormated, getRolePermissions, updateRolePermission } = useRolePermissions(); + + const [selectedRole, setSelectedRole] = useState(null); + const fullWidth = useRecoilValue(fullWidthState); + + const [user] = useRecoilState(userState); + const { isTeamManager } = useIsMemberManager(user); + + useEffect(() => { + selectedRole && selectedRole?.id && getRolePermissions(selectedRole.id); + }, [selectedRole, getRolePermissions]); + + const { getRoles, roles } = useRoles(); + useEffect(() => { + getRoles(); + }, [getRoles]); + + const handleToggleRolePermission = useCallback( + (name: string) => { + const permission = rolePermissionsFormated[name]; -export async function generateStaticParams() { - return [{ locale: APPLICATION_DEFAULT_LANGUAGE }]; + updateRolePermission({ + ...permission, + enabled: !permission.enabled + }).then(() => { + selectedRole && selectedRole?.id && getRolePermissions(selectedRole.id); + }); + }, + [rolePermissionsFormated, selectedRole, getRolePermissions, updateRolePermission] + ); + + if (activeTeamManagers && activeTeamManagers.length && !isTeamManager) { + return ( + + + + ); + } + + return ( + + + + + + +
+ {roles.map((role) => ( +
{ + setSelectedRole(role); + }} + > + {role?.name} +
+ ))} +
+ + + +
+ {selectedRole && ( +
+
+ + {t('pages.settingsTeam.TRACK_TIME')} + +
+ { + handleToggleRolePermission('TIME_TRACKER'); + }} + /> +
+
+
+ + Estimate issue + +
+ { + handleToggleRolePermission('ORG_TASK_ADD'); + handleToggleRolePermission('ORG_TASK_EDIT'); + }} + /> +
+
+
+ + {t('pages.settingsTeam.EPICS_CREATE_CLOSE')} + +
+ { + handleToggleRolePermission('ORG_TASK_ADD'); + handleToggleRolePermission('ORG_TASK_EDIT'); + }} + /> +
+
+
+ + {t('pages.settingsTeam.ISSUE_CREATE_CLOSE')} + +
+ { + handleToggleRolePermission('ORG_TASK_ADD'); + handleToggleRolePermission('ORG_TASK_EDIT'); + }} + /> +
+
+
+ + {t('pages.settingsTeam.ISSUE_ASSIGN_UNASSIGN')} + +
+ { + handleToggleRolePermission('ORG_TASK_ADD'); + handleToggleRolePermission('ORG_TASK_EDIT'); + }} + /> +
+
+
+ + {t('pages.settingsTeam.INVITE_MEMBERS')} + +
+ { + handleToggleRolePermission('ORG_INVITE_EDIT'); + }} + /> +
+
+
+ + {t('pages.settingsTeam.REMOVE_MEMBERS')} + +
+ { + handleToggleRolePermission('ORG_EMPLOYEES_EDIT'); + handleToggleRolePermission('CHANGE_SELECTED_EMPLOYEE'); + }} + /> +
+
+
+ + {t('pages.settingsTeam.HANDLE_REQUESTS')} + +
+ { + handleToggleRolePermission('ORG_TEAM_JOIN_REQUEST_EDIT'); + }} + /> +
+
+
+ + {t('pages.settingsTeam.ROLES_POSITIONS_CHANGE')} + +
+ { + handleToggleRolePermission('ORG_EMPLOYEES_EDIT'); + }} + /> +
+
+
+ + {t('pages.settingsTeam.VIEW_DETAILS')} + +
+ { + handleToggleRolePermission('ORG_TASK_VIEW'); + }} + /> +
+
+
+ )} + {!selectedRole && } +
+
+
+
+ ); +}; + +function SelectRole() { + return ( +
+
+ ! +
+ + + Please Select any Role + +
+ ); } + +export default withAuthentication(Permissions, { + displayName: 'PermissionPage' +}); diff --git a/apps/web/app/api/image-assets/upload/[folder]/route.ts b/apps/web/app/api/image-assets/upload/[folder]/route.ts index 449d7d5a8..c075fd57b 100644 --- a/apps/web/app/api/image-assets/upload/[folder]/route.ts +++ b/apps/web/app/api/image-assets/upload/[folder]/route.ts @@ -5,16 +5,13 @@ import { INextParams } from '@app/interfaces'; export async function POST(req: Request, { params }: INextParams) { const res = new NextResponse(); - const folderParam = params.folder; - - if (!folderParam) { - return; - } const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return NextResponse.json({}, { status: 401 }); + const folderParam = params.folder as string; + const form = await req.formData(); const response = await createImageAssetsRequest( diff --git a/apps/web/app/api/integration-tenant/[id]/route.ts b/apps/web/app/api/integration-tenant/[id]/route.ts index 63939f7d5..240d97b26 100644 --- a/apps/web/app/api/integration-tenant/[id]/route.ts +++ b/apps/web/app/api/integration-tenant/[id]/route.ts @@ -1,20 +1,17 @@ -import { INextParams } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { deleteIntegrationTenantRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - const integrationId = params.id; - - if (!integrationId) { - return; - } - const { $res, user, access_token, tenantId, organizationId } = await authenticatedGuard(req, res); if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); - const response = await deleteIntegrationTenantRequest(integrationId, tenantId, organizationId, access_token); + const { id } = params; - return $res(response.data); + if (id) { + const response = await deleteIntegrationTenantRequest(id as string, tenantId, organizationId, access_token); + + return $res(response.data); + } } diff --git a/apps/web/app/api/invite/[id]/route.ts b/apps/web/app/api/invite/[id]/route.ts index ad8204836..8aa06b6f1 100644 --- a/apps/web/app/api/invite/[id]/route.ts +++ b/apps/web/app/api/invite/[id]/route.ts @@ -11,13 +11,13 @@ import { NextResponse } from 'next/server'; export async function GET(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - if (!params.id) { - return NextResponse.json({}, { status: 400 }); - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return NextResponse.json({}, { status: 401 }); + if (params.id) { + return NextResponse.json({}, { status: 400 }); + } + const { data } = await getMyInvitationsRequest(tenantId, access_token); return $res(data); @@ -25,15 +25,15 @@ export async function GET(req: Request, { params }: { params: { id: string } }) export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); + const { $res, user, access_token, tenantId, organizationId, teamId } = await authenticatedGuard(req, res); + if (!user) return NextResponse.json({}, { status: 401 }); + const invitationId = params.id; - if (!invitationId) { + if (params.id) { return NextResponse.json({}, { status: 400 }); } - const { $res, user, access_token, tenantId, organizationId, teamId } = await authenticatedGuard(req, res); - if (!user) return NextResponse.json({}, { status: 401 }); - await removeTeamInvitationsRequest({ bearer_token: access_token, tenantId: tenantId, @@ -63,7 +63,7 @@ export async function PUT(req: Request, { params }: { params: { id: string } }) const { searchParams } = new URL(req.url); const { action } = searchParams as unknown as { action: string }; - if (!invitationId) { + if (params.id) { return NextResponse.json({}, { status: 400 }); } diff --git a/apps/web/app/api/issue-types/[id]/route.ts b/apps/web/app/api/issue-types/[id]/route.ts index 133aa941a..adc5bef54 100644 --- a/apps/web/app/api/issue-types/[id]/route.ts +++ b/apps/web/app/api/issue-types/[id]/route.ts @@ -1,22 +1,18 @@ -import { INextParams } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { deleteIssueTypesRequest, editIssueTypesRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + const { id } = params; const body = await req.json(); const response = await editIssueTypesRequest({ - id: params.id, + id, datas: body, bearer_token: access_token, tenantId @@ -25,18 +21,16 @@ export async function PUT(req: Request, { params }: INextParams) { return $res(response.data); } -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + const { id } = params; + const response = await deleteIssueTypesRequest({ - id: params.id, + id, bearer_token: access_token, tenantId }); diff --git a/apps/web/app/api/organization-projects/[id]/route.ts b/apps/web/app/api/organization-projects/[id]/route.ts index 072bf41d9..0b2242eb3 100644 --- a/apps/web/app/api/organization-projects/[id]/route.ts +++ b/apps/web/app/api/organization-projects/[id]/route.ts @@ -5,18 +5,16 @@ import { NextResponse } from 'next/server'; export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + const { id } = params; + const body = await req.json(); const response = await editOrganizationProjectsRequest({ bearer_token: access_token, - id: params.id, + id, datas: body, tenantId }); diff --git a/apps/web/app/api/organization-projects/setting/[id]/route.ts b/apps/web/app/api/organization-projects/setting/[id]/route.ts index ab96a8a0c..830715142 100644 --- a/apps/web/app/api/organization-projects/setting/[id]/route.ts +++ b/apps/web/app/api/organization-projects/setting/[id]/route.ts @@ -1,24 +1,19 @@ -import { INextParams } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { editOrganizationProjectsSettingsRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + const { id } = params; const body = await req.json(); const response = await editOrganizationProjectsSettingsRequest({ - id: params.id, bearer_token: access_token, + id, datas: body, tenantId }); diff --git a/apps/web/app/api/organization-team-employee/[id]/active-task/route.ts b/apps/web/app/api/organization-team-employee/[id]/active-task/route.ts index 58e6592b1..5857a8804 100644 --- a/apps/web/app/api/organization-team-employee/[id]/active-task/route.ts +++ b/apps/web/app/api/organization-team-employee/[id]/active-task/route.ts @@ -1,27 +1,24 @@ -import { INextParams, IOrganizationTeamEmployeeUpdate } from '@app/interfaces'; +import { IOrganizationTeamEmployeeUpdate } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { updateOrganizationTeamEmployeeActiveTaskRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) return NextResponse.json({ error: 'unauthorized' }, { status: 401 }); + const { id } = params; const body = (await req.json()) as IOrganizationTeamEmployeeUpdate; - const response = await updateOrganizationTeamEmployeeActiveTaskRequest({ - id: params.id, - bearer_token: access_token, - tenantId, - body - }); + if (id) { + const response = await updateOrganizationTeamEmployeeActiveTaskRequest({ + id: id as string, + bearer_token: access_token, + tenantId, + body + }); - return $res(response.data); + return $res(response.data); + } } diff --git a/apps/web/app/api/organization-team-employee/[id]/route.ts b/apps/web/app/api/organization-team-employee/[id]/route.ts index 0940d00e7..1d5b2e580 100644 --- a/apps/web/app/api/organization-team-employee/[id]/route.ts +++ b/apps/web/app/api/organization-team-employee/[id]/route.ts @@ -1,4 +1,4 @@ -import { INextParams, IOrganizationTeamEmployeeUpdate } from '@app/interfaces'; +import { IOrganizationTeamEmployeeUpdate } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { deleteOrganizationTeamEmployeeRequest, @@ -6,52 +6,47 @@ import { } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) return $res('Unauthorized'); const body = (await req.json()) as IOrganizationTeamEmployeeUpdate; + const { id } = params; + const response = await updateOrganizationTeamEmployeeRequest({ - id: params.id, + id: id as string, bearer_token: access_token, tenantId, body: body }); - return $res(response.data); + if (id) { + return $res(response.data); + } } -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId, organizationId, teamId } = await authenticatedGuard(req, res); - if (!user) return $res('Unauthorized'); const { searchParams } = new URL(req.url); - const employeeId = searchParams.get('employeeId') as string; + const { employeeId } = searchParams as unknown as { employeeId: string }; + const { id } = params; const response = await deleteOrganizationTeamEmployeeRequest({ - id: params.id, + id: id as string, bearer_token: access_token, tenantId, organizationId, - employeeId: employeeId, + employeeId: employeeId as string, organizationTeamId: teamId }); - return $res(response.data); + if (id) { + return $res(response.data); + } } diff --git a/apps/web/app/api/organization-team-join/[id]/[action]/route.ts b/apps/web/app/api/organization-team-join/[id]/[action]/route.ts index 231e673d0..251f06eb0 100644 --- a/apps/web/app/api/organization-team-join/[id]/[action]/route.ts +++ b/apps/web/app/api/organization-team-join/[id]/[action]/route.ts @@ -1,25 +1,23 @@ -import { INextParams, IRequestToJoinActionEnum } from '@app/interfaces'; +import { IRequestToJoinActionEnum } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { acceptRejectRequestToJoinRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request, { params }: { params: { id: string; action: string } }) { const res = new NextResponse(); - - if (!params.id || !params.action) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) return $res('unauthorized'); - const response = await acceptRejectRequestToJoinRequest({ - id: params.id, - bearer_token: access_token, - tenantId, - action: params.action as IRequestToJoinActionEnum - }); + const { id, action } = params; + + if (id) { + const response = await acceptRejectRequestToJoinRequest({ + id: id as string, + bearer_token: access_token, + tenantId, + action: action as IRequestToJoinActionEnum + }); - return $res(response.data); + return $res(response.data); + } } diff --git a/apps/web/app/api/organization-team/[id]/route.ts b/apps/web/app/api/organization-team/[id]/route.ts index 859e621da..d7b40d03b 100644 --- a/apps/web/app/api/organization-team/[id]/route.ts +++ b/apps/web/app/api/organization-team/[id]/route.ts @@ -1,4 +1,3 @@ -import { INextParams } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { @@ -8,73 +7,67 @@ import { } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function GET(req: Request, { params }: INextParams) { +export async function GET(req: Request) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, organizationId, access_token, tenantId, teamId } = await authenticatedGuard(req, res); - if (!user) return NextResponse.json({}, { status: 400 }); - const { data } = await getOrganizationTeamRequest( - { - organizationId, - tenantId, - teamId: teamId - }, - access_token - ); + const getTeamStatus = async () => { + const { data: team } = await getOrganizationTeamRequest( + { + organizationId, + tenantId, + teamId: teamId + }, + access_token + ); - return $res(data); + return team; + }; + + return $res(await getTeamStatus()); } -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, organizationId, access_token, tenantId, teamId } = await authenticatedGuard(req, res); - if (!user) return NextResponse.json({}, { status: 400 }); const body = await req.json(); - const { data } = await getOrganizationTeamRequest( - { - organizationId, - tenantId, - teamId: teamId - }, - access_token - ); + const getTeamStatus = async () => { + const { data: team } = await getOrganizationTeamRequest( + { + organizationId, + tenantId, + teamId: teamId + }, + access_token + ); + + return team; + }; await updateOrganizationTeamRequest(body, access_token); - return $res(data); + return $res(await getTeamStatus()); } -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, organizationId, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) return NextResponse.json({}, { status: 400 }); - const response = await deleteOrganizationTeamRequest({ - id: params.id, - bearer_token: access_token, - tenantId, - organizationId - }); + const { id } = params; + + if (id) { + const response = await deleteOrganizationTeamRequest({ + id: id as string, + bearer_token: access_token, + tenantId, + organizationId + }); - return $res(response.data); + return $res(response.data); + } } diff --git a/apps/web/app/api/organization-team/employee/[id]/route.ts b/apps/web/app/api/organization-team/employee/[id]/route.ts index ef073312e..e2ccbf950 100644 --- a/apps/web/app/api/organization-team/employee/[id]/route.ts +++ b/apps/web/app/api/organization-team/employee/[id]/route.ts @@ -1,4 +1,3 @@ -import { INextParams } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { addEmployeeOrganizationTeamOrderRequest, @@ -6,45 +5,44 @@ import { } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); + const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); + if (!user) return NextResponse.json({}, { status: 401 }); - if (!params.id) { + const { id } = params; + + if (!id) { return NextResponse.json({}, { status: 405 }); } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - - if (!user) return NextResponse.json({}, { status: 401 }); - const response = await removeEmployeeOrganizationTeamRequest({ bearer_token: access_token, tenantId, - employeeId: params.id + employeeId: id.toString() }); return $res(response.data); } -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return NextResponse.json({}, { status: 405 }); - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) return NextResponse.json({}, { status: 401 }); const body = await req.json(); + const { id } = params; const order = body.order; + if (!id) { + return NextResponse.json({}, { status: 405 }); + } + const response = await addEmployeeOrganizationTeamOrderRequest({ bearer_token: access_token, - employeeId: params.id, tenantId, + employeeId: id.toString(), order, organizationTeamId: body.organizationTeamId, organizationId: body.organizationId diff --git a/apps/web/app/api/organization-team/teams/[id]/route.ts b/apps/web/app/api/organization-team/teams/[id]/route.ts index 99b3fb650..534da9d44 100644 --- a/apps/web/app/api/organization-team/teams/[id]/route.ts +++ b/apps/web/app/api/organization-team/teams/[id]/route.ts @@ -1,24 +1,19 @@ -import { INextParams } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { removeUserFromAllTeam } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return NextResponse.json({}, { status: 400 }); - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); + if (!user) return NextResponse.json({}, { status: 401 }); + + const { id } = params; - if (!user) { - return NextResponse.json({}, { status: 401 }); - } + if (!id) return NextResponse.json({}, { status: 400 }); const response = await removeUserFromAllTeam({ - userId: params.id, + userId: id as string, bearer_token: access_token, tenantId }); diff --git a/apps/web/app/api/public/team/[profileLink]/[teamId]/route.ts b/apps/web/app/api/public/team/[profileLink]/[teamId]/route.ts index 8b1227b78..861839fe0 100644 --- a/apps/web/app/api/public/team/[profileLink]/[teamId]/route.ts +++ b/apps/web/app/api/public/team/[profileLink]/[teamId]/route.ts @@ -1,32 +1,27 @@ -import { INextParams } from '@app/interfaces'; import { getPublicOrganizationTeamMiscDataRequest, getPublicOrganizationTeamRequest } from '@app/services/server/requests/public-organization-team'; import { NextResponse } from 'next/server'; -export async function GET(req: Request, { params }: INextParams) { +export async function GET(req: Request, { params }: { params: { profileLink: string; teamId: string } }) { const { searchParams } = new URL(req.url); - if (!params.profileLink || !params.teamId) { - return; - } - - const type = searchParams.get('type') as string; + const { profileLink, teamId } = params; + const { type } = searchParams as unknown as { type: string }; if (type === 'misc') { const response = await getPublicOrganizationTeamMiscDataRequest({ - profileLink: params.profileLink, - teamId: params.teamId + profileLink: profileLink, + teamId }); return NextResponse.json(response.data); } const response = await getPublicOrganizationTeamRequest({ - profileLink: params.profileLink, - teamId: params.teamId + profileLink: profileLink, + teamId }); - return NextResponse.json(response.data); } diff --git a/apps/web/app/api/role-permissions/[id]/route.ts b/apps/web/app/api/role-permissions/[id]/route.ts index ac15e3d36..6ceb4941c 100644 --- a/apps/web/app/api/role-permissions/[id]/route.ts +++ b/apps/web/app/api/role-permissions/[id]/route.ts @@ -1,35 +1,26 @@ -import { INextParams } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { getRolePermissionsRequest, updateRolePermissionRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function GET(req: Request, { params }: INextParams) { +export async function GET(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return NextResponse.json({}, { status: 400 }); - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('unauthorized'); + const { id } = params; + const response = await getRolePermissionsRequest({ - roleId: params.id, bearer_token: access_token, - tenantId + tenantId, + roleId: id as string }); return $res(response.data); } -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request) { const res = new NextResponse(); - - if (!params.id) { - return NextResponse.json({}, { status: 400 }); - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('unauthorized'); diff --git a/apps/web/app/api/roles/[id]/route.ts b/apps/web/app/api/roles/[id]/route.ts index 5f6283bc0..94bf659bc 100644 --- a/apps/web/app/api/roles/[id]/route.ts +++ b/apps/web/app/api/roles/[id]/route.ts @@ -1,15 +1,10 @@ -import { INextParams, IRole } from '@app/interfaces'; +import { IRole } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { deleteRoleRequest, updateRoleRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request) { const res = new NextResponse(); - - if (!params.id) { - return NextResponse.json({}, { status: 400 }); - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('unauthorized'); @@ -24,19 +19,17 @@ export async function PUT(req: Request, { params }: INextParams) { return $res(response.data); } -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - if (!params.id) { - return NextResponse.json({}, { status: 400 }); - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('unauthorized'); + const { id } = params; + const response = await deleteRoleRequest({ - id: params.id, + id: id as string, bearer_token: access_token, tenantId }); diff --git a/apps/web/app/api/tags/[id]/route.ts b/apps/web/app/api/tags/[id]/route.ts index d448a4716..2b676f239 100644 --- a/apps/web/app/api/tags/[id]/route.ts +++ b/apps/web/app/api/tags/[id]/route.ts @@ -1,23 +1,18 @@ -import { INextParams, ITaskLabelsCreate } from '@app/interfaces'; +import { ITaskLabelsCreate } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { deleteTaskLabelsRequest, editTaskLabelsRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return NextResponse.json({}, { status: 400 }); - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) { - return NextResponse.json({ error: 'unauthorized' }, { status: 401 }); - } + if (!user) return NextResponse.json({ error: 'unauthorized' }, { status: 401 }); + + const { id } = params; const response = await deleteTaskLabelsRequest({ - id: params.id, + id, bearer_token: access_token, tenantId }); @@ -25,23 +20,17 @@ export async function DELETE(req: Request, { params }: INextParams) { return $res(response.data); } -export async function PUT(req: Request, { params }: INextParams) { - const res = new NextResponse(); - - if (!params.id) { - return NextResponse.json({}, { status: 400 }); - } - +export async function PUT(req: Request, { params }: { params: { id: string } }) { const body = (await req.json()) as unknown as ITaskLabelsCreate; - + const res = new NextResponse(); const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) { - return NextResponse.json({ error: 'unauthorized' }, { status: 401 }); - } + if (!user) return NextResponse.json({ error: 'unauthorized' }, { status: 401 }); + + const { id } = params; const response = await editTaskLabelsRequest({ - id: params.id, + id, datas: body, bearer_token: access_token, tenantId diff --git a/apps/web/app/api/task-priorities/[id]/route.ts b/apps/web/app/api/task-priorities/[id]/route.ts index 49b036d4d..94f779cc2 100644 --- a/apps/web/app/api/task-priorities/[id]/route.ts +++ b/apps/web/app/api/task-priorities/[id]/route.ts @@ -1,44 +1,38 @@ -import { INextParams, ITaskPrioritiesCreate } from '@app/interfaces'; +import { ITaskPrioritiesCreate } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { deleteTaskPrioritiesRequest, editTaskPrioritiesRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return NextResponse.json({}, { status: 400 }); - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('Unauthorized'); + const { id } = params; + const datas = (await req.json()) as unknown as ITaskPrioritiesCreate; const response = await editTaskPrioritiesRequest({ - id: params.id, - bearer_token: access_token, + id, datas, + bearer_token: access_token, tenantId }); return $res(response.data); } -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return NextResponse.json({}, { status: 400 }); - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('Unauthorized'); + const { id } = params; + const response = await deleteTaskPrioritiesRequest({ - id: params.id, + id, bearer_token: access_token, tenantId }); diff --git a/apps/web/app/api/task-related-issue-types/[id]/route.ts b/apps/web/app/api/task-related-issue-types/[id]/route.ts index 53af6b037..c8b3245a4 100644 --- a/apps/web/app/api/task-related-issue-types/[id]/route.ts +++ b/apps/web/app/api/task-related-issue-types/[id]/route.ts @@ -1,4 +1,4 @@ -import { INextParams, ITaskRelatedIssueTypeCreate } from '@app/interfaces'; +import { ITaskRelatedIssueTypeCreate } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { deleteTaskRelatedIssueTypeRequest, @@ -6,46 +6,36 @@ import { } from '@app/services/server/requests/task-related-issue-type'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) { - return $res('Unauthorized'); - } + if (!user) return $res('Unauthorized'); + + const { id } = params; const datas = (await req.json()) as unknown as ITaskRelatedIssueTypeCreate; const response = await editTaskRelatedIssueTypeRequest({ - id: params.id, - bearer_token: access_token, + id, datas, + bearer_token: access_token, tenantId }); return $res(response.data); } -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) { - return $res('Unauthorized'); - } + if (!user) return $res('Unauthorized'); + + const { id } = params; const response = await deleteTaskRelatedIssueTypeRequest({ - id: params.id, + id, bearer_token: access_token, tenantId }); diff --git a/apps/web/app/api/task-sizes/[id]/route.ts b/apps/web/app/api/task-sizes/[id]/route.ts index 70e96809d..ab9644f12 100644 --- a/apps/web/app/api/task-sizes/[id]/route.ts +++ b/apps/web/app/api/task-sizes/[id]/route.ts @@ -1,46 +1,38 @@ -import { INextParams, ITaskSizesCreate } from '@app/interfaces'; +import { ITaskSizesCreate } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { deleteTaskSizesRequest, editTaskSizesRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) { - return $res('Unauthorized'); - } + if (!user) return $res('Unauthorized'); + + const { id } = params; const datas = (await req.json()) as unknown as ITaskSizesCreate; const response = await editTaskSizesRequest({ - id: params.id, - bearer_token: access_token, + id, datas, + bearer_token: access_token, tenantId }); return $res(response.data); } -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('Unauthorized'); + const { id } = params; + const response = await deleteTaskSizesRequest({ - id: params.id, + id, bearer_token: access_token, tenantId }); diff --git a/apps/web/app/api/task-statuses/[id]/route.ts b/apps/web/app/api/task-statuses/[id]/route.ts index df5ef1e4f..2d60edab8 100644 --- a/apps/web/app/api/task-statuses/[id]/route.ts +++ b/apps/web/app/api/task-statuses/[id]/route.ts @@ -1,46 +1,38 @@ -import { INextParams, ITaskStatusCreate } from '@app/interfaces'; +import { ITaskStatusCreate } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { deleteTaskStatusRequest, editTaskStatusRequest } from '@app/services/server/requests/taskStatus'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('Unauthorized'); - const datas = (await req.json()) as ITaskStatusCreate; + const { id } = params; + + const datas = (await req.json()) as unknown as ITaskStatusCreate; const response = await editTaskStatusRequest({ - id: params.id, - bearer_token: access_token, + id, datas, + bearer_token: access_token, tenantId }); return $res(response.data); } -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) { - return $res('Unauthorized'); - } + if (!user) return $res('Unauthorized'); + + const { id } = params; const response = await deleteTaskStatusRequest({ - id: params.id, + id, bearer_token: access_token, tenantId }); diff --git a/apps/web/app/api/task-versions/[id]/route.ts b/apps/web/app/api/task-versions/[id]/route.ts index 4620c4010..aad09ccbf 100644 --- a/apps/web/app/api/task-versions/[id]/route.ts +++ b/apps/web/app/api/task-versions/[id]/route.ts @@ -1,46 +1,38 @@ -import { INextParams, ITaskVersionCreate } from '@app/interfaces'; +import { ITaskVersionCreate } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { deleteTaskVersionRequest, editTaskVersionRequest } from '@app/services/server/requests/task-version'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('Unauthorized'); - const datas = (await req.json()) as ITaskVersionCreate; + const { id } = params; + + const datas = (await req.json()) as unknown as ITaskVersionCreate; const response = await editTaskVersionRequest({ - id: params.id, - bearer_token: access_token, + id, datas, + bearer_token: access_token, tenantId }); return $res(response.data); } -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) { - return $res('Unauthorized'); - } + if (!user) return $res('Unauthorized'); + + const { id } = params; const response = await deleteTaskVersionRequest({ - id: params.id, + id, bearer_token: access_token, tenantId }); diff --git a/apps/web/app/api/tasks/[id]/route.ts b/apps/web/app/api/tasks/[id]/route.ts index b2ffebbf4..84f6721fb 100644 --- a/apps/web/app/api/tasks/[id]/route.ts +++ b/apps/web/app/api/tasks/[id]/route.ts @@ -1,21 +1,17 @@ -import { INextParams } from '@app/interfaces'; import { ITeamTask } from '@app/interfaces/ITask'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { getTeamTasksRequest, updateTaskRequest, getTaskByIdRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function GET(req: Request, { params }: INextParams) { +export async function GET(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - if (!params.id) { - return; - } - const { $res, user, tenantId, access_token, organizationId } = await authenticatedGuard(req, res); - if (!user) return $res('Unauthorized'); + const { id: taskId } = params; + const response = await getTaskByIdRequest({ - taskId: params.id, + taskId: taskId as string, tenantId, organizationId, bearer_token: access_token @@ -24,20 +20,16 @@ export async function GET(req: Request, { params }: INextParams) { return $res(response.data); } -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - if (!params.id) { - return; - } - const { $res, user, tenantId, access_token, organizationId, projectId, teamId } = await authenticatedGuard( req, res ); - if (!user) return $res('Unauthorized'); - const body = (await req.json()) as ITeamTask; + const { id: taskId } = params; + const body = (await req.json()) as unknown as ITeamTask; delete body.selectedTeam; delete body.rootEpic; @@ -45,7 +37,7 @@ export async function PUT(req: Request, { params }: INextParams) { await updateTaskRequest( { data: body, - id: params.id + id: taskId as string }, access_token ); diff --git a/apps/web/app/api/tasks/employee/[employeeId]/route.ts b/apps/web/app/api/tasks/employee/[employeeId]/route.ts index dd7f50048..265cec263 100644 --- a/apps/web/app/api/tasks/employee/[employeeId]/route.ts +++ b/apps/web/app/api/tasks/employee/[employeeId]/route.ts @@ -1,56 +1,45 @@ -import { INextParams } from '@app/interfaces'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { deleteEmployeeFromTasksRequest, getEmployeeTasksRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function GET(req: Request, { params }: INextParams) { +export async function GET(req: Request, { params }: { params: { employeeId: string } }) { const res = new NextResponse(); - - if (!params.employeeId) { - return; - } - const { $res, user, tenantId, access_token: bearer_token } = await authenticatedGuard(req, res); - if (!user) return $res('Unauthorized'); const { searchParams } = new URL(req.url); + const { employeeId } = params; const { organizationTeamId } = searchParams as unknown as { organizationTeamId: string; }; const response = await getEmployeeTasksRequest({ - employeeId: params.employeeId, - organizationTeamId, tenantId, + employeeId, + organizationTeamId, bearer_token }); return $res(response.data); } -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request, { params }: { params: { employeeId: string } }) { const res = new NextResponse(); - - if (!params.employeeId) { - return; - } - const { $res, user, tenantId, access_token: bearer_token } = await authenticatedGuard(req, res); - - if (!user) { - return $res('Unauthorized'); - } + if (!user) return $res('Unauthorized'); const { searchParams } = new URL(req.url); - const organizationTeamId = searchParams.get('organizationTeamId') as string; + const { employeeId } = params; + const { organizationTeamId } = searchParams as unknown as { + organizationTeamId: string; + }; const response = await deleteEmployeeFromTasksRequest({ - employeeId: params.employeeId, - organizationTeamId, tenantId, + employeeId, + organizationTeamId, bearer_token }); diff --git a/apps/web/app/api/user/[id]/route.ts b/apps/web/app/api/user/[id]/route.ts index dcdd894d3..93e85f7c9 100644 --- a/apps/web/app/api/user/[id]/route.ts +++ b/apps/web/app/api/user/[id]/route.ts @@ -1,43 +1,30 @@ -import { INextParams } from '@app/interfaces'; import { IUser } from '@app/interfaces/IUserData'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; import { getTaskCreator, updateUserAvatarRequest } from '@app/services/server/requests'; import { deleteUserRequest } from '@app/services/server/requests/user'; import { NextResponse } from 'next/server'; -export async function GET(req: Request, { params }: INextParams) { +export async function GET(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); - if (!params.id) { - return; - } - const { $res, user, access_token } = await authenticatedGuard(req, res); + if (!user) return $res('Unauthorized'); - if (!user) { - return $res('Unauthorized'); - } + const { id: userId } = params; const { data } = await getTaskCreator({ - userId: params.id, + userId: userId as string, bearer_token: access_token }); return $res(data); } -export async function PUT(req: Request, { params }: INextParams) { +export async function PUT(req: Request) { const res = new NextResponse(); - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - - if (!user) { - return $res('Unauthorized'); - } + if (!user) return $res('Unauthorized'); const body = (await req.json()) as unknown as IUser; @@ -53,18 +40,11 @@ export async function PUT(req: Request, { params }: INextParams) { return $res(response.data); } -export async function DELETE(req: Request, { params }: INextParams) { +export async function DELETE(req: Request) { const res = new NextResponse(); - if (!params.id) { - return; - } - const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - - if (!user) { - return $res('Unauthorized'); - } + if (!user) return $res('Unauthorized'); const response = await deleteUserRequest({ id: user.id, diff --git a/apps/web/app/constants.ts b/apps/web/app/constants.ts index 5cffc679d..887f56013 100644 --- a/apps/web/app/constants.ts +++ b/apps/web/app/constants.ts @@ -152,9 +152,6 @@ export const APPLICATION_LANGUAGES = [ 'Russian', 'Spanish' ]; - -export const APPLICATION_DEFAULT_LANGUAGE = 'en'; - export const APPLICATION_LANGUAGES_CODE = [ 'en', 'fr', diff --git a/apps/web/app/hooks/auth/useAuthenticationPasscode.ts b/apps/web/app/hooks/auth/useAuthenticationPasscode.ts index 9afd4c064..a52d11148 100644 --- a/apps/web/app/hooks/auth/useAuthenticationPasscode.ts +++ b/apps/web/app/hooks/auth/useAuthenticationPasscode.ts @@ -29,7 +29,6 @@ export function useAuthenticationPasscode() { const queryEmail = useMemo(() => { const emailQuery = query?.get('email') || ''; - if (typeof localStorage !== 'undefined') { localStorage?.setItem('ever-teams-start-email', emailQuery); } diff --git a/apps/web/app/hooks/auth/useAuthenticationTeam.ts b/apps/web/app/hooks/auth/useAuthenticationTeam.ts index 24d07e9d2..36fa9f926 100644 --- a/apps/web/app/hooks/auth/useAuthenticationTeam.ts +++ b/apps/web/app/hooks/auth/useAuthenticationTeam.ts @@ -31,17 +31,10 @@ const initialValues: IRegisterDataAPI = RECAPTCHA_SITE_KEY email: '', team: '' }; - export function useAuthenticationTeam() { const query = useSearchParams(); const queryEmail = useMemo(() => { - let localEmail: null | string = null; - - if (typeof localStorage !== 'undefined') { - localEmail = localStorage?.getItem('ever-teams-start-email'); - } - - const emailQuery = query?.get('email') || localEmail || ''; + const emailQuery = query?.get('email') || localStorage?.getItem('ever-teams-start-email') || ''; return emailQuery; }, [query]); initialValues.email = queryEmail; diff --git a/apps/web/app/hooks/features/useTimeSlot.ts b/apps/web/app/hooks/features/useTimeSlot.ts index d33770836..e6cbb7c38 100644 --- a/apps/web/app/hooks/features/useTimeSlot.ts +++ b/apps/web/app/hooks/features/useTimeSlot.ts @@ -31,8 +31,9 @@ export function useTimeSlots(hasFilter?: boolean) { todayEnd, todayStart }).then((response) => { - if (response.data && Array.isArray(response.data)) { - setTimeSlots(response.data[0]?.timeSlots || []); + if (response.data) { + // @ts-expect-error + setTimeSlots(response.data[0].timeSlots); } }); } else setTimeSlots([]); diff --git a/apps/web/app/services/client/api/task-status.ts b/apps/web/app/services/client/api/task-status.ts index cf4343e5e..e5f3eecb5 100644 --- a/apps/web/app/services/client/api/task-status.ts +++ b/apps/web/app/services/client/api/task-status.ts @@ -1,6 +1,5 @@ import { DeleteResponse, ITaskStatusCreate, ITaskStatusItemList, PaginationResponse } from '@app/interfaces'; import { deleteApi, get, post, put } from '../axios'; -import qs from 'qs'; export function createTaskStatusAPI(data: ITaskStatusCreate, tenantId?: string) { return post('/task-statuses', data, { @@ -19,13 +18,7 @@ export function deleteTaskStatusAPI(id: string) { } export async function getTaskStatusList(tenantId: string, organizationId: string, organizationTeamId: string | null) { - const query = qs.stringify({ - tenantId, - organizationId, - organizationTeamId - }); - - const endpoint = `/task-statuses?${query}`; + const endpoint = `/task-statuses?tenantId=${tenantId}&organizationId=${organizationId}&organizationTeamId=${organizationTeamId}`; return get>(endpoint, { tenantId }); } diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index cb062985c..4b939b510 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -1,5 +1,4 @@ import { - APPLICATION_DEFAULT_LANGUAGE, DEFAULT_APP_PATH, DEFAULT_MAIN_PATH, PROTECTED_APP_URL_PATHS, @@ -31,7 +30,7 @@ export const config = { export async function middleware(request: NextRequest) { const nextIntlMiddleware = createMiddleware({ - defaultLocale: APPLICATION_DEFAULT_LANGUAGE, + defaultLocale: 'en', locales: ['en', 'de', 'ar', 'bg', 'zh', 'nl', 'de', 'he', 'it', 'pl', 'pt', 'ru', 'es', 'fr'], // pathnames, localePrefix: 'as-needed' diff --git a/apps/web/next.config.js b/apps/web/next.config.js index a82eec3c3..547e6654c 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -8,8 +8,6 @@ const isProduction = process.env.NODE_ENV === 'production'; const isSentryEnabled = isProduction && process.env.SENTRY_DSN; -const BUILD_OUTPUT_MODE = process.env.NEXT_BUILD_OUTPUT_TYPE; - const sentryConfig = isSentryEnabled && { sentry: { // For all available options, see: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ @@ -33,7 +31,7 @@ const sentryConfig = isSentryEnabled && { // eslint-disable-next-line @typescript-eslint/no-var-requires /** @type {import('next').NextConfig} */ const nextConfig = { - output: ['standalone', 'export'].includes(BUILD_OUTPUT_MODE) ? BUILD_OUTPUT_MODE : undefined, + output: process.env.NEXT_BUILD_OUTPUT_TYPE === 'standalone' ? 'standalone' : undefined, reactStrictMode: false, swcMinify: true, webpack: (config, { isServer }) => {