-
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.
[fix]: Tab 'Outstanding' should have (#2687)
Estimated time (overall tasks); Total tasks (display how many)
- Loading branch information
1 parent
88332dd
commit 2ba0b09
Showing
11 changed files
with
444 additions
and
119 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
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,3 +1,7 @@ | ||
export * from './outstanding'; | ||
export * from './past-tasks'; | ||
export * from './future-tasks'; | ||
export * from './outstanding-all'; | ||
export * from './task-estimated-count'; | ||
export * from './outstanding-date'; | ||
export * from './task-estimated-count' |
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,50 @@ | ||
import { EmptyPlans } from 'lib/features/user-profile-plans'; | ||
import { TaskCard } from '../task-card'; | ||
import { useDailyPlan } from '@app/hooks'; | ||
import { TaskEstimatedcount } from '.'; | ||
|
||
interface OutstandingAll { | ||
profile: any, | ||
} | ||
export function OutstandingAll({ profile }: OutstandingAll) { | ||
const { outstandingPlans } = useDailyPlan(); | ||
const displayedTaskId = new Set(); | ||
return ( | ||
<div className="flex flex-col gap-6"> | ||
<TaskEstimatedcount outstandingPlans={outstandingPlans} /> | ||
{outstandingPlans?.length > 0 ? ( | ||
<> | ||
{outstandingPlans?.map((plan) => ( | ||
<> | ||
{/* <PlanHeader plan={plan} planMode="Outstanding" /> */} | ||
<ul className="flex flex-col gap-2"> | ||
{plan?.tasks?.map((task) => { | ||
//If the task is already displayed, skip it | ||
if (displayedTaskId.has(task.id)) { return null; } | ||
// Add the task to the Set to avoid displaying it again | ||
displayedTaskId.add(task.id); | ||
return <TaskCard | ||
key={`${task.id}${plan.id}`} | ||
isAuthUser={true} | ||
activeAuthTask={true} | ||
viewType={'dailyplan'} | ||
task={task} | ||
profile={profile} | ||
type="HORIZONTAL" | ||
taskBadgeClassName={`rounded-sm`} | ||
taskTitleClassName="mt-[0.0625rem]" | ||
planMode="Outstanding" | ||
/> | ||
} | ||
)} | ||
</ul> | ||
</> | ||
))} | ||
</> | ||
|
||
) : ( | ||
<EmptyPlans planMode="Outstanding" /> | ||
)} | ||
</div> | ||
); | ||
} |
61 changes: 61 additions & 0 deletions
61
apps/web/lib/features/task/daily-plan/outstanding-date.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,61 @@ | ||
import { formatDayPlanDate } from '@app/helpers'; | ||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@components/ui/accordion'; | ||
import { EmptyPlans, PlanHeader } from 'lib/features/user-profile-plans'; | ||
import { TaskCard } from '../task-card'; | ||
import { useDailyPlan } from '@app/hooks'; | ||
|
||
interface IOutstandingFieltreDate { | ||
profile: any | ||
} | ||
export function OutstandingFieltreDate({ profile }: IOutstandingFieltreDate) { | ||
Check warning on line 10 in apps/web/lib/features/task/daily-plan/outstanding-date.tsx GitHub Actions / Cspell
|
||
const { outstandingPlans } = useDailyPlan(); | ||
return ( | ||
<div className="flex flex-col gap-6"> | ||
{outstandingPlans?.length > 0 ? ( | ||
<Accordion | ||
type="multiple" | ||
className="text-sm" | ||
defaultValue={outstandingPlans?.map((plan) => new Date(plan.date).toISOString().split('T')[0])} | ||
> | ||
{outstandingPlans?.map((plan) => ( | ||
<AccordionItem | ||
value={plan.date.toString().split('T')[0]} | ||
key={plan.id} | ||
className="dark:border-slate-600" | ||
> | ||
<AccordionTrigger className="hover:no-underline"> | ||
<div className="text-lg"> | ||
{formatDayPlanDate(plan.date.toString())} ({plan.tasks?.length}) | ||
</div> | ||
</AccordionTrigger> | ||
<AccordionContent className="bg-light--theme border-none dark:bg-dark--theme pb-12"> | ||
{/* Plan header */} | ||
<PlanHeader plan={plan} planMode="Outstanding" /> | ||
|
||
{/* Plan tasks list */} | ||
<ul className="flex flex-col gap-2"> | ||
{plan.tasks?.map((task) => ( | ||
<TaskCard | ||
key={`${task.id}${plan.id}`} | ||
isAuthUser={true} | ||
activeAuthTask={true} | ||
viewType={'dailyplan'} | ||
task={task} | ||
profile={profile} | ||
type="HORIZONTAL" | ||
taskBadgeClassName={`rounded-sm`} | ||
taskTitleClassName="mt-[0.0625rem]" | ||
planMode="Outstanding" | ||
/> | ||
))} | ||
</ul> | ||
</AccordionContent> | ||
</AccordionItem> | ||
))} | ||
</Accordion> | ||
) : ( | ||
<EmptyPlans planMode="Outstanding" /> | ||
)} | ||
</div> | ||
); | ||
} |
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,58 +1,6 @@ | ||
import { formatDayPlanDate } from '@app/helpers'; | ||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@components/ui/accordion'; | ||
import { EmptyPlans, PlanHeader } from 'lib/features/user-profile-plans'; | ||
import { TaskCard } from '../task-card'; | ||
import { useDailyPlan } from '@app/hooks'; | ||
|
||
export function Outstanding({ profile }: { profile: any }) { | ||
const { outstandingPlans } = useDailyPlan(); | ||
return ( | ||
<div className="flex flex-col gap-6"> | ||
{outstandingPlans?.length > 0 ? ( | ||
<Accordion | ||
type="multiple" | ||
className="text-sm" | ||
defaultValue={outstandingPlans?.map((plan) => new Date(plan.date).toISOString().split('T')[0])} | ||
> | ||
{outstandingPlans?.map((plan) => ( | ||
<AccordionItem | ||
value={plan.date.toString().split('T')[0]} | ||
key={plan.id} | ||
className="dark:border-slate-600" | ||
> | ||
<AccordionTrigger className="hover:no-underline"> | ||
<div className="text-lg"> | ||
{formatDayPlanDate(plan.date.toString())} ({plan.tasks?.length}) | ||
</div> | ||
</AccordionTrigger> | ||
<AccordionContent className="bg-light--theme border-none dark:bg-dark--theme pb-12"> | ||
{/* Plan header */} | ||
<PlanHeader plan={plan} planMode="Outstanding" /> | ||
|
||
{/* Plan tasks list */} | ||
<ul className="flex flex-col gap-2"> | ||
{plan.tasks?.map((task) => ( | ||
<TaskCard | ||
key={`${task.id}${plan.id}`} | ||
isAuthUser={true} | ||
activeAuthTask={true} | ||
viewType={'dailyplan'} | ||
task={task} | ||
profile={profile} | ||
type="HORIZONTAL" | ||
taskBadgeClassName={`rounded-sm`} | ||
taskTitleClassName="mt-[0.0625rem]" | ||
planMode="Outstanding" | ||
/> | ||
))} | ||
</ul> | ||
</AccordionContent> | ||
</AccordionItem> | ||
))} | ||
</Accordion> | ||
) : ( | ||
<EmptyPlans planMode="Outstanding" /> | ||
)} | ||
</div> | ||
); | ||
interface IOutstanding { | ||
filtre?: any; | ||
} | ||
export function Outstanding({ filtre }: IOutstanding) { | ||
return (<>{filtre}</>); | ||
} |
44 changes: 44 additions & 0 deletions
44
apps/web/lib/features/task/daily-plan/task-estimated-count.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,44 @@ | ||
import { secondsToTime } from '@app/helpers'; | ||
import { IDailyPlan } from '@app/interfaces'; | ||
import { VerticalSeparator } from 'lib/components' | ||
import React from 'react' | ||
|
||
interface ITaskEstimatedcount { | ||
outstandingPlans: any[] | ||
} | ||
export function TaskEstimatedcount({ outstandingPlans }: ITaskEstimatedcount) { | ||
const element = outstandingPlans?.map((plan: IDailyPlan) => plan.tasks?.map((task) => task)); | ||
const { timesEstemated, totalTasks } = estimatedTotalTime(element || []); | ||
const { h: hour, m: minute } = secondsToTime((timesEstemated || 0)); | ||
return ( | ||
<div className='flex space-x-10'> | ||
<div className='flex space-x-2'> | ||
<span className='text-slate-600'>Estimated:</span> | ||
<span className='text-slate-900 font-semibold text-[12px]'>{hour}h{minute}m</span> | ||
</div> | ||
<VerticalSeparator className="border-slate-400" /> | ||
<div className='flex space-x-2'> | ||
<span className='text-slate-600'>Total tasks:</span> | ||
<span className='text-slate-900 font-semibold text-[12px]'>{totalTasks}</span> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
|
||
export function estimatedTotalTime(data: any) { | ||
// Flatten the data and reduce to calculate the sum of estimates without duplicates | ||
const uniqueTasks = data.flat().reduce((acc: any, task: any) => { | ||
if (!acc[task.id]) { | ||
acc[task.id] = task.estimate; | ||
} | ||
return acc; | ||
}, {}); | ||
|
||
// Calculate the total of estimates | ||
const timesEstemated = Object.values(uniqueTasks)?.reduce((total: number, estimate: any) => total + estimate, 0); | ||
// Calculate the total of tasks | ||
const totalTasks = Object.values(uniqueTasks)?.length; | ||
|
||
return { timesEstemated, totalTasks }; | ||
} |
Oops, something went wrong.