Skip to content

Commit

Permalink
Issue #PS-1456 feat: API integration for re-assign Learners
Browse files Browse the repository at this point in the history
  • Loading branch information
Aar-if committed Sep 3, 2024
1 parent 55a36b6 commit a8394d5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
34 changes: 17 additions & 17 deletions src/components/CohortLearnerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,23 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
filters,
});
const resp = response?.result?.userDetails;

if (resp) {
const userDetails = resp.map((user: any) => ({
name: toPascalCase(user.name),
userId: user.userId,
memberStatus: user.status,
statusReason: user.statusReason,
cohortMembershipId: user.cohortMembershipId,
enrollmentNumber: capitalizeEachWord(
getFieldValue(
user?.customField,
'fieldname',
'Enrollment Number',
'fieldvalues',
'-'
)
),
}));


const userDetails = resp.map((user: any) => {
const ageField = user.customField.find((field: { label: string }) => field.label === "AGE");
return {
name: toPascalCase(user?.name),
userId: user?.userId,
memberStatus: user?.status,
statusReason: user?.statusReason,
cohortMembershipId: user?.cohortMembershipId,
enrollmentNumber: user?.username,
age: ageField ? ageField.value : null, // Extract age for the specific user
};
});

console.log(`userDetails`, userDetails);
setUserData(userDetails);
}
Expand Down Expand Up @@ -117,6 +116,7 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
userId={data.userId}
learnerName={data.name}
enrollmentId={data.enrollmentNumber}
age={data.age}
cohortMembershipId={data.cohortMembershipId}
isDropout={data.memberStatus === Status.DROPOUT}
statusReason={data.statusReason}
Expand Down
14 changes: 13 additions & 1 deletion src/components/LearnersListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import reassignLearnerStore from '@/store/reassignLearnerStore';
import { bulkCreateCohortMembers } from '@/services/CohortServices';
import { capitalizeEachWord, filterMiniProfileFields } from '@/utils/Helper';
import { useMediaQuery } from '@mui/material';
import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord';

type Anchor = 'bottom';

Expand All @@ -46,6 +47,7 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
learnerName,
isDropout,
enrollmentId,
age,
cohortMembershipId,
statusReason,
reloadState,
Expand Down Expand Up @@ -561,7 +563,17 @@ const LearnersListItem: React.FC<LearnerListProps> = ({
color: theme.palette.warning['400'],
}}
>
{enrollmentId}
{age + ' y/o'}
</Box>
<FiberManualRecordIcon style={{ fontSize: '8px', color:'#CDC5BD' }} />
<Box
sx={{
fontSize: '14px',
fontWeight: '400',
color: theme.palette.warning['400'],
}}
>
{enrollmentId?.toUpperCase()}
</Box>
</>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/utils/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ export interface LearnerListProps {
type?: string;
userId: string;
isDropout: boolean;
enrollmentId?: string | number;
enrollmentId?: any;
age: string | number;
cohortMembershipId: string | number;
learnerName: string;
statusReason: string;
Expand Down

0 comments on commit a8394d5

Please sign in to comment.