diff --git a/src/pages/attendance-history.tsx b/src/pages/attendance-history.tsx index a5f8bb2d..6ea62289 100644 --- a/src/pages/attendance-history.tsx +++ b/src/pages/attendance-history.tsx @@ -129,14 +129,14 @@ const UserAttendanceHistory = () => { const extractedNames = resp?.results?.cohortDetails; const filteredData = extractedNames ?.map((item: any) => { - const stateNameField = item?.cohortData?.customFields.find( + const stateNameField = item?.customFields.find( (field: any) => field.label === 'State Name' ); const stateName = stateNameField ? stateNameField.value : ''; return { - cohortId: item?.cohortData?.cohortId, - name: item?.cohortData?.name, + cohortId: item?.cohortId, + name: item?.name, state: stateName, }; }) diff --git a/src/pages/attendance-overview.tsx b/src/pages/attendance-overview.tsx index 3255947c..8dbc0542 100644 --- a/src/pages/attendance-overview.tsx +++ b/src/pages/attendance-overview.tsx @@ -200,14 +200,14 @@ const AttendanceOverview: React.FC = () => { const cohortDetails = response?.cohortDetails || []; const filteredData = cohortDetails?.map((item: any) => { - const stateNameField = item?.cohortData?.customFields.find( + const stateNameField = item?.customFields.find( (field: any) => field.label === 'State Name' ); const stateName = stateNameField ? stateNameField.value : ''; return { - cohortId: item?.cohortData?.cohortId, - name: toPascalCase(item?.cohortData?.name), + cohortId: item?.cohortId, + name: toPascalCase(item?.name), state: stateName, }; }); @@ -218,11 +218,8 @@ const AttendanceOverview: React.FC = () => { // setClassId(filteredData[0].cohortId); // add state name to localstorage - if ( - cohortDetails?.length > 0 && - cohortDetails?.[0].cohortData.customFields - ) { - const customFields = cohortDetails?.[0].cohortData.customFields; + if (cohortDetails?.length > 0 && cohortDetails?.[0].customFields) { + const customFields = cohortDetails?.[0].customFields; const stateNameField = customFields?.find( (field: any) => field.label === 'State Name' ); diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index 81d5fd45..8813ea12 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -149,16 +149,13 @@ const Dashboard: React.FC = () => { const resp = await cohortList({ limit, page, filters }); const extractedNames = resp?.results?.cohortDetails; - localStorage.setItem( - 'parentCohortId', - extractedNames?.[0].cohortData.parentId - ); + localStorage.setItem('parentCohortId', extractedNames?.[0].parentId); const filteredData = extractedNames ?.map((item: any) => ({ - cohortId: item?.cohortData?.cohortId, - parentId: item?.cohortData?.parentId, - name: item?.cohortData?.name, + cohortId: item?.cohortId, + parentId: item?.parentId, + name: item?.name, })) ?.filter(Boolean); setCohortsData(filteredData);