Skip to content

Commit

Permalink
feat: remove task from plan
Browse files Browse the repository at this point in the history
  • Loading branch information
GloireMutaliko21 committed May 9, 2024
1 parent e3d2dd1 commit 642ebb0
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apps/web/lib/features/task/daily-plan/future-tasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function FutureTasks({ dayPlans, profile }: { dayPlans: IDailyPlan[]; pro
{formatDayPlanDate(plan.date.toString())} ({plan.tasks?.length})
</div>
</AccordionTrigger>
<AccordionContent className="bg-light--theme border-none dark:bg-dark--theme pb-12">
<AccordionContent className="bg-light--theme border-none dark:bg-dark--theme pb-[5rem]">
{/* Plan header */}
<PlanHeader plan={plan} planMode="Outstanding" />

Expand All @@ -48,6 +48,8 @@ export function FutureTasks({ dayPlans, profile }: { dayPlans: IDailyPlan[]; pro
type="HORIZONTAL"
taskBadgeClassName={`rounded-sm`}
taskTitleClassName="mt-[0.0625rem]"
plan={plan}
planMode="Future Tasks"
/>
))}
</ul>
Expand Down
54 changes: 52 additions & 2 deletions apps/web/lib/features/task/task-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { secondsToTime } from '@app/helpers';
import {
I_TeamMemberCardHook,
I_UserProfilePage,
useDailyPlan,
useModal,
useOrganizationEmployeeTeams,
useOrganizationTeams,
Expand All @@ -13,7 +14,16 @@ import {
useTeamTasks,
useTimerView
} from '@app/hooks';
import { IClassName, IDailyPlanMode, IOrganizationTeamList, ITeamTask, Nullable, OT_Member } from '@app/interfaces';
import {
IClassName,
ICreateDailyPlan,
IDailyPlan,
IDailyPlanMode,
IOrganizationTeamList,
ITeamTask,
Nullable,
OT_Member
} from '@app/interfaces';
import { timerSecondsState } from '@app/stores';
import { clsxm } from '@app/utils';
import { Popover, Transition } from '@headlessui/react';
Expand Down Expand Up @@ -53,6 +63,7 @@ type Props = {
setEditTaskId?: SetterOrUpdater<string | null>;
taskBadgeClassName?: string;
taskTitleClassName?: string;
plan?: IDailyPlan;
planMode?: FilterTabs;
} & IClassName;

Expand All @@ -69,6 +80,7 @@ export function TaskCard(props: Props) {
profile,
taskBadgeClassName,
taskTitleClassName,
plan,
planMode
} = props;
const t = useTranslations();
Expand Down Expand Up @@ -198,6 +210,7 @@ export function TaskCard(props: Props) {
memberInfo={memberInfo}
viewType={viewType}
profile={profile}
plan={plan}
planMode={planMode}
/>
)}
Expand Down Expand Up @@ -251,7 +264,13 @@ export function TaskCard(props: Props) {
<ActiveTaskStatusDropdown task={task || null} onChangeLoading={(load) => setLoading(load)} />

{task && currentMember && (
<TaskCardMenu task={task} loading={loading} memberInfo={memberInfo} viewType={viewType} />
<TaskCardMenu
task={task}
loading={loading}
memberInfo={memberInfo}
viewType={viewType}
plan={plan}
/>
)}
</div>
</Card>
Expand Down Expand Up @@ -433,13 +452,15 @@ function TaskCardMenu({
memberInfo,
viewType,
profile,
plan,
planMode
}: {
task: ITeamTask;
loading?: boolean;
memberInfo?: I_TeamMemberCardHook;
viewType: 'default' | 'unassign' | 'dailyplan';
profile?: I_UserProfilePage;
plan?: IDailyPlan;
planMode?: FilterTabs;
}) {
const t = useTranslations();
Expand Down Expand Up @@ -529,6 +550,16 @@ function TaskCardMenu({
{viewType === 'dailyplan' && planMode === 'Outstanding' && (
<AddTaskToPlanComponent employee={profile?.member} task={task} />
)}

{viewType === 'dailyplan' &&
(planMode === 'Today Tasks' || planMode === 'Future Tasks') && (
<div>
<Divider type="HORIZONTAL" />
<div className="mt-2">
<RemoveTaskFromPlan task={task} plan={plan} />
</div>
</div>
)}
{/* <li>
<ConfirmDropdown
className="right-[110%] top-0"
Expand Down Expand Up @@ -609,3 +640,22 @@ export function AddTaskToPlanComponent({ task, employee }: { task: ITeamTask; em
</span>
);
}

export function RemoveTaskFromPlan({ task, plan }: { task: ITeamTask; plan?: IDailyPlan }) {
const { removeTaskFromPlan } = useDailyPlan();
const data: Partial<ICreateDailyPlan> = { taskId: task.id };
const onClick = () => {
removeTaskFromPlan(data, plan?.id ?? '');
};
return (
<span
className={clsxm(
'font-normal whitespace-nowrap transition-all text-red-600',
'hover:font-semibold hover:transition-all cursor-pointer'
)}
onClick={onClick}
>
Remove from this plan
</span>
);
}
2 changes: 2 additions & 0 deletions apps/web/lib/features/user-profile-plans.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ function AllPlans({
type="HORIZONTAL"
taskBadgeClassName={`rounded-sm`}
taskTitleClassName="mt-[0.0625rem]"
planMode={currentTab === 'Today Tasks' ? 'Today Tasks' : undefined}
plan={plan}
/>
))}
</ul>
Expand Down

0 comments on commit 642ebb0

Please sign in to comment.