diff --git a/web/components/cycles/sidebar.tsx b/web/components/cycles/sidebar.tsx index c99ad9519..fa7fef008 100644 --- a/web/components/cycles/sidebar.tsx +++ b/web/components/cycles/sidebar.tsx @@ -273,10 +273,11 @@ export const CycleDetailsSidebar: React.FC = observer((props) => { ); - const endDate = new Date(cycleDetails.end_date ?? ""); - const startDate = new Date(cycleDetails.start_date ?? ""); + const endDate = new Date(watch("end_date") ?? cycleDetails.end_date ?? ""); + const startDate = new Date(watch("start_date") ?? cycleDetails.start_date ?? ""); - const areYearsEqual = startDate.getFullYear() === endDate.getFullYear(); + const areYearsEqual = + startDate.getFullYear() === endDate.getFullYear() || isNaN(startDate.getFullYear()) || isNaN(endDate.getFullYear()); const currentCycle = CYCLE_STATUS.find((status) => status.value === cycleStatus); @@ -355,7 +356,7 @@ export const CycleDetailsSidebar: React.FC = observer((props) => { @@ -380,10 +381,10 @@ export const CycleDetailsSidebar: React.FC = observer((props) => { handleStartDateChange(val); } }} - startDate={watch("start_date") ? `${watch("start_date")}` : null} - endDate={watch("end_date") ? `${watch("end_date")}` : null} + startDate={watch("start_date") ?? watch("end_date") ?? null} + endDate={watch("end_date") ?? watch("start_date") ?? null} maxDate={new Date(`${watch("end_date")}`)} - selectsStart + selectsStart={watch("end_date") ? true : false} /> @@ -393,9 +394,9 @@ export const CycleDetailsSidebar: React.FC = observer((props) => { <> {areYearsEqual ? renderShortDate(endDate, "_ _") : renderShortMonthDate(endDate, "_ _")} @@ -418,10 +419,10 @@ export const CycleDetailsSidebar: React.FC = observer((props) => { handleEndDateChange(val); } }} - startDate={watch("start_date") ? `${watch("start_date")}` : null} - endDate={watch("end_date") ? `${watch("end_date")}` : null} + startDate={watch("start_date") ?? watch("end_date") ?? null} + endDate={watch("end_date") ?? watch("start_date") ?? null} minDate={new Date(`${watch("start_date")}`)} - selectsEnd + selectsEnd={watch("start_date") ? true : false} /> diff --git a/web/components/modules/sidebar-select/select-lead.tsx b/web/components/modules/sidebar-select/select-lead.tsx index 8729b12f4..f675925c4 100644 --- a/web/components/modules/sidebar-select/select-lead.tsx +++ b/web/components/modules/sidebar-select/select-lead.tsx @@ -13,12 +13,13 @@ import { PROJECT_MEMBERS } from "constants/fetch-keys"; type Props = { value: string | null | undefined; onChange: (val: string) => void; + disabled?: boolean; }; const projectMemberService = new ProjectMemberService(); export const SidebarLeadSelect: FC = (props) => { - const { value, onChange } = props; + const { value, onChange, disabled = false } = props; // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; @@ -51,6 +52,7 @@ export const SidebarLeadSelect: FC = (props) => {
= (props) => { ) : (
No lead - + {!disabled && }
) } diff --git a/web/components/modules/sidebar-select/select-members.tsx b/web/components/modules/sidebar-select/select-members.tsx index b1d926d2e..28b173388 100644 --- a/web/components/modules/sidebar-select/select-members.tsx +++ b/web/components/modules/sidebar-select/select-members.tsx @@ -13,12 +13,13 @@ import { PROJECT_MEMBERS } from "constants/fetch-keys"; type Props = { value: string[] | undefined; onChange: (val: string[]) => void; + disabled?: boolean; }; // services const projectMemberService = new ProjectMemberService(); -export const SidebarMembersSelect: React.FC = ({ value, onChange }) => { +export const SidebarMembersSelect: React.FC = ({ value, onChange, disabled = false }) => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; @@ -48,6 +49,7 @@ export const SidebarMembersSelect: React.FC = ({ value, onChange }) => {
= ({ value, onChange }) => { ) : (
No members - + {!disabled && }
) } diff --git a/web/components/modules/sidebar.tsx b/web/components/modules/sidebar.tsx index ea7acfbaa..f2db5dbd5 100644 --- a/web/components/modules/sidebar.tsx +++ b/web/components/modules/sidebar.tsx @@ -245,10 +245,11 @@ export const ModuleDetailsSidebar: React.FC = observer((props) => { ); - const startDate = new Date(moduleDetails.start_date ?? ""); - const endDate = new Date(moduleDetails.target_date ?? ""); + const startDate = new Date(watch("start_date") ?? moduleDetails.start_date ?? ""); + const endDate = new Date(watch("target_date") ?? moduleDetails.target_date ?? ""); - const areYearsEqual = startDate.getFullYear() === endDate.getFullYear(); + const areYearsEqual = + startDate.getFullYear() === endDate.getFullYear() || isNaN(startDate.getFullYear()) || isNaN(endDate.getFullYear()); const moduleStatus = MODULE_STATUS.find((status) => status.value === moduleDetails.status); @@ -316,7 +317,7 @@ export const ModuleDetailsSidebar: React.FC = observer((props) => { customButton={ = observer((props) => { @@ -372,10 +373,10 @@ export const ModuleDetailsSidebar: React.FC = observer((props) => { handleStartDateChange(val); } }} - startDate={watch("start_date") ? `${watch("start_date")}` : null} - endDate={watch("target_date") ? `${watch("target_date")}` : null} + startDate={watch("start_date") ?? watch("target_date") ?? null} + endDate={watch("target_date") ?? watch("start_date") ?? null} maxDate={new Date(`${watch("target_date")}`)} - selectsStart + selectsStart={watch("target_date") ? true : false} /> @@ -385,7 +386,7 @@ export const ModuleDetailsSidebar: React.FC = observer((props) => { <> @@ -409,10 +410,10 @@ export const ModuleDetailsSidebar: React.FC = observer((props) => { handleEndDateChange(val); } }} - startDate={watch("start_date") ? `${watch("start_date")}` : null} - endDate={watch("target_date") ? `${watch("target_date")}` : null} + startDate={watch("start_date") ?? watch("target_date") ?? null} + endDate={watch("target_date") ?? watch("start_date") ?? null} minDate={new Date(`${watch("start_date")}`)} - selectsEnd + selectsEnd={watch("start_date") ? true : false} /> @@ -434,6 +435,7 @@ export const ModuleDetailsSidebar: React.FC = observer((props) => { name="lead" render={({ field: { value } }) => ( { submitChanges({ lead: val }); @@ -446,6 +448,7 @@ export const ModuleDetailsSidebar: React.FC = observer((props) => { name="members" render={({ field: { value } }) => ( { submitChanges({ members: val });