From b0199e6cfd9f36c2a9c69d75032b9fef2ff4207f Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Sat, 27 Jul 2024 19:50:00 +0200 Subject: [PATCH] fix: resolve conflits fix: resolve conflits fix: import modals from the root /features/dailyPlan/index.tsx --- .../daily-plan-enforce-planed-task-modal.tsx | 60 +++++++++++++++++++ apps/web/lib/features/daily-plan/index.ts | 5 +- apps/web/lib/features/timer/timer.tsx | 30 +++++++++- apps/web/locales/ar.json | 3 +- apps/web/locales/bg.json | 3 +- apps/web/locales/de.json | 3 +- apps/web/locales/en.json | 3 +- apps/web/locales/es.json | 3 +- apps/web/locales/fr.json | 3 +- apps/web/locales/he.json | 3 +- apps/web/locales/it.json | 3 +- apps/web/locales/nl.json | 3 +- apps/web/locales/pl.json | 3 +- apps/web/locales/pt.json | 3 +- apps/web/locales/ru.json | 3 +- apps/web/locales/zh.json | 3 +- 16 files changed, 117 insertions(+), 17 deletions(-) create mode 100644 apps/web/lib/features/daily-plan/daily-plan-enforce-planed-task-modal.tsx diff --git a/apps/web/lib/features/daily-plan/daily-plan-enforce-planed-task-modal.tsx b/apps/web/lib/features/daily-plan/daily-plan-enforce-planed-task-modal.tsx new file mode 100644 index 000000000..cf7ca5b30 --- /dev/null +++ b/apps/web/lib/features/daily-plan/daily-plan-enforce-planed-task-modal.tsx @@ -0,0 +1,60 @@ +import { useAuthenticateUser, useDailyPlan, useTimerView } from '@app/hooks'; +import { IDailyPlan, ITeamTask } from '@app/interfaces'; +import { Button, Card, Modal, Text } from 'lib/components'; +import { useTranslations } from 'next-intl'; +import { useCallback } from 'react'; + +interface IProps { + open: boolean; + closeModal: () => void; + task: ITeamTask; + plan: IDailyPlan; +} + +export function EnforcePlanedTaskModal(props: IProps) { + const { closeModal, task, open, plan } = props; + const t = useTranslations(); + const { addTaskToPlan, addTaskToPlanLoading } = useDailyPlan(); + const { startTimer } = useTimerView(); + const { user } = useAuthenticateUser(); + + const handleAddTaskToPlan = useCallback(() => { + if (user?.employee && task && plan.id) { + addTaskToPlan({ employeeId: user.employee.id, taskId: task.id }, plan.id).then(() => { + closeModal(); + startTimer(); + }); + } + }, [addTaskToPlan, closeModal, plan.id, startTimer, task, user?.employee]); + + return ( + + +
+ + {t('dailyPlan.SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN')} + +
+ + +
+
+
+
+ ); +} diff --git a/apps/web/lib/features/daily-plan/index.ts b/apps/web/lib/features/daily-plan/index.ts index 198a4d36b..7a5c3c9be 100644 --- a/apps/web/lib/features/daily-plan/index.ts +++ b/apps/web/lib/features/daily-plan/index.ts @@ -1,4 +1,5 @@ export * from './plans-work-time-and-estimate'; export * from './add-task-to-plan'; -export * from './daily-plan-compare-estimate-modal' -export * from './create-daily-plan-form-modal' +export * from './daily-plan-compare-estimate-modal'; +export * from './create-daily-plan-form-modal'; +export * from './daily-plan-enforce-planed-task-modal'; diff --git a/apps/web/lib/features/timer/timer.tsx b/apps/web/lib/features/timer/timer.tsx index 3677f3cac..2e86bf129 100644 --- a/apps/web/lib/features/timer/timer.tsx +++ b/apps/web/lib/features/timer/timer.tsx @@ -1,5 +1,5 @@ import { pad } from '@app/helpers'; -import { HostKeys, useDetectOS, useHotkeys, useModal, useTimerView } from '@app/hooks'; +import { HostKeys, useDetectOS, useHotkeys, useModal, useTeamTasks, useTimerView } from '@app/hooks'; import { IClassName, TimerSource } from '@app/interfaces'; import { clsxm } from '@app/utils'; import { ProgressBar, Text, Tooltip, VerticalSeparator } from 'lib/components'; @@ -15,12 +15,17 @@ import { } from '@heroicons/react/24/outline'; import { HotkeysEvent } from 'hotkeys-js'; import { useCallback, useMemo } from 'react'; -import { AddWorkTimeAndEstimatesToPlan } from '../daily-plan/plans-work-time-and-estimate'; import { ESTIMATE_POPUP_SHOWN_DATE, TODAY_PLAN_ALERT_SHOWN_DATE } from '@app/constants'; +import { EnforcePlanedTaskModal, AddWorkTimeAndEstimatesToPlan } from '../daily-plan'; export function Timer({ className }: IClassName) { const t = useTranslations(); const { closeModal, isOpen, openModal } = useModal(); + const { + isOpen: isEnforceTaskModalOpen, + closeModal: enforceTaskCloseModal, + openModal: enforceTaskOpenModal + } = useModal(); const { hours, minutes, @@ -37,6 +42,13 @@ export function Timer({ className }: IClassName) { isPlanVerified, hasPlan } = useTimerView(); + const { activeTeam, activeTeamTask } = useTeamTasks(); + const requirePlan = useMemo(() => activeTeam?.requirePlanToTrack, [activeTeam?.requirePlanToTrack]); + + const isActiveTaskPlaned = useMemo( + () => hasPlan?.tasks?.some((task) => task.id === activeTeamTask?.id), + [activeTeamTask?.id, hasPlan?.tasks] + ); const timerHanlderStartStop = useCallback(() => { const currentDate = new Date().toISOString().split('T')[0]; @@ -47,6 +59,8 @@ export function Timer({ className }: IClassName) { if (timerStatusFetching || !canRunTimer) return; if (timerStatus?.running) { stopTimer(); + } else if (requirePlan && !isActiveTaskPlaned) { + enforceTaskOpenModal(); } else { if (lastPlanPopupDate == currentDate && lastEstimatesPopupDate == currentDate) { startTimer(); @@ -63,10 +77,13 @@ export function Timer({ className }: IClassName) { } }, [ canRunTimer, + enforceTaskOpenModal, hasPlan?.tasks, hasPlan?.workTimePlanned, + isActiveTaskPlaned, isPlanVerified, openModal, + requirePlan, startTimer, stopTimer, timerStatus?.running, @@ -74,6 +91,7 @@ export function Timer({ className }: IClassName) { ]); const { os } = useDetectOS(); + const osSpecificTimerTooltipLabel = useMemo(() => { if (os === 'Mac') { if (!timerStatus?.running) { @@ -177,6 +195,14 @@ export function Timer({ className }: IClassName) { startTimer={startTimer} hasPlan={!!hasPlan} /> + {requirePlan && hasPlan && activeTeamTask && ( + + )} ); diff --git a/apps/web/locales/ar.json b/apps/web/locales/ar.json index b66b3e500..41f8bd956 100644 --- a/apps/web/locales/ar.json +++ b/apps/web/locales/ar.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "إزالة من هذه الخطة", "CREATE_A_PLAN_FOR_TODAY": "إنشاء خطة لليوم", "TODAY_PLAN_SUB_TITLE": "لا توجد خطة لليوم", - "DAILY_PLAN_DESCRIPTION": "'الخطة اليومية' تساعد في تنظيم عملية العمل لتحقيق أفضل النتائج" + "DAILY_PLAN_DESCRIPTION": "'الخطة اليومية' تساعد في تنظيم عملية العمل لتحقيق أفضل النتائج", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "لم تكن هذه المهمة مخططة لخطة اليوم. هل ترغب في إضافة شيء إلى الخطة؟" }, "form": { "NAME_PLACEHOLDER": "أدخل اسمك", diff --git a/apps/web/locales/bg.json b/apps/web/locales/bg.json index 5970bb2ae..a3010903b 100644 --- a/apps/web/locales/bg.json +++ b/apps/web/locales/bg.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "Премахни от този план", "CREATE_A_PLAN_FOR_TODAY": "Създайте план за днес", "TODAY_PLAN_SUB_TITLE": "Няма план за днес", - "DAILY_PLAN_DESCRIPTION": "'Дневният план' помага да се организира работният процес за постигане на най-добри резултати" + "DAILY_PLAN_DESCRIPTION": "'Дневният план' помага да се организира работният процес за постигане на най-добри резултати", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "Тази задача не беше планирана за днешния план. Искате ли да добавите към плана?" }, "form": { "NAME_PLACEHOLDER": "Въведете името си", diff --git a/apps/web/locales/de.json b/apps/web/locales/de.json index 7349dcf23..47d05249e 100644 --- a/apps/web/locales/de.json +++ b/apps/web/locales/de.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "Aus diesem Plan entfernen", "CREATE_A_PLAN_FOR_TODAY": "Erstellen Sie einen Plan für heute", "TODAY_PLAN_SUB_TITLE": "Es gibt keinen Plan für heute", - "DAILY_PLAN_DESCRIPTION": "'Tagesplan' hilft, den Arbeitsprozess zu organisieren, um die besten Ergebnisse zu erzielen" + "DAILY_PLAN_DESCRIPTION": "'Tagesplan' hilft, den Arbeitsprozess zu organisieren, um die besten Ergebnisse zu erzielen", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "Deze taak was niet gepland voor het plan van vandaag. Wilt u iets toevoegen aan het plan?" }, "form": { "NAME_PLACEHOLDER": "Ihren Namen eingeben", diff --git a/apps/web/locales/en.json b/apps/web/locales/en.json index a08dc0bc4..a5d42a25a 100644 --- a/apps/web/locales/en.json +++ b/apps/web/locales/en.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "Remove from this plan", "CREATE_A_PLAN_FOR_TODAY": "Create a Plan for Today", "TODAY_PLAN_SUB_TITLE": " There is no plan for Today", - "DAILY_PLAN_DESCRIPTION": "'Daily Plan' helps organize the work process to achieve the best results" + "DAILY_PLAN_DESCRIPTION": "'Daily Plan' helps organize the work process to achieve the best results", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "This task was not planned for Today's plan. Would you like to add to the plan?" }, "form": { "NAME_PLACEHOLDER": "Enter your name", diff --git a/apps/web/locales/es.json b/apps/web/locales/es.json index 721947be3..c9b5074d6 100644 --- a/apps/web/locales/es.json +++ b/apps/web/locales/es.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "Eliminar de este plan", "CREATE_A_PLAN_FOR_TODAY": "Crear un plan para hoy", "TODAY_PLAN_SUB_TITLE": "No hay plan para hoy", - "DAILY_PLAN_DESCRIPTION": "'Plan diario' ayuda a organizar el proceso de trabajo para lograr los mejores resultados" + "DAILY_PLAN_DESCRIPTION": "'Plan diario' ayuda a organizar el proceso de trabajo para lograr los mejores resultados", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "Esta tarea no estaba prevista en el plan de hoy. ¿Te gustaría añadir algo al plan?" }, "form": { "NAME_PLACEHOLDER": "Ingresa tu nombre", diff --git a/apps/web/locales/fr.json b/apps/web/locales/fr.json index be3260e5a..5ffa6eb9f 100644 --- a/apps/web/locales/fr.json +++ b/apps/web/locales/fr.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "Retirer de ce plan", "CREATE_A_PLAN_FOR_TODAY": "Créer un plan pour aujourd'hui", "TODAY_PLAN_SUB_TITLE": "Il n'y a pas de plan pour aujourd'hui", - "DAILY_PLAN_DESCRIPTION": "'Plan quotidien' aide à organiser le processus de travail pour obtenir les meilleurs résultats" + "DAILY_PLAN_DESCRIPTION": "'Plan quotidien' aide à organiser le processus de travail pour obtenir les meilleurs résultats", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "Cette tâche n'était pas prévue dans le planning d'aujourd'hui. Souhaitez-vous l'ajouter au planning ?" }, "form": { "NAME_PLACEHOLDER": "Entrez votre nom", diff --git a/apps/web/locales/he.json b/apps/web/locales/he.json index c1ff34b50..c797130bf 100644 --- a/apps/web/locales/he.json +++ b/apps/web/locales/he.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "הסר מתוכנית זו", "CREATE_A_PLAN_FOR_TODAY": "צור תוכנית להיום", "TODAY_PLAN_SUB_TITLE": "אין תוכנית להיום", - "DAILY_PLAN_DESCRIPTION": "'תוכנית יומית' עוזרת לארגן את תהליך העבודה להשגת התוצאות הטובות ביותר" + "DAILY_PLAN_DESCRIPTION": "'תוכנית יומית' עוזרת לארגן את תהליך העבודה להשגת התוצאות הטובות ביותר", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "משימה זו לא תוכננה עבור התוכנית של היום. האם תרצה להוסיף לתוכנית?" }, "form": { "NAME_PLACEHOLDER": "הכנס את השם שלך", diff --git a/apps/web/locales/it.json b/apps/web/locales/it.json index e2f293952..910473648 100644 --- a/apps/web/locales/it.json +++ b/apps/web/locales/it.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "Rimuovi da questo piano", "CREATE_A_PLAN_FOR_TODAY": "Crea un piano per oggi", "TODAY_PLAN_SUB_TITLE": "Non c'è nessun piano per oggi", - "DAILY_PLAN_DESCRIPTION": "'Piano giornaliero' aiuta a organizzare il processo di lavoro per ottenere i migliori risultati" + "DAILY_PLAN_DESCRIPTION": "'Piano giornaliero' aiuta a organizzare il processo di lavoro per ottenere i migliori risultati", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "Questa attività non era pianificata per il piano di oggi. Vuoi aggiungerla al piano?" }, "form": { "NAME_PLACEHOLDER": "Inserisci il tuo nome", diff --git a/apps/web/locales/nl.json b/apps/web/locales/nl.json index 09aa6bbd5..0451bcc77 100644 --- a/apps/web/locales/nl.json +++ b/apps/web/locales/nl.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "Verwijder uit dit plan", "CREATE_A_PLAN_FOR_TODAY": "Maak een plan voor vandaag", "TODAY_PLAN_SUB_TITLE": "Er is geen plan voor vandaag", - "DAILY_PLAN_DESCRIPTION": "'Dagelijkse planning' helpt om het werkproces te organiseren om de beste resultaten te behalen" + "DAILY_PLAN_DESCRIPTION": "'Dagelijkse planning' helpt om het werkproces te organiseren om de beste resultaten te behalen", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "Diese Aufgabe war für den heutigen Plan nicht vorgesehen. Möchten Sie den Plan ergänzen?" }, "form": { "NAME_PLACEHOLDER": "Voer uw naam in", diff --git a/apps/web/locales/pl.json b/apps/web/locales/pl.json index b250d0bd4..9e33e82e3 100644 --- a/apps/web/locales/pl.json +++ b/apps/web/locales/pl.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "Usuń z tego planu", "CREATE_A_PLAN_FOR_TODAY": "Utwórz plan na dziś", "TODAY_PLAN_SUB_TITLE": "Brak planu na dziś", - "DAILY_PLAN_DESCRIPTION": "'Plan dnia' pomaga zorganizować proces pracy, aby osiągnąć najlepsze wyniki" + "DAILY_PLAN_DESCRIPTION": "'Plan dnia' pomaga zorganizować proces pracy, aby osiągnąć najlepsze wyniki", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "To zadanie nie było zaplanowane na dzisiejszy plan. Czy chcesz dodać do planu?" }, "form": { "NAME_PLACEHOLDER": "Wprowadź swoje imię", diff --git a/apps/web/locales/pt.json b/apps/web/locales/pt.json index c37ed080a..88d280439 100644 --- a/apps/web/locales/pt.json +++ b/apps/web/locales/pt.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "Remover deste plano", "CREATE_A_PLAN_FOR_TODAY": "Criar um plano para hoje", "TODAY_PLAN_SUB_TITLE": "Não há plano para hoje", - "DAILY_PLAN_DESCRIPTION": "'Plano diário' ajuda a organizar o processo de trabalho para obter os melhores resultados" + "DAILY_PLAN_DESCRIPTION": "'Plano diário' ajuda a organizar o processo de trabalho para obter os melhores resultados", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "Esta tarefa não foi planeada no plano de hoje. Gostaria de acrescentar ao plano?" }, "form": { "NAME_PLACEHOLDER": "Digite seu nome", diff --git a/apps/web/locales/ru.json b/apps/web/locales/ru.json index 5e7c31c81..ec5036f90 100644 --- a/apps/web/locales/ru.json +++ b/apps/web/locales/ru.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "Убрать из этого плана", "CREATE_A_PLAN_FOR_TODAY": "Создать план на сегодня", "TODAY_PLAN_SUB_TITLE": "На сегодня нет плана", - "DAILY_PLAN_DESCRIPTION": "'Ежедневный план' помогает организовать рабочий процесс для достижения наилучших результатов" + "DAILY_PLAN_DESCRIPTION": "'Ежедневный план' помогает организовать рабочий процесс для достижения наилучших результатов", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "Эта задача не была запланирована в плане на сегодня. Хотите добавить в план?" }, "form": { "NAME_PLACEHOLDER": "Введите ваше имя", diff --git a/apps/web/locales/zh.json b/apps/web/locales/zh.json index b547c5d2f..86f4dc55c 100644 --- a/apps/web/locales/zh.json +++ b/apps/web/locales/zh.json @@ -582,7 +582,8 @@ "REMOVE_FROM_THIS_PLAN": "从计划中移除", "CREATE_A_PLAN_FOR_TODAY": "为今天制定计划", "TODAY_PLAN_SUB_TITLE": "今天没有计划", - "DAILY_PLAN_DESCRIPTION": "'每日计划' 有助于组织工作流程以实现最佳结果" + "DAILY_PLAN_DESCRIPTION": "'每日计划' 有助于组织工作流程以实现最佳结果", + "SUGGESTS_TO_ADD_TASK_TO_TODAY_PLAN": "此任务未列入今日计划。要添加到计划中吗?" }, "form": { "NAME_PLACEHOLDER": "输入您的姓名",