-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Member cant track without plan (#2635)
* feat: popup add work time plan and estimated time to track time * feat: un estimated tasks popups when want tracking * feat: update unestimated tasks * feat: track time after provide all estimates time * refact: tasks to display onto un estimated * feat: update daily plan work time planned before start tracking * feat: start timer on task card require plan * fix: update planned time and estimates warning * fix: oauth env vars
- Loading branch information
1 parent
aa8c147
commit 4265b74
Showing
21 changed files
with
401 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
apps/web/lib/features/daily-plan/plans-work-time-and-estimate.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { PiWarningCircleFill } from 'react-icons/pi'; | ||
import { IDailyPlan, ITeamTask } from '@app/interfaces'; | ||
import { Card, InputField, Modal, Text, VerticalSeparator } from 'lib/components'; | ||
import { useTranslations } from 'use-intl'; | ||
import { TaskNameInfoDisplay } from '../task/task-displays'; | ||
import { Button } from '@components/ui/button'; | ||
import { TaskEstimate } from '../task/task-estimate'; | ||
import { useDailyPlan, useTeamTasks } from '@app/hooks'; | ||
|
||
export function AddWorkTimeAndEstimatesToPlan({ | ||
open, | ||
closeModal, | ||
plan, | ||
startTimer | ||
// employee | ||
}: { | ||
open: boolean; | ||
closeModal: () => void; | ||
startTimer: () => void; | ||
plan?: IDailyPlan; | ||
// employee?: OT_Member; | ||
}) { | ||
const t = useTranslations(); | ||
const [workTimePlanned, setworkTimePlanned] = useState<number | undefined>(plan?.workTimePlanned); | ||
|
||
useEffect(() => { | ||
if (typeof workTimePlanned === 'string') setworkTimePlanned(parseFloat(workTimePlanned)); | ||
}, [workTimePlanned]); | ||
|
||
const { updateDailyPlan } = useDailyPlan(); | ||
|
||
const { tasks: $tasks } = useTeamTasks(); | ||
|
||
const tasks = $tasks.filter((task) => | ||
plan?.tasks?.some((t) => task?.id === t.id && typeof task?.estimate === 'number' && task?.estimate <= 0) | ||
); | ||
|
||
const handleSubmit = () => { | ||
if (workTimePlanned === 0 || typeof workTimePlanned !== 'number') return; | ||
if (tasks.some((task) => task.estimate === 0)) return; | ||
|
||
updateDailyPlan({ workTimePlanned }, plan?.id ?? ''); | ||
startTimer(); | ||
closeModal(); | ||
}; | ||
|
||
return ( | ||
<Modal isOpen={open} closeModal={closeModal} className="w-[98%] md:w-[530px] relative"> | ||
<Card className="w-full" shadow="custom"> | ||
<div className="flex flex-col justify-between"> | ||
<div className="mb-7"> | ||
<Text.Heading as="h3" className="mb-3 text-center"> | ||
{t('timer.todayPlanSettings.TITLE')} | ||
</Text.Heading> | ||
</div> | ||
<div className="mb-7 w-full flex flex-col gap-4"> | ||
<span className="text-sm"> | ||
{t('timer.todayPlanSettings.WORK_TIME_PLANNED')} <span className="text-red-600">*</span> | ||
</span> | ||
<InputField | ||
type="number" | ||
placeholder={t('timer.todayPlanSettings.WORK_TIME_PLANNED_PLACEHOLDER')} | ||
className="mb-0 min-w-[350px]" | ||
wrapperClassName="mb-0 rounded-lg" | ||
onChange={(e) => setworkTimePlanned(parseFloat(e.target.value))} | ||
required | ||
defaultValue={plan?.workTimePlanned ?? 0} | ||
/> | ||
</div> | ||
|
||
{tasks.length > 0 && ( | ||
<div className="text-sm flex flex-col gap-3"> | ||
<UnEstimatedTasks dailyPlan={plan} /> | ||
|
||
<div className="flex gap-2 items-center text-red-500"> | ||
<PiWarningCircleFill className="text-2xl" /> | ||
<p>{t('timer.todayPlanSettings.WARNING_PLAN_ESTIMATION')}</p> | ||
</div> | ||
</div> | ||
)} | ||
|
||
<div className="mt-6 flex justify-between items-center"> | ||
<Button | ||
variant="outline" | ||
type="submit" | ||
className="py-3 px-5 rounded-md font-light text-md dark:text-white dark:bg-slate-700 dark:border-slate-600" | ||
onClick={closeModal} | ||
> | ||
{t('common.CANCEL')} | ||
</Button> | ||
<Button | ||
variant="default" | ||
type="submit" | ||
className="py-3 px-5 rounded-md font-light text-md dark:text-white" | ||
onClick={handleSubmit} | ||
> | ||
{t('timer.todayPlanSettings.START_WORKING_BUTTON')} | ||
</Button> | ||
</div> | ||
</div> | ||
</Card> | ||
</Modal> | ||
); | ||
} | ||
|
||
function UnEstimatedTasks({ dailyPlan }: { dailyPlan?: IDailyPlan }) { | ||
const t = useTranslations(); | ||
|
||
const { tasks: $tasks } = useTeamTasks(); | ||
|
||
const tasks = $tasks.filter((task) => | ||
dailyPlan?.tasks?.some((t) => task?.id === t.id && typeof task?.estimate === 'number' && task?.estimate <= 0) | ||
); | ||
|
||
return ( | ||
<div> | ||
{tasks?.length > 0 && ( | ||
<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="flex flex-col gap-1"> | ||
{tasks && tasks?.map((task) => <UnEstimatedTask key={task.id} task={task} />)} | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export function UnEstimatedTask({ task }: { task: ITeamTask }) { | ||
return ( | ||
<Card | ||
shadow="custom" | ||
className={ | ||
'lg:flex items-center justify-between py-3 px-4 md:px-4 hidden min-h-[4.5rem] dark:bg-[#1E2025] border-[0.05rem] dark:border-[#FFFFFF0D] relative !text-xs' | ||
} | ||
> | ||
<div className="min-w-[50%] max-w-[50%]"> | ||
<TaskNameInfoDisplay task={task} /> | ||
</div> | ||
<VerticalSeparator /> | ||
{/* <TaskEstimateInput memberInfo={memberInfo} edition={taskEdition} /> */} | ||
<TaskEstimate _task={task} /> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './outstanding'; | ||
export * from './past-tasks'; | ||
export * from './future-tasks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.