Skip to content

Commit

Permalink
fix dropdowns in 'See plan' modal
Browse files Browse the repository at this point in the history
  • Loading branch information
CREDO23 committed Oct 2, 2024
1 parent 8c4eba2 commit 9ef979e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
7 changes: 6 additions & 1 deletion apps/web/lib/components/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Props = {
description?: string;
isOpen: boolean;
closeModal: () => void;
customCloseModal?: () => void;
className?: string;
alignCloseIcon?: boolean;
showCloseIcon?: boolean;
Expand All @@ -19,6 +20,7 @@ type Props = {
export function Modal({
isOpen,
closeModal,
customCloseModal,
children,
title,
titleClass,
Expand Down Expand Up @@ -54,7 +56,10 @@ export function Modal({
{description && <Dialog.Description>{description}</Dialog.Description>}
{showCloseIcon && (
<div
onClick={closeModal}
onClick={() => {
closeModal();
customCloseModal?.();
}}
className={`absolute ${
alignCloseIcon ? 'right-2 top-3' : 'right-3 top-3'
} md:right-2 md:top-3 cursor-pointer z-50`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@ export function AddTasksEstimationHoursModal(props: IAddTasksEstimationHoursModa
draft: false,
saved: false
});
const isTomorrowPlan = useMemo(
() =>
plan &&
new Date(moment().add(1, 'days').toDate()).toLocaleDateString('en') ==
new Date(plan.date).toLocaleDateString('en'),
[plan]
);

const canStartWorking = useMemo(() => {
const isTodayPlan =
Expand Down Expand Up @@ -260,8 +253,8 @@ export function AddTasksEstimationHoursModal(props: IAddTasksEstimationHoursModa
const StartWorkingButton = (
<Button
disabled={
(!isTomorrowPlan ? warning : false) || loading || timerStatus?.running
? planEditState.draft
(canStartWorking && warning) || loading || (canStartWorking && timerStatus?.running)
? planEditState.draft && !warning
? false
: true
: false
Expand All @@ -270,7 +263,7 @@ export function AddTasksEstimationHoursModal(props: IAddTasksEstimationHoursModa
type="submit"
className={clsxm(
'py-3 px-5 w-full rounded-md font-light flex items-center justify-center text-md dark:text-white',
(!isTomorrowPlan ? warning : false) && 'bg-gray-400'
canStartWorking && warning && 'bg-gray-400'
)}
onClick={handleSubmit}
>
Expand Down Expand Up @@ -704,21 +697,13 @@ function TaskCard(props: ITaskCardProps) {
if (plan && plan.id) {
await addTaskToPlan({ taskId: task.id }, plan.id);
} else {
if (plan) {
await createDailyPlan({
workTimePlanned: 0,
taskId: task.id,
date: new Date(moment(plan.date).format('YYYY-MM-DD')),
status: DailyPlanStatusEnum.OPEN,
tenantId: user?.tenantId ?? '',
employeeId: user?.employee.id,
organizationId: user?.employee.organizationId
});
} else if (selectedDate) {
const planDate = plan ? plan.date : selectedDate;

if (planDate) {
await createDailyPlan({
workTimePlanned: 0,
taskId: task.id,
date: new Date(moment(selectedDate).format('YYYY-MM-DD')),
date: new Date(moment(planDate).format('YYYY-MM-DD')),
status: DailyPlanStatusEnum.OPEN,
tenantId: user?.tenantId ?? '',
employeeId: user?.employee.id,
Expand Down Expand Up @@ -810,6 +795,12 @@ function TaskCard(props: ITaskCardProps) {
);
}

/**
* ----------------------------------------------------------------
* ----------------- TASK CARD ACTIONS -------------------
* ----------------------------------------------------------------
*/

interface ITaskCardActionsProps {
task: ITeamTask;
selectedPlan: IDailyPlan;
Expand Down Expand Up @@ -964,6 +955,12 @@ function TaskCardActions(props: ITaskCardActionsProps) {
);
}

/**
* ----------------------------------------------------------------
* ---------------- UNPLAN TASK ACTIONS ----------------
* ----------------------------------------------------------------
*/

interface IUnplanTaskProps {
taskId: string;
selectedPlanId: string;
Expand Down
7 changes: 6 additions & 1 deletion apps/web/lib/features/daily-plan/all-plans-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ export const AllPlansModal = memo(function AllPlansModal(props: IAllPlansModal)
}, [createDailyPlan, customDate, user?.employee.id, user?.employee.organizationId, user?.tenantId]);

return (
<Modal isOpen={isOpen} closeModal={handleCloseModal} className={clsxm('w-[36rem]')}>
<Modal
isOpen={isOpen}
customCloseModal={handleCloseModal}
closeModal={() => null}
className={clsxm('w-[36rem]')}
>
<Card className="w-full h-full overflow-hidden" shadow="custom">
<div className="w-full flex flex-col gap-3 ">
<div className="relative w-full h-12 flex items-center justify-center">
Expand Down

0 comments on commit 9ef979e

Please sign in to comment.