From eb7e3934328bac00e48343a09352c072f3877a18 Mon Sep 17 00:00:00 2001 From: Badal Khatri Date: Tue, 26 Dec 2023 12:40:04 +0530 Subject: [PATCH 01/24] fix: API Call --- .../features/usePublicOrganizationTeams.ts | 6 +- .../app/hooks/features/useTeamInvitations.ts | 10 +- apps/web/app/hooks/features/useTeamTasks.ts | 8 +- apps/web/pages/_app.tsx | 124 ------------------ apps/web/pages/_document.tsx | 13 -- 5 files changed, 13 insertions(+), 148 deletions(-) delete mode 100644 apps/web/pages/_app.tsx delete mode 100644 apps/web/pages/_document.tsx diff --git a/apps/web/app/hooks/features/usePublicOrganizationTeams.ts b/apps/web/app/hooks/features/usePublicOrganizationTeams.ts index a6a37b019..787fb6af7 100644 --- a/apps/web/app/hooks/features/usePublicOrganizationTeams.ts +++ b/apps/web/app/hooks/features/usePublicOrganizationTeams.ts @@ -17,7 +17,7 @@ import { useTaskStatus } from './useTaskStatus'; import { useTeamTasks } from './useTeamTasks'; export function usePublicOrganizationTeams() { - const { loading, queryCall } = useQuery(getPublicOrganizationTeamsAPI); + const { loading, queryCall, loadingRef } = useQuery(getPublicOrganizationTeamsAPI); const { loading: loadingMiscData, queryCall: queryCallMiscData } = useQuery(getPublicOrganizationTeamsMiscDataAPI); const { activeTeam, teams, setTeams } = useOrganizationTeams(); const { setAllTasks } = useTeamTasks(); @@ -29,6 +29,10 @@ export function usePublicOrganizationTeams() { const loadPublicTeamData = useCallback( (profileLink: string, teamId: string) => { + if (loadingRef.current) { + return; + } + return queryCall(profileLink, teamId).then((res) => { if (res.data?.data?.status === 404) { setTeams([]); diff --git a/apps/web/app/hooks/features/useTeamInvitations.ts b/apps/web/app/hooks/features/useTeamInvitations.ts index bb0134889..6e078b71b 100644 --- a/apps/web/app/hooks/features/useTeamInvitations.ts +++ b/apps/web/app/hooks/features/useTeamInvitations.ts @@ -43,7 +43,11 @@ export function useTeamInvitations() { const { queryCall: resendInviteQueryCall, loading: resendInviteLoading } = useQuery(resendTeamInvitationsAPI); - const { queryCall: myInvitationsQueryCall, loading: myInvitationsLoading } = useQuery(getMyInvitationsAPI); + const { + queryCall: myInvitationsQueryCall, + loading: myInvitationsLoading, + loadingRef: myInvitationsLoadingRef + } = useQuery(getMyInvitationsAPI); const { queryCall: acceptRejectMyInvitationsQueryCall, loading: acceptRejectMyInvitationsLoading } = useQuery(acceptRejectMyInvitationsAPI); @@ -99,7 +103,7 @@ export function useTeamInvitations() { ); const myInvitations = useCallback(() => { - if (!user?.tenantId) { + if (myInvitationsLoadingRef.current || !user?.tenantId) { return; } @@ -107,7 +111,7 @@ export function useTeamInvitations() { setMyInvitationsList(res.data.items); return res.data; }); - }, [myInvitationsQueryCall, setMyInvitationsList, user]); + }, [myInvitationsQueryCall, setMyInvitationsList, user, myInvitationsLoadingRef]); const removeMyInvitation = useCallback( (id: string) => { setMyInvitationsList(myInvitationsList.filter((invitation) => invitation.id !== id)); diff --git a/apps/web/app/hooks/features/useTeamTasks.ts b/apps/web/app/hooks/features/useTeamTasks.ts index e1116ed44..ca3d5a180 100644 --- a/apps/web/app/hooks/features/useTeamTasks.ts +++ b/apps/web/app/hooks/features/useTeamTasks.ts @@ -108,13 +108,7 @@ export function useTeamTasks() { const loadTeamTasksData = useCallback( (deepCheck?: boolean) => { - if (loadingRef.current) { - return new Promise((response) => { - response(true); - }); - } - - if (!user || !activeTeamRef.current?.id) { + if (loadingRef.current || !user || !activeTeamRef.current?.id) { return new Promise((response) => { response(true); }); diff --git a/apps/web/pages/_app.tsx b/apps/web/pages/_app.tsx deleted file mode 100644 index 790cbd7c6..000000000 --- a/apps/web/pages/_app.tsx +++ /dev/null @@ -1,124 +0,0 @@ -/* eslint-disable no-mixed-spaces-and-tabs */ -import { getNextPublicEnv, loadNextPublicEnvs, setNextPublicEnv } from '@app/env'; -import { GA_MEASUREMENT_ID, jitsuConfiguration } from '@app/constants'; -import { JitsuProvider } from '@jitsu/jitsu-react'; -import { Analytics } from '@vercel/analytics/react'; -import { AppState } from 'lib/app/init-state'; -import type { JitsuOptions } from '@jitsu/jitsu-react/dist/useJitsu'; -import ChatwootWidget from 'lib/features/integrations/chatwoot'; -import { NextPage, NextPageContext } from 'next'; -import { ThemeProvider } from 'next-themes'; -import type { AppProps } from 'next/app'; -import Head from 'next/head'; -import Script from 'next/script'; -import { I18nextProvider } from 'react-i18next'; -import { SkeletonTheme } from 'react-loading-skeleton'; -import { RecoilRoot } from 'recoil'; -import { JitsuAnalytics } from '../lib/components/services/jitsu-analytics'; -import i18n from '../ni18n.config'; -import 'react-loading-skeleton/dist/skeleton.css'; -import '../styles/globals.css'; - -type MyAppProps = { - jitsuConf?: JitsuOptions; - jitsuHost?: string; - envs: Record; - user?: any; -}; - -const MyApp = ({ Component, pageProps }: AppProps) => { - setNextPublicEnv(pageProps.envs); - - const jitsuConf = pageProps?.jitsuConf; - console.log(`Jitsu Configuration: ${JSON.stringify(jitsuConf)}`); - - const isJitsuEnvsPresent: boolean = jitsuConf?.host !== '' && jitsuConf?.writeKey !== ''; - console.log(`Jitsu Enabled: ${isJitsuEnvsPresent}`); - - return ( - <> - {GA_MEASUREMENT_ID.value && ( - <> - - - )} - - - - - - - - - - - - - - - - - - - - - - - ); -}; - -MyApp.getInitialProps = async ({ Component, ctx }: { Component: NextPage; ctx: NextPageContext }) => { - // Recover environment variables - const jitsuHost = getNextPublicEnv('NEXT_PUBLIC_JITSU_BROWSER_URL').value; - const jitsuWriteKey = getNextPublicEnv('NEXT_PUBLIC_JITSU_BROWSER_WRITE_KEY').value; - - const jitsuConf = jitsuConfiguration(); - - console.log(`Jitsu Host: ${jitsuHost}`); - console.log(`Jitsu Write Key: ${jitsuWriteKey}`); - - console.log(`Jitsu Configuration: ${JSON.stringify(jitsuConf)}`); - - // Call the static method getInitialProps - // of the page component if it exists - let pageProps = {}; - - if (Component.getInitialProps) { - pageProps = await Component.getInitialProps(ctx); - } - - return { - pageProps: { - ...pageProps, - jitsuConf, - jitsuHost, - jitsuWriteKey, - envs: loadNextPublicEnvs() - } as MyAppProps - }; -}; - -export default MyApp; diff --git a/apps/web/pages/_document.tsx b/apps/web/pages/_document.tsx deleted file mode 100644 index 6256c119f..000000000 --- a/apps/web/pages/_document.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { Html, Head, Main, NextScript } from 'next/document'; - -export default function Document() { - return ( - - - -
- - - - ); -} From 020bf71ecc74c7bc69bdc1edea709842e3d9e20e Mon Sep 17 00:00:00 2001 From: Badal Khatri Date: Tue, 26 Dec 2023 14:45:24 +0530 Subject: [PATCH 02/24] fix: Translation Issue --- apps/web/messages/ar.json | 8 +++++++- apps/web/messages/bg.json | 9 +++++++-- apps/web/messages/de.json | 8 +++++++- apps/web/messages/en.json | 8 +++++++- apps/web/messages/es.json | 8 +++++++- apps/web/messages/fr.json | 8 +++++++- apps/web/messages/he.json | 8 +++++++- apps/web/messages/it.json | 8 +++++++- apps/web/messages/nl.json | 8 +++++++- apps/web/messages/pl.json | 8 +++++++- apps/web/messages/pt.json | 8 +++++++- apps/web/messages/ru.json | 8 +++++++- apps/web/messages/zh.json | 8 +++++++- 13 files changed, 91 insertions(+), 14 deletions(-) diff --git a/apps/web/messages/ar.json b/apps/web/messages/ar.json index f2ae639e6..68f22bb5e 100644 --- a/apps/web/messages/ar.json +++ b/apps/web/messages/ar.json @@ -450,6 +450,10 @@ "ASSIGN_NEW_TASK": "تعيين مهمة جديدة", "ASSIGNED_BY": "تم التعيين بواسطة", "NO_ONE_FOR_TASK": "لم يتم تعيين أحد لهذه المهمة", + "WORKED_TODAY_ON_TASK_TOOLTIP": "عمل اليوم على هذه المهمة لمدة", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "عمل على هذه المهمة لمدة إجمالية", + "WORKED_TODAY_ON_ALL_TOOLTIP": "عمل اليوم على الكل", + "TASKS_FOR_TOOLTIP": "المهام ل", "taskLabel": { "WORK_LABEL": "عمل", "TASK_ASSIGNED": "معينة", @@ -475,7 +479,9 @@ "TITLE": "إجمالي العمل", "DESCRIPTION": "اليوم", "LABEL": "إجمالي العمل اليوم" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "كم ساعة عمل الموظف اليوم والإجمالي في المهمة", + "WORKED_ON_TASK_HEADER_TOOLTIP": "كم ساعة عمل الموظف اليوم في جميع المهام للفريق المحدد" }, "CONFIRM_CLOSE_TASK": "يرجى تأكيد رغبتك في إغلاق المهمة" }, diff --git a/apps/web/messages/bg.json b/apps/web/messages/bg.json index 343763c9e..282e7cf4e 100644 --- a/apps/web/messages/bg.json +++ b/apps/web/messages/bg.json @@ -454,7 +454,10 @@ "ASSIGN_NEW_TASK": "Възлагане на нова задача", "ASSIGNED_BY": "Възложено от", "NO_ONE_FOR_TASK": "Няма отговорник за тази задача", - + "WORKED_TODAY_ON_TASK_TOOLTIP": "работено днес по тази задача за", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "работено по тази задача общо за", + "WORKED_TODAY_ON_ALL_TOOLTIP": "работено днес по всички", + "TASKS_FOR_TOOLTIP": "задачи за", "taskLabel": { "WORK_LABEL": "Работено", "TASK_ASSIGNED": "Възложено", @@ -480,7 +483,9 @@ "TITLE": "Общо работено", "DESCRIPTION": "Днес", "LABEL": "Общо работено днес" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Колко часа работил служителят общо и днес по задача", + "WORKED_ON_TASK_HEADER_TOOLTIP": "Колко часа е работил служителят днес по всички задачи за избрания екип" }, "CONFIRM_CLOSE_TASK": "Моля, потвърдете ако искате да затворите задачата" }, diff --git a/apps/web/messages/de.json b/apps/web/messages/de.json index ab8b0e4d0..94da8e416 100644 --- a/apps/web/messages/de.json +++ b/apps/web/messages/de.json @@ -445,6 +445,10 @@ "ASSIGN_NEW_TASK": "Neue Aufgabe zuweisen", "ASSIGNED_BY": "Zugewiesen von", "NO_ONE_FOR_TASK": "Niemand dieser Aufgabe zugewiesen", + "WORKED_TODAY_ON_TASK_TOOLTIP": "heute an dieser Aufgabe gearbeitet für", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "insgesamt an dieser Aufgabe gearbeitet für", + "WORKED_TODAY_ON_ALL_TOOLTIP": "heute an allem gearbeitet für", + "TASKS_FOR_TOOLTIP": "Aufgaben für", "taskLabel": { "WORK_LABEL": "Gearbeitet", "TASK_ASSIGNED": "Zugewiesen", @@ -470,7 +474,9 @@ "TITLE": "Insgesamt gearbeitet", "DESCRIPTION": "Heute", "LABEL": "Heute insgesamt gearbeitet" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Wie viele Stunden hat der Mitarbeiter heute und insgesamt an der Aufgabe gearbeitet", + "WORKED_ON_TASK_HEADER_TOOLTIP": "Wie viele Stunden hat der Mitarbeiter heute an allen Aufgaben für das ausgewählte Team gearbeitet" }, "CONFIRM_CLOSE_TASK": "Bitte bestätigen Sie, ob Sie die Aufgabe schließen möchten" }, diff --git a/apps/web/messages/en.json b/apps/web/messages/en.json index b3f6f9bc9..d23acba4b 100644 --- a/apps/web/messages/en.json +++ b/apps/web/messages/en.json @@ -447,6 +447,10 @@ "ASSIGN_NEW_TASK": "Assign new task", "ASSIGNED_BY": "Assigned By", "NO_ONE_FOR_TASK": "No One Assigned to this Task", + "WORKED_TODAY_ON_TASK_TOOLTIP": "worked today on this task for", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "worked on this task for a total of", + "WORKED_TODAY_ON_ALL_TOOLTIP": "worked today on all", + "TASKS_FOR_TOOLTIP": "tasks for", "taskLabel": { "WORK_LABEL": "Worked", "TASK_ASSIGNED": "Assigned", @@ -472,7 +476,9 @@ "TITLE": "Total Worked", "DESCRIPTION": "Today", "LABEL": "Total worked Today" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "How many hours employee worked for total and today on task", + "WORKED_ON_TASK_HEADER_TOOLTIP": "How many hours employee worked today on all tasks for selected Team" }, "CONFIRM_CLOSE_TASK": "Please confirm if you want to close the task" }, diff --git a/apps/web/messages/es.json b/apps/web/messages/es.json index cbd5628d7..1eda971b4 100644 --- a/apps/web/messages/es.json +++ b/apps/web/messages/es.json @@ -429,6 +429,10 @@ "ASSIGN_NEW_TASK": "Asignar nueva tarea", "ASSIGNED_BY": "Asignado por", "NO_ONE_FOR_TASK": "Nadie asignado a esta tarea", + "WORKED_TODAY_ON_TASK_TOOLTIP": "trabajó hoy en esta tarea durante", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "trabajó en esta tarea durante un total de", + "WORKED_TODAY_ON_ALL_TOOLTIP": "trabajó hoy en todas", + "TASKS_FOR_TOOLTIP": "tareas para", "taskLabel": { "WORK_LABEL": "Trabajado", "TASK_ASSIGNED": "Asignado", @@ -454,7 +458,9 @@ "TITLE": "Total trabajado", "DESCRIPTION": "Hoy", "LABEL": "Total trabajado hoy" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Cuántas horas trabajó el empleado en total y hoy en la tarea", + "WORKED_ON_TASK_HEADER_TOOLTIP": "Cuántas horas trabajó el empleado hoy en todas las tareas para el equipo seleccionado" }, "CONFIRM_CLOSE_TASK": "Por favor, confirma si deseas cerrar la tarea" }, diff --git a/apps/web/messages/fr.json b/apps/web/messages/fr.json index c74048e64..efa8438c1 100644 --- a/apps/web/messages/fr.json +++ b/apps/web/messages/fr.json @@ -440,6 +440,10 @@ "ASSIGN_NEW_TASK": "Assigner une nouvelle tâche", "ASSIGNED_BY": "Assigné par", "NO_ONE_FOR_TASK": "Personne n'est assigné à cette tâche", + "WORKED_TODAY_ON_TASK_TOOLTIP": "a travaillé aujourd'hui sur cette tâche pendant", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "a travaillé sur cette tâche pour un total de", + "WORKED_TODAY_ON_ALL_TOOLTIP": "a travaillé aujourd'hui sur toutes", + "TASKS_FOR_TOOLTIP": "tâches pour", "taskLabel": { "WORK_LABEL": "Travaillé", "TASK_ASSIGNED": "Assigné", @@ -465,7 +469,9 @@ "TITLE": "Total travaillé", "DESCRIPTION": "Aujourd'hui", "LABEL": "Total travaillé aujourd'hui" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Combien d'heures l'employé a-t-il travaillé au total et aujourd'hui sur la tâche", + "WORKED_ON_TASK_HEADER_TOOLTIP": "Combien d'heures l'employé a-t-il travaillé aujourd'hui sur toutes les tâches pour l'équipe sélectionnée" }, "CONFIRM_CLOSE_TASK": "Veuillez confirmer si vous voulez fermer la tâche" }, diff --git a/apps/web/messages/he.json b/apps/web/messages/he.json index a9b84058d..6e69ad550 100644 --- a/apps/web/messages/he.json +++ b/apps/web/messages/he.json @@ -440,6 +440,10 @@ "ASSIGN_NEW_TASK": "הקצה משימה חדשה", "ASSIGNED_BY": "הוקצה על ידי", "NO_ONE_FOR_TASK": "אף אחד לא הוקצה למשימה זו", + "WORKED_TODAY_ON_TASK_TOOLTIP": "עבד היום על משימה זו למשך", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "עבד על משימה זו לסך הכל למשך", + "WORKED_TODAY_ON_ALL_TOOLTIP": "עבד היום על כל", + "TASKS_FOR_TOOLTIP": "משימות עבור", "taskLabel": { "WORK_LABEL": "עבד", "TASK_ASSIGNED": "הוקצה", @@ -465,7 +469,9 @@ "TITLE": "סך עבודה", "DESCRIPTION": "היום", "LABEL": "סך עבודה היום" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "כמה שעות עבד העובד בסך הכול והיום על המשימה", + "WORKED_ON_TASK_HEADER_TOOLTIP": "כמה שעות עבד העובד היום בכל המשימות לצוות שנבחר" }, "CONFIRM_CLOSE_TASK": "אנא אשר אם ברצונך לסגור את המשימה" }, diff --git a/apps/web/messages/it.json b/apps/web/messages/it.json index 5e119a055..0ff73675c 100644 --- a/apps/web/messages/it.json +++ b/apps/web/messages/it.json @@ -443,6 +443,10 @@ "ASSIGN_NEW_TASK": "Assign new task", "ASSIGNED_BY": "Assigned By", "NO_ONE_FOR_TASK": "No One Assigned to this Task", + "WORKED_TODAY_ON_TASK_TOOLTIP": "lavorato oggi su questo compito per", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "lavorato su questo compito per un totale di", + "WORKED_TODAY_ON_ALL_TOOLTIP": "lavorato oggi su tutto per", + "TASKS_FOR_TOOLTIP": "compiti per", "taskLabel": { "WORK_LABEL": "Worked", "TASK_ASSIGNED": "Assigned", @@ -468,7 +472,9 @@ "TITLE": "Total Worked", "DESCRIPTION": "Today", "LABEL": "Total worked Today" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Quante ore ha lavorato l'impiegato in totale e oggi sul compito", + "WORKED_ON_TASK_HEADER_TOOLTIP": "Quante ore ha lavorato l'impiegato oggi su tutte le attività per il team selezionato" }, "CONFIRM_CLOSE_TASK": "Please confirm if you want to close the task" }, diff --git a/apps/web/messages/nl.json b/apps/web/messages/nl.json index 92c2a52e6..3af97dc68 100644 --- a/apps/web/messages/nl.json +++ b/apps/web/messages/nl.json @@ -443,6 +443,10 @@ "ASSIGN_NEW_TASK": "Nieuwe taak toewijzen", "ASSIGNED_BY": "Toegewezen door", "NO_ONE_FOR_TASK": "Niemand toegewezen aan deze taak", + "WORKED_TODAY_ON_TASK_TOOLTIP": "vandaag gewerkt aan deze taak voor", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "in totaal gewerkt aan deze taak voor", + "WORKED_TODAY_ON_ALL_TOOLTIP": "vandaag gewerkt aan alles voor", + "TASKS_FOR_TOOLTIP": "taken voor", "taskLabel": { "WORK_LABEL": "Gewerkt", "TASK_ASSIGNED": "Toegewezen", @@ -468,7 +472,9 @@ "TITLE": "Totaal gewerkt", "DESCRIPTION": "Vandaag", "LABEL": "Totaal gewerkt vandaag" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Hoeveel uur heeft de werknemer in totaal en vandaag aan de taak gewerkt", + "WORKED_ON_TASK_HEADER_TOOLTIP": "Hoeveel uur heeft de werknemer vandaag gewerkt aan alle taken voor het geselecteerde team" }, "CONFIRM_CLOSE_TASK": "Bevestig als u de taak wilt sluiten" }, diff --git a/apps/web/messages/pl.json b/apps/web/messages/pl.json index 7f3950ed1..f11cb19c0 100644 --- a/apps/web/messages/pl.json +++ b/apps/web/messages/pl.json @@ -443,6 +443,10 @@ "ASSIGN_NEW_TASK": "Assign new task", "ASSIGNED_BY": "Assigned By", "NO_ONE_FOR_TASK": "No One Assigned to this Task", + "WORKED_TODAY_ON_TASK_TOOLTIP": "pracował dziś nad tym zadaniem przez", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "pracował nad tym zadaniem przez łącznie", + "WORKED_TODAY_ON_ALL_TOOLTIP": "pracował dziś nad wszystkimi", + "TASKS_FOR_TOOLTIP": "zadania dla", "taskLabel": { "WORK_LABEL": "Worked", "TASK_ASSIGNED": "Assigned", @@ -468,7 +472,9 @@ "TITLE": "Total Worked", "DESCRIPTION": "Today", "LABEL": "Total worked Today" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Ile godzin pracował pracownik ogółem i dzisiaj nad zadaniem", + "WORKED_ON_TASK_HEADER_TOOLTIP": "Ile godzin pracował pracownik dzisiaj nad wszystkimi zadaniami dla wybranego zespołu" }, "CONFIRM_CLOSE_TASK": "Please confirm if you want to close the task" }, diff --git a/apps/web/messages/pt.json b/apps/web/messages/pt.json index 891d588de..6b19d03f3 100644 --- a/apps/web/messages/pt.json +++ b/apps/web/messages/pt.json @@ -443,6 +443,10 @@ "ASSIGN_NEW_TASK": "Assign new task", "ASSIGNED_BY": "Assigned By", "NO_ONE_FOR_TASK": "No One Assigned to this Task", + "WORKED_TODAY_ON_TASK_TOOLTIP": "trabalhou hoje nesta tarefa por", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "trabalhou nesta tarefa por um total de", + "WORKED_TODAY_ON_ALL_TOOLTIP": "trabalhou hoje em todas", + "TASKS_FOR_TOOLTIP": "tarefas para", "taskLabel": { "WORK_LABEL": "Worked", "TASK_ASSIGNED": "Assigned", @@ -468,7 +472,9 @@ "TITLE": "Total Worked", "DESCRIPTION": "Today", "LABEL": "Total worked Today" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Quantas horas o funcionário trabalhou no total e hoje na tarefa", + "WORKED_ON_TASK_HEADER_TOOLTIP": "Quantas horas o funcionário trabalhou hoje em todas as tarefas para a equipe selecionada" }, "CONFIRM_CLOSE_TASK": "Please confirm if you want to close the task" }, diff --git a/apps/web/messages/ru.json b/apps/web/messages/ru.json index cbd6ec50b..633a5692a 100644 --- a/apps/web/messages/ru.json +++ b/apps/web/messages/ru.json @@ -443,6 +443,10 @@ "ASSIGN_NEW_TASK": "Assign new task", "ASSIGNED_BY": "Assigned By", "NO_ONE_FOR_TASK": "No One Assigned to this Task", + "WORKED_TODAY_ON_TASK_TOOLTIP": "сегодня поработал по этой задаче", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "поработал на этой задаче в общей сложности", + "WORKED_TODAY_ON_ALL_TOOLTIP": "сегодня поработал над всеми", + "TASKS_FOR_TOOLTIP": "задачами для", "taskLabel": { "WORK_LABEL": "Worked", "TASK_ASSIGNED": "Assigned", @@ -468,7 +472,9 @@ "TITLE": "Total Worked", "DESCRIPTION": "Today", "LABEL": "Total worked Today" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "Сколько часов сотрудник поработал всего и сегодня по задаче", + "WORKED_ON_TASK_HEADER_TOOLTIP": "Сколько часов сотрудник поработал сегодня по всем задачам для выбранной команды" }, "CONFIRM_CLOSE_TASK": "Please confirm if you want to close the task" }, diff --git a/apps/web/messages/zh.json b/apps/web/messages/zh.json index 85d6edf28..bffaf1ad4 100644 --- a/apps/web/messages/zh.json +++ b/apps/web/messages/zh.json @@ -420,6 +420,10 @@ "ASSIGN_NEW_TASK": "分配新任务", "ASSIGNED_BY": "分配者", "NO_ONE_FOR_TASK": "此任务未分配", + "WORKED_TODAY_ON_TASK_TOOLTIP": "今天在这个任务上工作了", + "WORKED_TOTAL_ON_TASK_TOOLTIP": "总共在这个任务上工作了", + "WORKED_TODAY_ON_ALL_TOOLTIP": "今天在所有任务上工作了", + "TASKS_FOR_TOOLTIP": "的任务", "taskLabel": { "WORK_LABEL": "已处理", "TASK_ASSIGNED": "已分配", @@ -445,7 +449,9 @@ "TITLE": "总共处理", "DESCRIPTION": "今天", "LABEL": "今天总共处理" - } + }, + "TOTAL_WORKED_TODAY_HEADER_TOOLTIP": "员工今天和总共在任务上工作了多少小时", + "WORKED_ON_TASK_HEADER_TOOLTIP": "员工今天在所选团队的所有任务上工作了多少小时" }, "CONFIRM_CLOSE_TASK": "请确认您是否要关闭此任务" }, From 0c71d783481241c4e81676c73099324da0e1c751 Mon Sep 17 00:00:00 2001 From: maceteligolden Date: Tue, 26 Dec 2023 14:19:35 +0100 Subject: [PATCH 03/24] update:addlink to team name on landing page --- apps/web/app/[locale]/page.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/web/app/[locale]/page.tsx b/apps/web/app/[locale]/page.tsx index 814b3ec37..fa8e42978 100644 --- a/apps/web/app/[locale]/page.tsx +++ b/apps/web/app/[locale]/page.tsx @@ -48,9 +48,10 @@ type MyAppProps = { function MainPage({ pageProps }: AppProps) { const t = useTranslations(); + const { isTeamMember, isTrackingEnabled, activeTeam } = useOrganizationTeams(); - const breadcrumb = [{title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/'}, activeTeam?.name || '']; + const breadcrumb = [{title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/'}, { title: activeTeam?.name || '', href:'/'}]; const [view, setView] = useState(IssuesView.CARDS); const { online } = useNetworkState(); From 81010c9ce948b8cffa4000073a2583d8e4812263 Mon Sep 17 00:00:00 2001 From: maceteligolden Date: Tue, 26 Dec 2023 14:29:22 +0100 Subject: [PATCH 04/24] update:kanban breadcrumb links --- apps/web/app/[locale]/kanban/page.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/web/app/[locale]/kanban/page.tsx b/apps/web/app/[locale]/kanban/page.tsx index 0d840ae23..acb6aa900 100644 --- a/apps/web/app/[locale]/kanban/page.tsx +++ b/apps/web/app/[locale]/kanban/page.tsx @@ -19,10 +19,11 @@ const Kanban = () => { const { data } = useKanban(); const { activeTeam } = useOrganizationTeams(); const t = useTranslations(); + const [activeTab, setActiveTab] = useState(KanbanTabs.TODAY); - const breadcrumbPath = [{title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/'}, activeTeam?.name || '', 'Kanban Board']; + const breadcrumbPath = [{title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/'}, {title: activeTeam?.name || '', href:'/'}, {title:'Kanban Board', href: '/kanban'}]; const imageRadius = 20; const numberOfImagesDisplayed = 4; From 756a754af69911fdca2602521740a4a1d2e7d18d Mon Sep 17 00:00:00 2001 From: maceteligolden Date: Tue, 26 Dec 2023 14:35:36 +0100 Subject: [PATCH 05/24] update:add locale to kanban --- apps/web/app/[locale]/kanban/page.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/web/app/[locale]/kanban/page.tsx b/apps/web/app/[locale]/kanban/page.tsx index acb6aa900..69c86d728 100644 --- a/apps/web/app/[locale]/kanban/page.tsx +++ b/apps/web/app/[locale]/kanban/page.tsx @@ -19,11 +19,12 @@ const Kanban = () => { const { data } = useKanban(); const { activeTeam } = useOrganizationTeams(); const t = useTranslations(); + const { locale } = useParams<{locale: string}>(); const [activeTab, setActiveTab] = useState(KanbanTabs.TODAY); - const breadcrumbPath = [{title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/'}, {title: activeTeam?.name || '', href:'/'}, {title:'Kanban Board', href: '/kanban'}]; + const breadcrumbPath = [{title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/'}, {title: activeTeam?.name || '', href:'/'}, {title:'Kanban Board', href: `/${locale}/kanban`}]; const imageRadius = 20; const numberOfImagesDisplayed = 4; From cc20060090e9ca96c7ce5fecbabca2ebbd837827 Mon Sep 17 00:00:00 2001 From: maceteligolden Date: Tue, 26 Dec 2023 14:41:27 +0100 Subject: [PATCH 06/24] update:get curernt locale --- apps/web/app/[locale]/kanban/page.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/web/app/[locale]/kanban/page.tsx b/apps/web/app/[locale]/kanban/page.tsx index 69c86d728..134caf108 100644 --- a/apps/web/app/[locale]/kanban/page.tsx +++ b/apps/web/app/[locale]/kanban/page.tsx @@ -14,17 +14,19 @@ import { MainLayout } from 'lib/layout'; import Image from 'next/image'; import { useState } from 'react'; import { useTranslations } from 'next-intl'; +import { useParams } from 'next/navigation'; const Kanban = () => { const { data } = useKanban(); const { activeTeam } = useOrganizationTeams(); const t = useTranslations(); - const { locale } = useParams<{locale: string}>(); + const params = useParams<{locale: string}>(); + const currentLocale = params ? params.locale : null; const [activeTab, setActiveTab] = useState(KanbanTabs.TODAY); - const breadcrumbPath = [{title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/'}, {title: activeTeam?.name || '', href:'/'}, {title:'Kanban Board', href: `/${locale}/kanban`}]; + const breadcrumbPath = [{title: JSON.parse(t('pages.home.BREADCRUMB')), href: '/'}, {title: activeTeam?.name || '', href:'/'}, {title:'Kanban Board', href: `/${currentLocale}/kanban`}]; const imageRadius = 20; const numberOfImagesDisplayed = 4; From 5d6e9372cc60dbccf2081c78dc5a2e44bff5e415 Mon Sep 17 00:00:00 2001 From: Badal Khatri Date: Wed, 27 Dec 2023 08:28:57 +0530 Subject: [PATCH 07/24] fix: Build Issue --- .../team/[teamId]/[profileLink]/page.tsx | 2 +- .../features/usePublicOrganizationTeams.ts | 4 +++- apps/web/app/not-found.tsx | 15 --------------- apps/web/pages/404.tsx | 19 ------------------- apps/web/pages/main-v1.tsx | 15 --------------- 5 files changed, 4 insertions(+), 51 deletions(-) delete mode 100644 apps/web/app/not-found.tsx delete mode 100644 apps/web/pages/404.tsx delete mode 100644 apps/web/pages/main-v1.tsx diff --git a/apps/web/app/[locale]/team/[teamId]/[profileLink]/page.tsx b/apps/web/app/[locale]/team/[teamId]/[profileLink]/page.tsx index 90cd5a9e2..9092f83a6 100644 --- a/apps/web/app/[locale]/team/[teamId]/[profileLink]/page.tsx +++ b/apps/web/app/[locale]/team/[teamId]/[profileLink]/page.tsx @@ -30,7 +30,7 @@ const Team = () => { const loadData = useCallback(() => { if (params?.teamId && params?.profileLink) { - loadPublicTeamData(params?.profileLink as string, params?.teamId as string).then((res) => { + loadPublicTeamData(params?.profileLink as string, params?.teamId as string).then((res: any) => { if (res?.data?.data?.status === 404) { notFound(); } diff --git a/apps/web/app/hooks/features/usePublicOrganizationTeams.ts b/apps/web/app/hooks/features/usePublicOrganizationTeams.ts index 787fb6af7..468f14832 100644 --- a/apps/web/app/hooks/features/usePublicOrganizationTeams.ts +++ b/apps/web/app/hooks/features/usePublicOrganizationTeams.ts @@ -30,7 +30,9 @@ export function usePublicOrganizationTeams() { const loadPublicTeamData = useCallback( (profileLink: string, teamId: string) => { if (loadingRef.current) { - return; + return new Promise((response) => { + response({}); + }); } return queryCall(profileLink, teamId).then((res) => { diff --git a/apps/web/app/not-found.tsx b/apps/web/app/not-found.tsx deleted file mode 100644 index e903081e0..000000000 --- a/apps/web/app/not-found.tsx +++ /dev/null @@ -1,15 +0,0 @@ -'use client'; -import NotFound from '@components/pages/404'; -import { AuthLayout } from 'lib/layout'; - -const NotFoundPage = () => { - // TODO: - // Fix localisation issue - return ( - - - - ); -}; - -export default NotFoundPage; diff --git a/apps/web/pages/404.tsx b/apps/web/pages/404.tsx deleted file mode 100644 index 2fac4eac8..000000000 --- a/apps/web/pages/404.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import NotFound from '@components/pages/404'; -import { AuthLayout } from 'lib/layout'; -import { useTranslation } from 'react-i18next'; - -const NotFoundPage = () => { - - const { t } = useTranslation(); - - return ( - - - - ); -}; - -export default NotFoundPage; diff --git a/apps/web/pages/main-v1.tsx b/apps/web/pages/main-v1.tsx deleted file mode 100644 index 619c68efd..000000000 --- a/apps/web/pages/main-v1.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { withAuthentication } from 'lib/app/authenticator'; -import TeamMemberSection from '@components/pages/main/team-member'; -import { TimerTasksSection } from '@components/pages/main/timer-tasks'; -import { AppLayout } from '@components/layout'; - -const Main = () => { - return ( - - - - - ); -}; - -export default withAuthentication(Main, { displayName: 'MainPage' }); From 517ae3fbbd59cf5f5745bd4c6a44bd230e0f1e7d Mon Sep 17 00:00:00 2001 From: Badal Khatri Date: Wed, 27 Dec 2023 08:50:58 +0530 Subject: [PATCH 08/24] fix: Member Page --- apps/web/app/hooks/features/useUserProfilePage.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/web/app/hooks/features/useUserProfilePage.ts b/apps/web/app/hooks/features/useUserProfilePage.ts index 02d28db55..790a739b0 100644 --- a/apps/web/app/hooks/features/useUserProfilePage.ts +++ b/apps/web/app/hooks/features/useUserProfilePage.ts @@ -1,7 +1,7 @@ 'use client'; import { ITeamTask } from '@app/interfaces'; -import { useSearchParams } from 'next/navigation'; +import { useParams } from 'next/navigation'; import { useCallback, useEffect, useMemo } from 'react'; import { useAuthenticateUser } from './useAuthenticateUser'; import { useAuthTeamTasks } from './useAuthTeamTasks'; @@ -16,10 +16,10 @@ export function useUserProfilePage() { const { user: auth } = useAuthenticateUser(); const { getTasksStatsData } = useTaskStatistics(); - const searchParams = useSearchParams(); + const params = useParams(); const memberId: string = useMemo(() => { - return (searchParams?.get('memberId') || '') as string; - }, [searchParams]); + return (params?.memberId || '') as string; + }, [params]); const members = activeTeam?.members || []; From aa5eab64981a704941699665b22536035fc527c3 Mon Sep 17 00:00:00 2001 From: Badal Khatri Date: Wed, 27 Dec 2023 10:20:18 +0530 Subject: [PATCH 09/24] fix: Font not loading --- apps/web/app/[locale]/layout.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/web/app/[locale]/layout.tsx b/apps/web/app/[locale]/layout.tsx index 7c81aa4ec..8e091f809 100644 --- a/apps/web/app/[locale]/layout.tsx +++ b/apps/web/app/[locale]/layout.tsx @@ -2,7 +2,6 @@ 'use client'; import clsx from 'clsx'; -import { Inter } from 'next/font/google'; import { notFound } from 'next/navigation'; import { ReactNode } from 'react'; import { NextIntlClientProvider } from 'next-intl'; @@ -14,8 +13,6 @@ import '../../styles/globals.css'; const locales = ['en', 'de', 'ar', 'bg', 'zh', 'nl', 'de', 'he', 'it', 'pl', 'pt', 'ru', 'es', 'fr']; -const inter = Inter({ subsets: ['latin'] }); - type Props = { children: ReactNode; params: { locale: string }; @@ -59,7 +56,7 @@ export default function LocaleLayout({ children, params: { locale } }: Props) { )} */} - + {children} From 99e7840fd15e757d378e217dd4a045ca7d1af5fb Mon Sep 17 00:00:00 2001 From: Badal Khatri Date: Wed, 27 Dec 2023 10:35:34 +0530 Subject: [PATCH 10/24] fix: Sidebar links --- .../lib/settings/left-side-setting-menu.tsx | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/apps/web/lib/settings/left-side-setting-menu.tsx b/apps/web/lib/settings/left-side-setting-menu.tsx index a5da3f262..f9d3407ec 100644 --- a/apps/web/lib/settings/left-side-setting-menu.tsx +++ b/apps/web/lib/settings/left-side-setting-menu.tsx @@ -5,15 +5,20 @@ import { scrollToElement } from '@app/utils'; import { Text } from 'lib/components'; import { SidebarAccordian } from 'lib/components/sidebar-accordian'; import { PeopleIcon, PeopleIconFilled, UserIcon, UserIconFilled } from 'lib/components/svgs'; -import { usePathname } from 'next/navigation'; -import { useCallback, useEffect, useState } from 'react'; +import { useParams, usePathname } from 'next/navigation'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { useTranslations } from 'next-intl'; import { useRecoilState } from 'recoil'; +import Link from 'next/link'; export const LeftSideSettingMenu = () => { const t = useTranslations(); const { PersonalAccordianData, TeamAccordianData } = useLeftSettingData(); const pathname = usePathname(); + const params = useParams(); + const locale = useMemo(() => { + return params?.locale || ''; + }, [params]); const [activePage, setActivePage] = useState(''); const [user] = useRecoilState(userState); @@ -94,7 +99,11 @@ export const LeftSideSettingMenu = () => {
{PersonalAccordianData.map((ad, index) => { return ( - + { > {ad.title} - + ); })}
@@ -138,7 +147,11 @@ export const LeftSideSettingMenu = () => { {TeamAccordianData.filter((ad) => (!isTeamManager && !ad.managerOnly) || isTeamManager).map( (ad, index) => { return ( - + { > {ad.title} - + ); } )} From e3e602b52d20279aff4b8030776bda5491fa4006 Mon Sep 17 00:00:00 2001 From: maceteligolden Date: Wed, 27 Dec 2023 08:47:41 +0100 Subject: [PATCH 11/24] fix:resolve scroll issues --- apps/web/lib/components/dropdown.tsx | 9 +++++---- apps/web/lib/features/team/teams-dropdown.tsx | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/web/lib/components/dropdown.tsx b/apps/web/lib/components/dropdown.tsx index 29465e147..b048afcce 100644 --- a/apps/web/lib/components/dropdown.tsx +++ b/apps/web/lib/components/dropdown.tsx @@ -91,15 +91,15 @@ export function Dropdown({ > ({ /> )} - +
{items.map((Item, index) => ( ({ }} ))} +
{/* Additional content */} {closeOnChildrenClick && {children}} diff --git a/apps/web/lib/features/team/teams-dropdown.tsx b/apps/web/lib/features/team/teams-dropdown.tsx index bbaefe4e7..a4ac5bdb8 100644 --- a/apps/web/lib/features/team/teams-dropdown.tsx +++ b/apps/web/lib/features/team/teams-dropdown.tsx @@ -63,7 +63,7 @@ export const TeamsDropDown = ({ publicTeam }: { publicTeam?: boolean }) => { className="md:w-[223px] outline-none" optionsClassName="md:w-[223px] outline-none" buttonClassName={clsxm( - 'py-0 font-medium outline-none h-[3.125rem] dark:bg-[#1B1D22] dark:border-[0.125rem] border-[#0000001A] dark:border-[#26272C]', + 'py-0 font-medium outline-none dark:bg-[#1B1D22] dark:border-[0.125rem] border-[#0000001A] dark:border-[#26272C]', items.length === 0 && ['py-2'] )} value={teamItem} From bc83ac1863b26e9de01376a8c29cc0490ceb4a2c Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Thu, 21 Dec 2023 17:09:37 +0200 Subject: [PATCH 12/24] feat: make card draggable --- .../lib/features/team-members-card-view.tsx | 38 +++++++++++++++++-- .../features/team/user-team-card/index.tsx | 33 ++++++++++++++-- 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/apps/web/lib/features/team-members-card-view.tsx b/apps/web/lib/features/team-members-card-view.tsx index c69fff7c7..8aa192447 100644 --- a/apps/web/lib/features/team-members-card-view.tsx +++ b/apps/web/lib/features/team-members-card-view.tsx @@ -4,6 +4,7 @@ import { InviteFormModal } from './team/invite/invite-form-modal'; import { InvitedCard, InviteUserTeamCard } from './team/invite/user-invite-card'; import { InviteUserTeamSkeleton, UserTeamCard, UserTeamCardSkeleton } from '.'; import { OT_Member } from '@app/interfaces'; +import React from 'react'; interface Props { teamMembers: OT_Member[]; @@ -22,6 +23,18 @@ const TeamMembersCardView: React.FC = ({ const { teamInvitations } = useTeamInvitations(); + const [memberOrdereds, setMemberOrdereds] = React.useState(members); + const dragTeamMember = React.useRef(0); + const draggedOverTeamMember = React.useRef(0); + + function handleSort() { + const peopleClone = [...memberOrdereds]; + const temp = peopleClone[dragTeamMember.current]; + peopleClone[dragTeamMember.current] = peopleClone[draggedOverTeamMember.current]; + peopleClone[draggedOverTeamMember.current] = temp; + setMemberOrdereds(peopleClone); + } + return (
    {/* Current authenticated user members */} @@ -35,12 +48,22 @@ const TeamMembersCardView: React.FC = ({ leaveTo="opacity-0" >
  • - + (dragTeamMember.current = 0)} + onDragEnter={() => (draggedOverTeamMember.current = 0)} + onDragEnd={handleSort} + onDragOver={(e) => e.preventDefault()} + />
  • {/* Team members list */} - {members.map((member) => { + {memberOrdereds.map((member, i) => { return ( = ({ leaveTo="opacity-0" >
  • - + (dragTeamMember.current = i)} + onDragEnter={() => (draggedOverTeamMember.current = i)} + onDragEnd={handleSort} + onDragOver={(e) => e.preventDefault()} + />
  • ); diff --git a/apps/web/lib/features/team/user-team-card/index.tsx b/apps/web/lib/features/team/user-team-card/index.tsx index 743a9f511..0286c5858 100644 --- a/apps/web/lib/features/team/user-team-card/index.tsx +++ b/apps/web/lib/features/team/user-team-card/index.tsx @@ -3,7 +3,7 @@ import { useCollaborative, useTMCardTaskEdit, useTaskStatistics, useTeamMemberCa import { IClassName, IOrganizationTeamList } from '@app/interfaces'; import { timerSecondsState } from '@app/stores'; import { clsxm } from '@app/utils'; -import { Card, InputField, Text, Tooltip, VerticalSeparator } from 'lib/components'; +import { Card, HorizontalSeparator, InputField, Text, Tooltip, VerticalSeparator } from 'lib/components'; import { DraggerIcon } from 'lib/components/svgs'; import { TaskTimes, TodayWorkedTime } from 'lib/features'; import { useTranslations } from 'next-intl'; @@ -48,9 +48,26 @@ type IUserTeamCard = { member?: IOrganizationTeamList['members'][number]; publicTeam?: boolean; members?: IOrganizationTeamList['members']; + draggable: boolean; + onDragStart: () => any; + onDragEnter: () => any; + onDragEnd: any; + onDragOver: (e: React.DragEvent) => any; + currentExit: boolean; } & IClassName; -export function UserTeamCard({ className, active, member, publicTeam = false }: IUserTeamCard) { +export function UserTeamCard({ + className, + active, + member, + publicTeam = false, + draggable = false, + onDragStart, + onDragEnd, + onDragEnter, + onDragOver, + currentExit = false +}: IUserTeamCard) { const t = useTranslations(); const memberInfo = useTeamMemberCard(member); const taskEdition = useTMCardTaskEdit(memberInfo.memberTask); @@ -99,7 +116,14 @@ export function UserTeamCard({ className, active, member, publicTeam = false }: ); return ( -
    +
    -
    +
    @@ -191,6 +215,7 @@ export function UserTeamCard({ className, active, member, publicTeam = false }: {/* Card menu */}
    {menu}
    + {currentExit && }
    ); } From 65ee78e6158b18b389245d3d1493b41f2ffd8fbf Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Thu, 21 Dec 2023 22:23:17 +0200 Subject: [PATCH 13/24] feat: make cards draggable --- apps/web/lib/features/team-members-card-view.tsx | 13 +++++++++++-- apps/web/lib/features/team/user-team-card/index.tsx | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/web/lib/features/team-members-card-view.tsx b/apps/web/lib/features/team-members-card-view.tsx index 8aa192447..c0720e633 100644 --- a/apps/web/lib/features/team-members-card-view.tsx +++ b/apps/web/lib/features/team-members-card-view.tsx @@ -23,6 +23,7 @@ const TeamMembersCardView: React.FC = ({ const { teamInvitations } = useTeamInvitations(); + // TODO: sort teamMembers by index const [memberOrdereds, setMemberOrdereds] = React.useState(members); const dragTeamMember = React.useRef(0); const draggedOverTeamMember = React.useRef(0); @@ -33,6 +34,8 @@ const TeamMembersCardView: React.FC = ({ peopleClone[dragTeamMember.current] = peopleClone[draggedOverTeamMember.current]; peopleClone[draggedOverTeamMember.current] = temp; setMemberOrdereds(peopleClone); + + // TODO: update teamMembers index } return ( @@ -81,8 +84,14 @@ const TeamMembersCardView: React.FC = ({ publicTeam={publicTeam} currentExit={draggedOverTeamMember.current == i} draggable - onDragStart={() => (dragTeamMember.current = i)} - onDragEnter={() => (draggedOverTeamMember.current = i)} + onDragStart={() => { + // TODO: update also index of tamMember for API + dragTeamMember.current = i; + }} + onDragEnter={() => { + // TODO: update also index of tamMember for API + draggedOverTeamMember.current = i; + }} onDragEnd={handleSort} onDragOver={(e) => e.preventDefault()} /> diff --git a/apps/web/lib/features/team/user-team-card/index.tsx b/apps/web/lib/features/team/user-team-card/index.tsx index 0286c5858..e38354cbc 100644 --- a/apps/web/lib/features/team/user-team-card/index.tsx +++ b/apps/web/lib/features/team/user-team-card/index.tsx @@ -215,7 +215,9 @@ export function UserTeamCard({ {/* Card menu */}
    {menu}
    - {currentExit && } + {currentExit && ( + + )}
    ); } From 5648e95b5ccc722d02277fb7a6237e86cf1600c1 Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Sat, 23 Dec 2023 15:40:35 +0200 Subject: [PATCH 14/24] feat: add request to edit employee index --- .../server/requests/organization-team.ts | 20 ++++++++++++++ .../lib/features/team-members-card-view.tsx | 2 ++ .../api/organization-team/employee/[id].ts | 27 ++++++++++++++----- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/apps/web/app/services/server/requests/organization-team.ts b/apps/web/app/services/server/requests/organization-team.ts index c3fdabd4f..2cd320459 100644 --- a/apps/web/app/services/server/requests/organization-team.ts +++ b/apps/web/app/services/server/requests/organization-team.ts @@ -172,6 +172,26 @@ export function removeEmployeeOrganizationTeamRequest({ }); } +export function addEmployeeOrganizationTeamIndexRequest({ + employeeId, + bearer_token, + tenantId, + index +}: { + employeeId: string; + bearer_token: string; + tenantId: string; + index: number; +}) { + return serverFetch({ + path: `/organization-team-employee/${employeeId}`, + method: 'DELETE', + bearer_token, + body: { index }, + tenantId + }); +} + export function removeUserFromAllTeam({ userId, bearer_token, diff --git a/apps/web/lib/features/team-members-card-view.tsx b/apps/web/lib/features/team-members-card-view.tsx index c0720e633..7d4a86065 100644 --- a/apps/web/lib/features/team-members-card-view.tsx +++ b/apps/web/lib/features/team-members-card-view.tsx @@ -86,10 +86,12 @@ const TeamMembersCardView: React.FC = ({ draggable onDragStart={() => { // TODO: update also index of tamMember for API + console.log({ d: dragTeamMember.current }); dragTeamMember.current = i; }} onDragEnter={() => { // TODO: update also index of tamMember for API + console.log({ d: draggedOverTeamMember.current }); draggedOverTeamMember.current = i; }} onDragEnd={handleSort} diff --git a/apps/web/pages/api/organization-team/employee/[id].ts b/apps/web/pages/api/organization-team/employee/[id].ts index 49297c102..9b34dc19f 100644 --- a/apps/web/pages/api/organization-team/employee/[id].ts +++ b/apps/web/pages/api/organization-team/employee/[id].ts @@ -8,15 +8,30 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) const { id } = req.query; - if (req.method !== 'DELETE' || !id) { + if (!id) { return $res.status(405).json({}); } - await removeEmployeeOrganizationTeamRequest({ - bearer_token: access_token, - tenantId, - employeeId: id.toString() - }); + switch (req.method) { + case 'DELETE': + await removeEmployeeOrganizationTeamRequest({ + bearer_token: access_token, + tenantId, + employeeId: id.toString() + }); + break; + case 'PUT': + } + + // if (req.method !== 'DELETE' || !id) { + // return $res.status(405).json({}); + // } + + // await removeEmployeeOrganizationTeamRequest({ + // bearer_token: access_token, + // tenantId, + // employeeId: id.toString() + // }); return; } From 62c3d9bf5778ddefefb134b0000bbb219f7b3cc8 Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Sat, 23 Dec 2023 16:03:39 +0200 Subject: [PATCH 15/24] feat: add request to edit employee index on API --- apps/web/app/interfaces/IOrganizationTeam.ts | 1 + .../pages/api/organization-team/employee/[id].ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/web/app/interfaces/IOrganizationTeam.ts b/apps/web/app/interfaces/IOrganizationTeam.ts index ec6764f6f..6ec712257 100644 --- a/apps/web/app/interfaces/IOrganizationTeam.ts +++ b/apps/web/app/interfaces/IOrganizationTeam.ts @@ -66,6 +66,7 @@ export type IOrganizationTeamWithMStatus = IOrganizationTeamList; export interface OT_Member { id: string; + index?: number; createdAt: string; updatedAt: string; tenantId: any; diff --git a/apps/web/pages/api/organization-team/employee/[id].ts b/apps/web/pages/api/organization-team/employee/[id].ts index 9b34dc19f..7f489f5a5 100644 --- a/apps/web/pages/api/organization-team/employee/[id].ts +++ b/apps/web/pages/api/organization-team/employee/[id].ts @@ -1,5 +1,8 @@ import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard'; -import { removeEmployeeOrganizationTeamRequest } from '@app/services/server/requests'; +import { + addEmployeeOrganizationTeamIndexRequest, + removeEmployeeOrganizationTeamRequest +} from '@app/services/server/requests'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler(req: NextApiRequest, res: NextApiResponse) { @@ -7,6 +10,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) if (!user) return $res(); const { id } = req.query; + const index = req.body.index; if (!id) { return $res.status(405).json({}); @@ -21,6 +25,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) }); break; case 'PUT': + await addEmployeeOrganizationTeamIndexRequest({ + bearer_token: access_token, + tenantId, + employeeId: id.toString(), + index + }); + break; } // if (req.method !== 'DELETE' || !id) { From 0b68f9591b3a1301a9e8ab74a87a745314d7883c Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Sun, 24 Dec 2023 04:16:07 +0200 Subject: [PATCH 16/24] feat: add hook to edit team member index in array --- .../client/requests/organization-team.ts | 167 +++++++++--------- .../features/useOrganizatioTeamsEmployee.ts | 19 +- .../services/client/api/organization-team.ts | 4 + .../server/requests/organization-team.ts | 2 +- .../lib/features/team-members-card-view.tsx | 13 +- 5 files changed, 117 insertions(+), 88 deletions(-) diff --git a/apps/mobile/app/services/client/requests/organization-team.ts b/apps/mobile/app/services/client/requests/organization-team.ts index d57e49bd0..d9dd8574f 100644 --- a/apps/mobile/app/services/client/requests/organization-team.ts +++ b/apps/mobile/app/services/client/requests/organization-team.ts @@ -1,42 +1,39 @@ /* eslint-disable camelcase */ -import moment from "moment" -import { PaginationResponse } from "../../interfaces/IDataResponse" +import moment from 'moment'; +import { PaginationResponse } from '../../interfaces/IDataResponse'; import { IOrganizationTeam, IOrganizationTeamCreate, IOrganizationTeamList, IOrganizationTeamUpdate, - IOrganizationTeamWithMStatus, -} from "../../interfaces/IOrganizationTeam" -import { serverFetch } from "../fetch" + IOrganizationTeamWithMStatus +} from '../../interfaces/IOrganizationTeam'; +import { serverFetch } from '../fetch'; -export function createOrganizationTeamRequest( - datas: IOrganizationTeamCreate, - bearer_token: string, -) { +export function createOrganizationTeamRequest(datas: IOrganizationTeamCreate, bearer_token: string) { return serverFetch({ - path: "/organization-team", - method: "POST", + path: '/organization-team', + method: 'POST', body: datas, - bearer_token, - }) + bearer_token + }); } export function updateOrganizationTeamRequest({ id, datas, - bearer_token, + bearer_token }: { - datas: IOrganizationTeamList | IOrganizationTeamCreate - id: string - bearer_token: string + datas: IOrganizationTeamList | IOrganizationTeamCreate; + id: string; + bearer_token: string; }) { return serverFetch({ path: `/organization-team/${id}`, - method: "PUT", + method: 'PUT', body: datas, - bearer_token, - }) + bearer_token + }); } export function getOrganizationTeamRequest( @@ -45,131 +42,131 @@ export function getOrganizationTeamRequest( tenantId, teamId, relations = [ - "members", - "members.role", - "members.employee", - "members.employee.user", - "createdBy", - "createdBy.employee", - "projects", - ], + 'members', + 'members.role', + 'members.employee', + 'members.employee.user', + 'createdBy', + 'createdBy.employee', + 'projects' + ] }: TeamRequestParams & { teamId: string }, - bearer_token: string, + bearer_token: string ) { const params = { organizationId, tenantId, // source: "BROWSER", - withLaskWorkedTask: "true", - startDate: moment().startOf("day").toISOString(), - endDate: moment().endOf("day").toISOString(), - includeOrganizationTeamId: "false", - } as { [x: string]: string } + withLaskWorkedTask: 'true', + startDate: moment().startOf('day').toISOString(), + endDate: moment().endOf('day').toISOString(), + includeOrganizationTeamId: 'false' + } as { [x: string]: string }; relations.forEach((rl, i) => { - params[`relations[${i}]`] = rl - }) + params[`relations[${i}]`] = rl; + }); - const queries = new URLSearchParams(params || {}) + const queries = new URLSearchParams(params || {}); return serverFetch({ path: `/organization-team/${teamId}?${queries.toString()}`, - method: "GET", + method: 'GET', bearer_token, - tenantId, - }) + tenantId + }); } type TeamRequestParams = { - organizationId: string - tenantId: string - relations?: string[] -} + organizationId: string; + tenantId: string; + relations?: string[]; +}; export function getAllOrganizationTeamRequest( { organizationId, tenantId, relations = [ - "members", - "members.role", - "members.employee", - "members.employee.user", - "createdBy", - "createdBy.employee", - ], + 'members', + 'members.role', + 'members.employee', + 'members.employee.user', + 'createdBy', + 'createdBy.employee' + ] }: TeamRequestParams, - bearer_token: string, + bearer_token: string ) { const params = { - "where[organizationId]": organizationId, - "where[tenantId]": tenantId, - source: "BROWSER", - withLaskWorkedTask: "true", - } as { [x: string]: string } + 'where[organizationId]': organizationId, + 'where[tenantId]': tenantId, + source: 'BROWSER', + withLaskWorkedTask: 'true' + } as { [x: string]: string }; relations.forEach((rl, i) => { - params[`relations[${i}]`] = rl - }) + params[`relations[${i}]`] = rl; + }); - const query = new URLSearchParams(params) + const query = new URLSearchParams(params); return serverFetch>({ path: `/organization-team?${query.toString()}`, - method: "GET", + method: 'GET', bearer_token, - tenantId, - }) + tenantId + }); } export function removeEmployeeOrganizationTeamRequest({ employeeId, bearer_token, - tenantId, + tenantId }: { - employeeId: string - bearer_token: string - tenantId: string + employeeId: string; + bearer_token: string; + tenantId: string; }) { return serverFetch({ path: `/organization-team-employee/${employeeId}`, - method: "DELETE", + method: 'DELETE', bearer_token, - tenantId, - }) + tenantId + }); } export function removeUserFromAllTeam({ userId, bearer_token, - tenantId, + tenantId }: { - userId: string - bearer_token: string - tenantId: string + userId: string; + bearer_token: string; + tenantId: string; }) { return serverFetch({ path: `/organization-team/teams/${userId}`, - method: "DELETE", + method: 'DELETE', bearer_token, - tenantId, - }) + tenantId + }); } export function deleteOrganizationTeamRequest({ id, bearer_token, tenantId, - organizationId, + organizationId }: { - id: string - bearer_token: string - tenantId: string - organizationId: string + id: string; + bearer_token: string; + tenantId: string; + organizationId: string; }) { return serverFetch({ path: `/organization-team/${id}?organizationId=${organizationId}`, - method: "DELETE", + method: 'DELETE', bearer_token, - tenantId, - }) + tenantId + }); } diff --git a/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts b/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts index 7082ee163..5cc41b7e3 100644 --- a/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts +++ b/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts @@ -7,6 +7,7 @@ import { import { useCallback } from 'react'; import { useQuery } from '../useQuery'; import { useOrganizationTeams } from './useOrganizationTeams'; +import { editEmployeeIndexOrganizationTeamAPI } from '@app/services/client/api'; export function useOrganizationEmployeeTeams() { const { loadTeamsData } = useOrganizationTeams(); @@ -19,6 +20,10 @@ export function useOrganizationEmployeeTeams() { updateOrganizationEmployeeTeamAPI ); + const { loading: editEmployeeIndexOrganizationTeamLoading, queryCall: updateIndexCall } = useQuery( + editEmployeeIndexOrganizationTeamAPI + ); + const { loading: updateOrganizationTeamEmployeeActiveTaskLoading, queryCall: updateOrganizationTeamEmployeeActiveTaskQueryCall @@ -59,6 +64,16 @@ export function useOrganizationEmployeeTeams() { [loadTeamsData, updateQueryCall] ); + const updateOrganizationTeamEmployeeIndexOnList = useCallback( + (employeeId: string, index: number) => { + updateIndexCall(employeeId, { index }).then((res) => { + loadTeamsData(); + return res; + }); + }, + [loadTeamsData, updateIndexCall] + ); + const updateOrganizationTeamEmployeeActiveTask = useCallback( (id: string, data: Partial) => { updateOrganizationTeamEmployeeActiveTaskQueryCall(id, data).then((res) => { @@ -75,6 +90,8 @@ export function useOrganizationEmployeeTeams() { updateOrganizationEmployeeTeamLoading, updateOrganizationTeamEmployee, updateOrganizationTeamEmployeeActiveTaskLoading, - updateOrganizationTeamEmployeeActiveTask + updateOrganizationTeamEmployeeActiveTask, + editEmployeeIndexOrganizationTeamLoading, + updateOrganizationTeamEmployeeIndexOnList }; } diff --git a/apps/web/app/services/client/api/organization-team.ts b/apps/web/app/services/client/api/organization-team.ts index b2ea8e31f..3ea106386 100644 --- a/apps/web/app/services/client/api/organization-team.ts +++ b/apps/web/app/services/client/api/organization-team.ts @@ -92,6 +92,10 @@ export function removeEmployeeOrganizationTeamAPI(employeeId: string) { return api.delete(`/organization-team/employee/${employeeId}`); } +export function editEmployeeIndexOrganizationTeamAPI(employeeId: string, data: { index: number }) { + return api.put(`/organization-team/employee/${employeeId}`, data); +} + export function removeUserFromAllTeamAPI(userId: string) { return api.delete>(`/organization-team/teams/${userId}`); } diff --git a/apps/web/app/services/server/requests/organization-team.ts b/apps/web/app/services/server/requests/organization-team.ts index 2cd320459..f5a19da84 100644 --- a/apps/web/app/services/server/requests/organization-team.ts +++ b/apps/web/app/services/server/requests/organization-team.ts @@ -185,7 +185,7 @@ export function addEmployeeOrganizationTeamIndexRequest({ }) { return serverFetch({ path: `/organization-team-employee/${employeeId}`, - method: 'DELETE', + method: 'PUT', bearer_token, body: { index }, tenantId diff --git a/apps/web/lib/features/team-members-card-view.tsx b/apps/web/lib/features/team-members-card-view.tsx index 7d4a86065..f8a190b50 100644 --- a/apps/web/lib/features/team-members-card-view.tsx +++ b/apps/web/lib/features/team-members-card-view.tsx @@ -1,4 +1,4 @@ -import { useAuthenticateUser, useModal, useTeamInvitations } from '@app/hooks'; +import { useAuthenticateUser, useModal, useOrganizationEmployeeTeams, useTeamInvitations } from '@app/hooks'; import { Transition } from '@headlessui/react'; import { InviteFormModal } from './team/invite/invite-form-modal'; import { InvitedCard, InviteUserTeamCard } from './team/invite/user-invite-card'; @@ -23,6 +23,8 @@ const TeamMembersCardView: React.FC = ({ const { teamInvitations } = useTeamInvitations(); + const { updateOrganizationTeamEmployeeIndexOnList } = useOrganizationEmployeeTeams(); + // TODO: sort teamMembers by index const [memberOrdereds, setMemberOrdereds] = React.useState(members); const dragTeamMember = React.useRef(0); @@ -34,10 +36,19 @@ const TeamMembersCardView: React.FC = ({ peopleClone[dragTeamMember.current] = peopleClone[draggedOverTeamMember.current]; peopleClone[draggedOverTeamMember.current] = temp; setMemberOrdereds(peopleClone); + handleChangeIndex(peopleClone[dragTeamMember.current].id, draggedOverTeamMember.current); + handleChangeIndex(peopleClone[draggedOverTeamMember.current].id, dragTeamMember.current); // TODO: update teamMembers index } + const handleChangeIndex = React.useCallback( + (employeeId: string, index: number) => { + updateOrganizationTeamEmployeeIndexOnList(employeeId, index); + }, + [updateOrganizationTeamEmployeeIndexOnList] + ); + return (
      {/* Current authenticated user members */} From b5c2480afe733db948492b3e8b3c7b9ee371b699 Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Sun, 24 Dec 2023 16:12:27 +0200 Subject: [PATCH 17/24] rafact: change index property in api call methods --- .../features/useOrganizatioTeamsEmployee.ts | 16 ++++++++-------- apps/web/app/interfaces/IOrganizationTeam.ts | 2 +- .../services/client/api/organization-team.ts | 2 +- .../server/requests/organization-team.ts | 8 ++++---- .../lib/features/team-members-card-view.tsx | 19 +++++++------------ .../api/organization-team/employee/[id].ts | 8 ++++---- 6 files changed, 25 insertions(+), 30 deletions(-) diff --git a/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts b/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts index 5cc41b7e3..7fcff6bd5 100644 --- a/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts +++ b/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts @@ -7,7 +7,7 @@ import { import { useCallback } from 'react'; import { useQuery } from '../useQuery'; import { useOrganizationTeams } from './useOrganizationTeams'; -import { editEmployeeIndexOrganizationTeamAPI } from '@app/services/client/api'; +import { editEmployeeOrderOrganizationTeamAPI } from '@app/services/client/api'; export function useOrganizationEmployeeTeams() { const { loadTeamsData } = useOrganizationTeams(); @@ -20,8 +20,8 @@ export function useOrganizationEmployeeTeams() { updateOrganizationEmployeeTeamAPI ); - const { loading: editEmployeeIndexOrganizationTeamLoading, queryCall: updateIndexCall } = useQuery( - editEmployeeIndexOrganizationTeamAPI + const { loading: editEmployeeIndexOrganizationTeamLoading, queryCall: updateOrderCall } = useQuery( + editEmployeeOrderOrganizationTeamAPI ); const { @@ -64,14 +64,14 @@ export function useOrganizationEmployeeTeams() { [loadTeamsData, updateQueryCall] ); - const updateOrganizationTeamEmployeeIndexOnList = useCallback( - (employeeId: string, index: number) => { - updateIndexCall(employeeId, { index }).then((res) => { + const updateOrganizationTeamEmployeeOrderOnList = useCallback( + (employeeId: string, order: number) => { + updateOrderCall(employeeId, { order }).then((res) => { loadTeamsData(); return res; }); }, - [loadTeamsData, updateIndexCall] + [loadTeamsData, updateOrderCall] ); const updateOrganizationTeamEmployeeActiveTask = useCallback( @@ -92,6 +92,6 @@ export function useOrganizationEmployeeTeams() { updateOrganizationTeamEmployeeActiveTaskLoading, updateOrganizationTeamEmployeeActiveTask, editEmployeeIndexOrganizationTeamLoading, - updateOrganizationTeamEmployeeIndexOnList + updateOrganizationTeamEmployeeOrderOnList }; } diff --git a/apps/web/app/interfaces/IOrganizationTeam.ts b/apps/web/app/interfaces/IOrganizationTeam.ts index 6ec712257..d55ecc790 100644 --- a/apps/web/app/interfaces/IOrganizationTeam.ts +++ b/apps/web/app/interfaces/IOrganizationTeam.ts @@ -66,7 +66,7 @@ export type IOrganizationTeamWithMStatus = IOrganizationTeamList; export interface OT_Member { id: string; - index?: number; + order?: number; createdAt: string; updatedAt: string; tenantId: any; diff --git a/apps/web/app/services/client/api/organization-team.ts b/apps/web/app/services/client/api/organization-team.ts index 3ea106386..6a73ff6d4 100644 --- a/apps/web/app/services/client/api/organization-team.ts +++ b/apps/web/app/services/client/api/organization-team.ts @@ -92,7 +92,7 @@ export function removeEmployeeOrganizationTeamAPI(employeeId: string) { return api.delete(`/organization-team/employee/${employeeId}`); } -export function editEmployeeIndexOrganizationTeamAPI(employeeId: string, data: { index: number }) { +export function editEmployeeOrderOrganizationTeamAPI(employeeId: string, data: { order: number }) { return api.put(`/organization-team/employee/${employeeId}`, data); } diff --git a/apps/web/app/services/server/requests/organization-team.ts b/apps/web/app/services/server/requests/organization-team.ts index f5a19da84..c2279a1de 100644 --- a/apps/web/app/services/server/requests/organization-team.ts +++ b/apps/web/app/services/server/requests/organization-team.ts @@ -172,22 +172,22 @@ export function removeEmployeeOrganizationTeamRequest({ }); } -export function addEmployeeOrganizationTeamIndexRequest({ +export function addEmployeeOrganizationTeamOrderRequest({ employeeId, bearer_token, tenantId, - index + order }: { employeeId: string; bearer_token: string; tenantId: string; - index: number; + order: number; }) { return serverFetch({ path: `/organization-team-employee/${employeeId}`, method: 'PUT', bearer_token, - body: { index }, + body: { order }, tenantId }); } diff --git a/apps/web/lib/features/team-members-card-view.tsx b/apps/web/lib/features/team-members-card-view.tsx index f8a190b50..fe3ee546c 100644 --- a/apps/web/lib/features/team-members-card-view.tsx +++ b/apps/web/lib/features/team-members-card-view.tsx @@ -23,7 +23,7 @@ const TeamMembersCardView: React.FC = ({ const { teamInvitations } = useTeamInvitations(); - const { updateOrganizationTeamEmployeeIndexOnList } = useOrganizationEmployeeTeams(); + const { updateOrganizationTeamEmployeeOrderOnList } = useOrganizationEmployeeTeams(); // TODO: sort teamMembers by index const [memberOrdereds, setMemberOrdereds] = React.useState(members); @@ -36,17 +36,16 @@ const TeamMembersCardView: React.FC = ({ peopleClone[dragTeamMember.current] = peopleClone[draggedOverTeamMember.current]; peopleClone[draggedOverTeamMember.current] = temp; setMemberOrdereds(peopleClone); - handleChangeIndex(peopleClone[dragTeamMember.current].id, draggedOverTeamMember.current); - handleChangeIndex(peopleClone[draggedOverTeamMember.current].id, dragTeamMember.current); - // TODO: update teamMembers index + handleChangeOrder(peopleClone[dragTeamMember.current].id, draggedOverTeamMember.current); + handleChangeOrder(peopleClone[draggedOverTeamMember.current].id, dragTeamMember.current); } - const handleChangeIndex = React.useCallback( - (employeeId: string, index: number) => { - updateOrganizationTeamEmployeeIndexOnList(employeeId, index); + const handleChangeOrder = React.useCallback( + (employeeId: string, order: number) => { + updateOrganizationTeamEmployeeOrderOnList(employeeId, order); }, - [updateOrganizationTeamEmployeeIndexOnList] + [updateOrganizationTeamEmployeeOrderOnList] ); return ( @@ -96,13 +95,9 @@ const TeamMembersCardView: React.FC = ({ currentExit={draggedOverTeamMember.current == i} draggable onDragStart={() => { - // TODO: update also index of tamMember for API - console.log({ d: dragTeamMember.current }); dragTeamMember.current = i; }} onDragEnter={() => { - // TODO: update also index of tamMember for API - console.log({ d: draggedOverTeamMember.current }); draggedOverTeamMember.current = i; }} onDragEnd={handleSort} diff --git a/apps/web/pages/api/organization-team/employee/[id].ts b/apps/web/pages/api/organization-team/employee/[id].ts index 7f489f5a5..54c69aa4c 100644 --- a/apps/web/pages/api/organization-team/employee/[id].ts +++ b/apps/web/pages/api/organization-team/employee/[id].ts @@ -1,6 +1,6 @@ import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard'; import { - addEmployeeOrganizationTeamIndexRequest, + addEmployeeOrganizationTeamOrderRequest, removeEmployeeOrganizationTeamRequest } from '@app/services/server/requests'; import { NextApiRequest, NextApiResponse } from 'next'; @@ -10,7 +10,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) if (!user) return $res(); const { id } = req.query; - const index = req.body.index; + const order = req.body.order; if (!id) { return $res.status(405).json({}); @@ -25,11 +25,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) }); break; case 'PUT': - await addEmployeeOrganizationTeamIndexRequest({ + await addEmployeeOrganizationTeamOrderRequest({ bearer_token: access_token, tenantId, employeeId: id.toString(), - index + order }); break; } From b170ab8821ea54734e45007a553d9c92e17e4176 Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Tue, 26 Dec 2023 21:22:00 +0200 Subject: [PATCH 18/24] feat: send index of team member to API --- .../hooks/features/useOrganizatioTeamsEmployee.ts | 11 +++++++---- .../app/interfaces/IOrganizationEmployeeTeam.ts | 1 + .../app/services/client/api/organization-team.ts | 5 +++-- apps/web/lib/features/team-members-card-view.tsx | 14 ++++++-------- apps/web/lib/features/team-members.tsx | 8 +++++++- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts b/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts index 7fcff6bd5..9470410ed 100644 --- a/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts +++ b/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts @@ -1,4 +1,4 @@ -import { IOrganizationTeamEmployeeUpdate } from '@app/interfaces'; +import { IOrganizationTeamEmployeeUpdate, OT_Member } from '@app/interfaces'; import { deleteOrganizationEmployeeTeamAPI, updateOrganizationEmployeeTeamAPI, @@ -65,12 +65,15 @@ export function useOrganizationEmployeeTeams() { ); const updateOrganizationTeamEmployeeOrderOnList = useCallback( - (employeeId: string, order: number) => { - updateOrderCall(employeeId, { order }).then((res) => { + (employee: OT_Member, order: number) => { + updateOrderCall(employee.id, { + order + }).then((res) => { loadTeamsData(); return res; }); }, + [loadTeamsData, updateOrderCall] ); @@ -91,7 +94,7 @@ export function useOrganizationEmployeeTeams() { updateOrganizationTeamEmployee, updateOrganizationTeamEmployeeActiveTaskLoading, updateOrganizationTeamEmployeeActiveTask, - editEmployeeIndexOrganizationTeamLoading, + // editEmployeeIndexOrganizationTeamLoading, updateOrganizationTeamEmployeeOrderOnList }; } diff --git a/apps/web/app/interfaces/IOrganizationEmployeeTeam.ts b/apps/web/app/interfaces/IOrganizationEmployeeTeam.ts index 332d9fa59..3ebea6311 100644 --- a/apps/web/app/interfaces/IOrganizationEmployeeTeam.ts +++ b/apps/web/app/interfaces/IOrganizationEmployeeTeam.ts @@ -9,6 +9,7 @@ export interface IOrganizationTeamEmployeeCreate { roleId?: string; isTrackingEnabled?: boolean; activeTaskId?: string; + order?: number; } export interface IOrganizationTeamEmployeeUpdate extends IOrganizationTeamEmployeeCreate { id: string; diff --git a/apps/web/app/services/client/api/organization-team.ts b/apps/web/app/services/client/api/organization-team.ts index 6a73ff6d4..49178b3e5 100644 --- a/apps/web/app/services/client/api/organization-team.ts +++ b/apps/web/app/services/client/api/organization-team.ts @@ -5,7 +5,8 @@ import { IOrganizationTeamWithMStatus, IOrganizationTeamUpdate, IOrganizationTeam, - TimerSource + TimerSource, + OT_Member } from '@app/interfaces'; import moment from 'moment'; import api, { get } from '../axios'; @@ -93,7 +94,7 @@ export function removeEmployeeOrganizationTeamAPI(employeeId: string) { } export function editEmployeeOrderOrganizationTeamAPI(employeeId: string, data: { order: number }) { - return api.put(`/organization-team/employee/${employeeId}`, data); + return api.put>(`/organization-team/employee/${employeeId}`, data); } export function removeUserFromAllTeamAPI(userId: string) { diff --git a/apps/web/lib/features/team-members-card-view.tsx b/apps/web/lib/features/team-members-card-view.tsx index fe3ee546c..5f0049e85 100644 --- a/apps/web/lib/features/team-members-card-view.tsx +++ b/apps/web/lib/features/team-members-card-view.tsx @@ -37,16 +37,14 @@ const TeamMembersCardView: React.FC = ({ peopleClone[draggedOverTeamMember.current] = temp; setMemberOrdereds(peopleClone); // TODO: update teamMembers index - handleChangeOrder(peopleClone[dragTeamMember.current].id, draggedOverTeamMember.current); - handleChangeOrder(peopleClone[draggedOverTeamMember.current].id, dragTeamMember.current); + handleChangeOrder(peopleClone[dragTeamMember.current], draggedOverTeamMember.current); + handleChangeOrder(peopleClone[draggedOverTeamMember.current], dragTeamMember.current); } - const handleChangeOrder = React.useCallback( - (employeeId: string, order: number) => { - updateOrganizationTeamEmployeeOrderOnList(employeeId, order); - }, - [updateOrganizationTeamEmployeeOrderOnList] - ); + const handleChangeOrder = (employee: OT_Member, order: number) => { + console.log({ employee, order }); + updateOrganizationTeamEmployeeOrderOnList(employee, order); + }; return (
        diff --git a/apps/web/lib/features/team-members.tsx b/apps/web/lib/features/team-members.tsx index 1e2697e92..30200d94b 100644 --- a/apps/web/lib/features/team-members.tsx +++ b/apps/web/lib/features/team-members.tsx @@ -28,10 +28,16 @@ export function TeamMembers({ publicTeam = false, kanbanView: view = IssuesView. activeFilter == 'all' ? orderedMembers : orderedMembers.filter((m) => m.timerStatus == activeFilter) || []; const currentUser = members.find((m) => m.employee.userId === user?.id); - const $members = members.filter((member) => member.id !== currentUser?.id); + const $members = members + .filter((member) => member.id !== currentUser?.id) + .sort((a, b) => { + if (a.order && b.order) return a.order > b.order ? -1 : 1; + else return -1; + }); const $teamsFetching = teamsFetching && members.length === 0; let teamMembersView; + console.log($members); switch (true) { case members.length === 0: From 9508df320f9f5b6057f9f7d216c88d3b85136802 Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Tue, 26 Dec 2023 21:37:50 +0200 Subject: [PATCH 19/24] fix: unused var --- apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts b/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts index 9470410ed..be85e2b01 100644 --- a/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts +++ b/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts @@ -94,7 +94,7 @@ export function useOrganizationEmployeeTeams() { updateOrganizationTeamEmployee, updateOrganizationTeamEmployeeActiveTaskLoading, updateOrganizationTeamEmployeeActiveTask, - // editEmployeeIndexOrganizationTeamLoading, + editEmployeeIndexOrganizationTeamLoading, updateOrganizationTeamEmployeeOrderOnList }; } From 76b9b96dc5dd6a166a0ce53f0dbdcba54338ae5f Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Wed, 27 Dec 2023 14:44:23 +0200 Subject: [PATCH 20/24] fix: api to update order of organization team member --- .../features/useOrganizatioTeamsEmployee.ts | 17 +++++++++++++---- .../services/client/api/organization-team.ts | 10 ++++++++-- .../server/requests/organization-team.ts | 13 ++++++++++--- .../api/organization-team/employee/[id].ts | 4 +++- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts b/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts index be85e2b01..0c36aa2ec 100644 --- a/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts +++ b/apps/web/app/hooks/features/useOrganizatioTeamsEmployee.ts @@ -8,9 +8,12 @@ import { useCallback } from 'react'; import { useQuery } from '../useQuery'; import { useOrganizationTeams } from './useOrganizationTeams'; import { editEmployeeOrderOrganizationTeamAPI } from '@app/services/client/api'; +import { userState } from '@app/stores'; +import { useRecoilState } from 'recoil'; export function useOrganizationEmployeeTeams() { const { loadTeamsData } = useOrganizationTeams(); + const [user] = useRecoilState(userState); const { loading: deleteOrganizationEmployeeTeamLoading, queryCall: deleteQueryCall } = useQuery( deleteOrganizationEmployeeTeamAPI @@ -66,15 +69,21 @@ export function useOrganizationEmployeeTeams() { const updateOrganizationTeamEmployeeOrderOnList = useCallback( (employee: OT_Member, order: number) => { - updateOrderCall(employee.id, { - order - }).then((res) => { + updateOrderCall( + employee.id, + { + order, + organizationTeamId: employee.organizationTeamId, + organizationId: employee.organizationId + }, + user?.tenantId || '' + ).then((res) => { loadTeamsData(); return res; }); }, - [loadTeamsData, updateOrderCall] + [loadTeamsData, updateOrderCall, user] ); const updateOrganizationTeamEmployeeActiveTask = useCallback( diff --git a/apps/web/app/services/client/api/organization-team.ts b/apps/web/app/services/client/api/organization-team.ts index 49178b3e5..cf339caad 100644 --- a/apps/web/app/services/client/api/organization-team.ts +++ b/apps/web/app/services/client/api/organization-team.ts @@ -93,8 +93,14 @@ export function removeEmployeeOrganizationTeamAPI(employeeId: string) { return api.delete(`/organization-team/employee/${employeeId}`); } -export function editEmployeeOrderOrganizationTeamAPI(employeeId: string, data: { order: number }) { - return api.put>(`/organization-team/employee/${employeeId}`, data); +export function editEmployeeOrderOrganizationTeamAPI( + employeeId: string, + data: { order: number; organizationTeamId: string; organizationId: string }, + tenantId?: string +) { + return api.put>(`/organization-team/employee/${employeeId}`, data, { + headers: { 'Tenant-Id': tenantId } + }); } export function removeUserFromAllTeamAPI(userId: string) { diff --git a/apps/web/app/services/server/requests/organization-team.ts b/apps/web/app/services/server/requests/organization-team.ts index c2279a1de..38e66bff2 100644 --- a/apps/web/app/services/server/requests/organization-team.ts +++ b/apps/web/app/services/server/requests/organization-team.ts @@ -176,20 +176,27 @@ export function addEmployeeOrganizationTeamOrderRequest({ employeeId, bearer_token, tenantId, - order + order, + organizationTeamId, + organizationId }: { employeeId: string; bearer_token: string; tenantId: string; order: number; + organizationTeamId: string; + organizationId: string; }) { - return serverFetch({ + console.log({ order, tenantId, employeeId }); + const res = serverFetch({ path: `/organization-team-employee/${employeeId}`, method: 'PUT', bearer_token, - body: { order }, + body: { order, organizationTeamId, organizationId }, tenantId }); + res.then((d) => console.log(d.data)); + return res; } export function removeUserFromAllTeam({ diff --git a/apps/web/pages/api/organization-team/employee/[id].ts b/apps/web/pages/api/organization-team/employee/[id].ts index 54c69aa4c..6ea6655f4 100644 --- a/apps/web/pages/api/organization-team/employee/[id].ts +++ b/apps/web/pages/api/organization-team/employee/[id].ts @@ -29,7 +29,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) bearer_token: access_token, tenantId, employeeId: id.toString(), - order + order, + organizationTeamId: req.body.organizationTeamId, + organizationId: req.body.organizationId }); break; } From 14829509078af197f912c5d58f843d8a4fe7490f Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Wed, 27 Dec 2023 18:33:33 +0200 Subject: [PATCH 21/24] fix: add ordered to cspell --- .cspell.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.cspell.json b/.cspell.json index 207b86a4c..48b44a18c 100644 --- a/.cspell.json +++ b/.cspell.json @@ -311,7 +311,8 @@ "plasmohq", "Proguard", "horcrux", - "dimesions" + "dimesions", + "Ordereds" ], "useGitignore": true, "ignorePaths": [ From 3a82ae0b4b5fe86c16289d93580a6714fd63b56b Mon Sep 17 00:00:00 2001 From: cedric karungu Date: Wed, 27 Dec 2023 18:51:20 +0200 Subject: [PATCH 22/24] feat: make order by drag and drop for managers only --- apps/web/lib/features/team-members-card-view.tsx | 4 ++-- apps/web/lib/features/team-members.tsx | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/web/lib/features/team-members-card-view.tsx b/apps/web/lib/features/team-members-card-view.tsx index 5f0049e85..ef7d78ea1 100644 --- a/apps/web/lib/features/team-members-card-view.tsx +++ b/apps/web/lib/features/team-members-card-view.tsx @@ -42,7 +42,7 @@ const TeamMembersCardView: React.FC = ({ } const handleChangeOrder = (employee: OT_Member, order: number) => { - console.log({ employee, order }); + console.log({ isTeamManager, employee, order }); updateOrganizationTeamEmployeeOrderOnList(employee, order); }; @@ -91,7 +91,7 @@ const TeamMembersCardView: React.FC = ({ member={member} publicTeam={publicTeam} currentExit={draggedOverTeamMember.current == i} - draggable + draggable={isTeamManager} onDragStart={() => { dragTeamMember.current = i; }} diff --git a/apps/web/lib/features/team-members.tsx b/apps/web/lib/features/team-members.tsx index 30200d94b..1d6287ecb 100644 --- a/apps/web/lib/features/team-members.tsx +++ b/apps/web/lib/features/team-members.tsx @@ -37,7 +37,6 @@ export function TeamMembers({ publicTeam = false, kanbanView: view = IssuesView. const $teamsFetching = teamsFetching && members.length === 0; let teamMembersView; - console.log($members); switch (true) { case members.length === 0: From ea7c6b1423fc1ec36c56354eff01de5fc8e8e99c Mon Sep 17 00:00:00 2001 From: Ruslan K Date: Wed, 27 Dec 2023 18:39:22 +0100 Subject: [PATCH 23/24] Update team-members-card-view.tsx --- apps/web/lib/features/team-members-card-view.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/web/lib/features/team-members-card-view.tsx b/apps/web/lib/features/team-members-card-view.tsx index ef7d78ea1..5c3f3df17 100644 --- a/apps/web/lib/features/team-members-card-view.tsx +++ b/apps/web/lib/features/team-members-card-view.tsx @@ -41,8 +41,7 @@ const TeamMembersCardView: React.FC = ({ handleChangeOrder(peopleClone[draggedOverTeamMember.current], dragTeamMember.current); } - const handleChangeOrder = (employee: OT_Member, order: number) => { - console.log({ isTeamManager, employee, order }); + const handleChangeOrder = (employee: OT_Member, order: number) => { updateOrganizationTeamEmployeeOrderOnList(employee, order); }; From 8151a3d6b97543819ec9fd338a8ede66a2703547 Mon Sep 17 00:00:00 2001 From: Ruslan K Date: Wed, 27 Dec 2023 18:40:55 +0100 Subject: [PATCH 24/24] Update [id].ts --- apps/web/pages/api/organization-team/employee/[id].ts | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/apps/web/pages/api/organization-team/employee/[id].ts b/apps/web/pages/api/organization-team/employee/[id].ts index 6ea6655f4..c23773bda 100644 --- a/apps/web/pages/api/organization-team/employee/[id].ts +++ b/apps/web/pages/api/organization-team/employee/[id].ts @@ -24,6 +24,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) employeeId: id.toString() }); break; + case 'PUT': await addEmployeeOrganizationTeamOrderRequest({ bearer_token: access_token, @@ -36,15 +37,5 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) break; } - // if (req.method !== 'DELETE' || !id) { - // return $res.status(405).json({}); - // } - - // await removeEmployeeOrganizationTeamRequest({ - // bearer_token: access_token, - // tenantId, - // employeeId: id.toString() - // }); - return; }