Skip to content

Commit

Permalink
feat: add planned vs estimations check & warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
CREDO23 committed Aug 26, 2024
1 parent 0aaf688 commit 999f3ce
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,39 @@ export function AddTasksEstimationHoursModal(props: IAddTasksEstimationHoursModa
const handleCloseModal = useCallback(() => {
localStorage.setItem(TASKS_ESTIMATE_HOURS_MODAL_DATE, currentDate);
closeModal();
}, [closeModal, currentDate]);
startTimer();
}, [closeModal, currentDate, startTimer]);

const handleSubmit = useCallback(() => {
updateDailyPlan({ workTimePlanned }, plan.id ?? '');
startTimer();
handleCloseModal();
}, [handleCloseModal, plan.id, startTimer, updateDailyPlan, workTimePlanned]);
}, [handleCloseModal, plan.id, updateDailyPlan, workTimePlanned]);

const checkPlannedAndEstimateTimeDiff = useCallback(() => {
if (workTimePlanned) {
if (workTimePlanned > tasksEstimationTimes) {
setWarning(t('dailyPlan.planned_tasks_popup.warning.PLAN_MORE_TASKS'));
} else {
setWarning(t('dailyPlan.planned_tasks_popup.warning.OPTIMIZE_PLAN'));
}
} else {
setWarning(t('dailyPlan.planned_tasks_popup.warning.PLANNED_TIME'));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tasksEstimationTimes, workTimePlanned]);

useEffect(() => {
if (!workTimePlanned || workTimePlanned <= 0) {
setWarning(t('dailyPlan.planned_tasks_popup.warning.PLANNED_TIME'));
} else if (plan.tasks?.find((task) => !task.estimate)) {
setWarning(t('dailyPlan.planned_tasks_popup.warning.TASKS_ESTIMATION'));
} else if (Math.abs(workTimePlanned - tasksEstimationTimes) > 1) {
checkPlannedAndEstimateTimeDiff();
} else {
setWarning('');
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [workTimePlanned, tasksEstimationTimes, plan.tasks, myDailyPlans]);

// Put tasks without estimates at the top of the list
const sortedTasks = useMemo(
Expand Down Expand Up @@ -72,21 +98,10 @@ export function AddTasksEstimationHoursModal(props: IAddTasksEstimationHoursModa
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isOpen]);

useEffect(() => {
if (!workTimePlanned || workTimePlanned <= 0) {
setWarning(t('dailyPlan.planned_tasks_popup.warning.PLANNED_TIME'));
} else if (plan.tasks?.find((task) => !task.estimate)) {
setWarning(t('dailyPlan.planned_tasks_popup.warning.TASKS_ESTIMATION'));
} else {
setWarning('');
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [workTimePlanned, tasksEstimationTimes, plan.tasks, myDailyPlans]);

return (
<Modal isOpen={isOpen} closeModal={handleCloseModal} showCloseIcon={requirePlan ? false : true}>
<Card className="w-full" shadow="custom">
<div className="flex flex-col justify-between">
<div className="flex w-[32rem] flex-col justify-between">
<div className="mb-7">
<Text.Heading as="h3" className="mb-3 text-center">
{t('timer.todayPlanSettings.TITLE')}
Expand Down Expand Up @@ -115,21 +130,30 @@ export function AddTasksEstimationHoursModal(props: IAddTasksEstimationHoursModa
</div>
<div className="text-sm flex flex-col gap-3">
<div className="text-sm flex flex-col gap-3">
<span>
{t('timer.todayPlanSettings.TASKS_WITH_NO_ESTIMATIONS')}{' '}
<span className="text-red-600">*</span>
</span>
<div className="w-full flex items-center justify-between gap-2">
<div className="flex items-center justify-center gap-1">
<span>Tasks</span>
<span className="text-red-600">*</span>
</div>
<div className="flex items-center justify-center gap-1">
<span>Total estimate:</span>
<span className=" font-medium">
{tasksEstimationTimes.toFixed(1)}
{' h'}
</span>
</div>
</div>
<div className="flex flex-col gap-1">
{sortedTasks.map((task, index) => (
<TaskCard key={index} task={task} />
))}
</div>
</div>
<div className="flex gap-2 items-center h-6 text-red-500">
<div className="flex gap-2 text-sm h-6 text-red-500">
{warning && (
<>
<PiWarningCircleFill className="text-2xl" />
<p>{warning}</p>
<PiWarningCircleFill />
<span>{warning}</span>
</>
)}
</div>
Expand Down Expand Up @@ -174,7 +198,7 @@ function TaskCard({ task }: ITaskCardProps) {
<Card
shadow="custom"
className={clsx(
'lg:flex items-center justify-between py-3 md:px-4 hidden min-h-[4.5rem] w-[30rem] h-[4.5rem] dark:bg-[#1E2025] border-[0.05rem] dark:border-[#FFFFFF0D] relative !text-xs cursor-pointer',
'lg:flex items-center justify-between py-3 md:px-4 hidden min-h-[4.5rem] w-full h-[4.5rem] dark:bg-[#1E2025] border-[0.05rem] dark:border-[#FFFFFF0D] relative !text-xs cursor-pointer',
task.id === activeTeamTask?.id && 'border-primary-light border-[0.15rem]'
)}
onClick={() => setActiveTask(task)}
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "يرجى إضافة الوقت المخطط",
"TASKS_ESTIMATION": "يرجى تقدير جميع المهام"
"TASKS_ESTIMATION": "يرجى تقدير جميع المهام",
"OPTIMIZE_PLAN": "الوقت المقدر الإجمالي يتجاوز الوقت المخطط له، يرجى تحسين خطتك",
"PLAN_MORE_TASKS": "يرجى إضافة المزيد من المهام إلى الخطة"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "Моля, добавете планираното време",
"TASKS_ESTIMATION": "Моля, оценете всички задачи"
"TASKS_ESTIMATION": "Моля, оценете всички задачи",
"OPTIMIZE_PLAN": "Общото прогнозирано време надвишава планираното време, моля оптимизирайте плана си",
"PLAN_MORE_TASKS": "Моля, добавете още задачи към плана"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "Bitte fügen Sie die geplante Zeit hinzu",
"TASKS_ESTIMATION": "Bitte schätzen Sie alle Aufgaben"
"TASKS_ESTIMATION": "Bitte schätzen Sie alle Aufgaben",
"OPTIMIZE_PLAN": "Die geschätzte Gesamtzeit übersteigt Ihre geplante Zeit, bitte optimieren Sie Ihren Plan",
"PLAN_MORE_TASKS": "Bitte fügen Sie dem Plan mehr Aufgaben hinzu"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "Please, add planned time",
"TASKS_ESTIMATION": "Please, estimate all tasks"
"TASKS_ESTIMATION": "Please, estimate all tasks",
"OPTIMIZE_PLAN": "Total estimated time exceeds your Planned time, please optimize your plan",
"PLAN_MORE_TASKS": "Please add more tasks to the plan"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "Por favor, añade tiempo planificado",
"TASKS_ESTIMATION": "Por favor, estima todas las tareas"
"TASKS_ESTIMATION": "Por favor, estima todas las tareas",
"OPTIMIZE_PLAN": "El tiempo total estimado excede tu tiempo planificado, por favor optimiza tu plan",
"PLAN_MORE_TASKS": "Por favor, añade más tareas al plan"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "Veuillez ajouter le temps planifié",
"TASKS_ESTIMATION": "Veuillez estimer toutes les tâches"
"TASKS_ESTIMATION": "Veuillez estimer toutes les tâches",
"OPTIMIZE_PLAN": "Le temps total estimé dépasse votre temps planifié, veuillez optimiser votre plan",
"PLAN_MORE_TASKS": "Veuillez ajouter plus de tâches au plan"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "אנא הוסף זמן מתוכנן",
"TASKS_ESTIMATION": "אנא הערך את כל המשימות"
"TASKS_ESTIMATION": "אנא הערך את כל המשימות",
"OPTIMIZE_PLAN": "הזמן הכולל המשוער חורג מהזמן המתוכנן, אנא מיטב את התוכנית שלך",
"PLAN_MORE_TASKS": "אנא הוסף עוד משימות לתוכנית"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "Per favore, aggiungi il tempo pianificato",
"TASKS_ESTIMATION": "Per favore, stima tutte le attività"
"TASKS_ESTIMATION": "Per favore, stima tutte le attività",
"OPTIMIZE_PLAN": "Il tempo totale stimato supera il tempo pianificato, per favore ottimizza il tuo piano",
"PLAN_MORE_TASKS": "Per favore, aggiungi più attività al piano"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "Voeg alstublieft de geplande tijd toe",
"TASKS_ESTIMATION": "Schat alstublieft alle taken in"
"TASKS_ESTIMATION": "Schat alstublieft alle taken in",
"OPTIMIZE_PLAN": "De totale geschatte tijd overschrijdt uw geplande tijd, optimaliseer uw plan alstublieft",
"PLAN_MORE_TASKS": "Voeg alstublieft meer taken aan het plan toe"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "Proszę dodać planowany czas",
"TASKS_ESTIMATION": "Proszę oszacować wszystkie zadania"
"TASKS_ESTIMATION": "Proszę oszacować wszystkie zadania",
"OPTIMIZE_PLAN": "Całkowity szacowany czas przekracza planowany czas, proszę zoptymalizować swój plan",
"PLAN_MORE_TASKS": "Proszę dodać więcej zadań do planu"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "Por favor, adicione o tempo planejado",
"TASKS_ESTIMATION": "Por favor, estime todas as tarefas"
"TASKS_ESTIMATION": "Por favor, estime todas as tarefas",
"OPTIMIZE_PLAN": "O tempo total estimado excede o seu tempo planejado, por favor otimize seu plano",
"PLAN_MORE_TASKS": "Por favor, adicione mais tarefas ao plano"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "Пожалуйста, добавьте запланированное время",
"TASKS_ESTIMATION": "Пожалуйста, оцените все задачи"
"TASKS_ESTIMATION": "Пожалуйста, оцените все задачи",
"OPTIMIZE_PLAN": "Общее время оценки превышает запланированное время, пожалуйста, оптимизируйте ваш план",
"PLAN_MORE_TASKS": "Пожалуйста, добавьте больше задач в план"
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion apps/web/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,9 @@
"planned_tasks_popup": {
"warning": {
"PLANNED_TIME": "请添加计划时间",
"TASKS_ESTIMATION": "请估算所有任务"
"TASKS_ESTIMATION": "请估算所有任务",
"OPTIMIZE_PLAN": "总预计时间超过您的计划时间,请优化您的计划",
"PLAN_MORE_TASKS": "请在计划中添加更多任务"
}
}
},
Expand Down

0 comments on commit 999f3ce

Please sign in to comment.