Skip to content

Commit

Permalink
Issue #0000 chore: data mapping chnaged according to api response for…
Browse files Browse the repository at this point in the history
… search api
  • Loading branch information
suvarnakale committed Jun 20, 2024
1 parent 894c322 commit 96f2901
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/pages/attendance-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
})
Expand Down
13 changes: 5 additions & 8 deletions src/pages/attendance-overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ const AttendanceOverview: React.FC<AttendanceOverviewProps> = () => {
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,
};
});
Expand All @@ -218,11 +218,8 @@ const AttendanceOverview: React.FC<AttendanceOverviewProps> = () => {
// 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'
);
Expand Down
11 changes: 4 additions & 7 deletions src/pages/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,13 @@ const Dashboard: React.FC<DashboardProps> = () => {
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);
Expand Down

0 comments on commit 96f2901

Please sign in to comment.