From a444292114624754f47c1cd89140c3e1309356e8 Mon Sep 17 00:00:00 2001 From: Tze Zhe Brandon Lim Date: Wed, 10 Apr 2024 17:35:06 -0400 Subject: [PATCH] change condition for disabling button --- packages/frontend/components/Plan/AddPlanModal.tsx | 12 +++++++----- packages/frontend/components/Plan/EditPlanModal.tsx | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/frontend/components/Plan/AddPlanModal.tsx b/packages/frontend/components/Plan/AddPlanModal.tsx index 3a3a0d52a..8f74b54df 100644 --- a/packages/frontend/components/Plan/AddPlanModal.tsx +++ b/packages/frontend/components/Plan/AddPlanModal.tsx @@ -161,11 +161,13 @@ export const AddPlanModal: React.FC = ({ yearSupportedMajors?.[majorName ?? ""]?.verified ?? false; const isValidForm = - title && - catalogYear && - majorName && - (!isConcentrationRequired || concentration) && - (!isValidatedMajor ? agreeToBetaMajor : true); + (title && + catalogYear && + majorName && + (!isConcentrationRequired || concentration) && + (!isValidatedMajor ? agreeToBetaMajor : true)) || + // Valid plan for no major selected + (title && isNoMajorSelected); const noMajorHelperLabel = ( diff --git a/packages/frontend/components/Plan/EditPlanModal.tsx b/packages/frontend/components/Plan/EditPlanModal.tsx index 95697a2a8..fe9034cff 100644 --- a/packages/frontend/components/Plan/EditPlanModal.tsx +++ b/packages/frontend/components/Plan/EditPlanModal.tsx @@ -131,11 +131,13 @@ export const EditPlanModal: React.FC = ({ plan }) => { yearSupportedMajors?.[majorName ?? ""]?.verified ?? false; const isValidForm = - title && - catalogYear && - majorName && - (!isConcentrationRequired || concentration) && - (!isValidatedMajor ? agreeToBetaMajor : true); + (title && + catalogYear && + majorName && + (!isConcentrationRequired || concentration) && + (!isValidatedMajor ? agreeToBetaMajor : true)) || + // Valid plan for no major selected + (title && isNoMajorSelected); const onSubmitHandler = async (payload: UpdatePlanDto) => { // no submitting till the curr plan has been fetched