diff --git a/src/components/AddNewCenters.tsx b/src/components/AddNewCenters.tsx index b3d5d00e..d463ebd2 100644 --- a/src/components/AddNewCenters.tsx +++ b/src/components/AddNewCenters.tsx @@ -270,9 +270,9 @@ const AddNewCenters: React.FC = ({ setShowForm={setShowForm} /> - {dynamicFormForBlock && schema && uiSchema && selectedBlockCohortId && ( + {dynamicFormForBlock && schema && uiSchema && selectedBlockCohortId && ( <> - {showForm && ( + {showForm ? ( = ({ - )} + ) : null} )} {!selectedBlockCohortId && selectedBlockCohortId !== "" && ( diff --git a/src/components/DependentFields.tsx b/src/components/DependentFields.tsx index daa89bf4..18455a00 100644 --- a/src/components/DependentFields.tsx +++ b/src/components/DependentFields.tsx @@ -47,8 +47,8 @@ const DependentFields: React.FC = ({ const fieldsOfInterest = ['board', 'medium', 'grade', 'subject']; const fieldIds: { [key: string]: string } = {}; - data.fields.forEach((field: { name: string; fieldId: string }) => { - if (fieldsOfInterest.includes(field.name)) { + data?.fields?.forEach((field: { name: string; fieldId: string }) => { + if (fieldsOfInterest?.includes(field.name)) { fieldIds[field.name] = field.fieldId; } }); @@ -62,19 +62,19 @@ const DependentFields: React.FC = ({ if (fieldIds) { const arrangedData = { board: { - fieldId: fieldIds.board, + fieldId: fieldIds?.board, boardName: selectedBoard, }, medium: { - fieldId: fieldIds.medium, + fieldId: fieldIds?.medium, mediumName: selectedMedium, }, grade: { - fieldId: fieldIds.grade, + fieldId: fieldIds?.grade, gradeName: selectedGrade, }, subject: { - fieldId: fieldIds.subject, + fieldId: fieldIds?.subject, subjectName: selectedSubjectLabel, }, };