Skip to content

Commit

Permalink
Merge pull request #132 from Aar-if/newFixes
Browse files Browse the repository at this point in the history
Issue #PS-1677 feat: Teaching Centers Page Inconsistencies
  • Loading branch information
itsvick authored Aug 12, 2024
2 parents 3c0f1d9 + 52f9feb commit 0f2c82b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
27 changes: 20 additions & 7 deletions src/components/CohortSelectionSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,22 @@ const CohortSelectionSection: React.FC<CohortSelectionSectionProps> = ({
} else if (response[0].type === cohortHierarchy.BLOCK) {
setBlockName(response[0].name || response[0].cohortName);
const filteredData = response[0].childData
?.map((item: any) => ({
cohortId: item?.cohortId,
parentId: item?.parentId,
name: item?.cohortName || item?.name,
}))
?.map((item: any) => {
const typeOfCohort = item?.customField?.find(
(field: any) => field?.label === 'TYPE_OF_COHORT'
)?.value;

return {
cohortId: item?.cohortId,
parentId: item?.parentId,
name: item?.cohortName || item?.name,
typeOfCohort: typeOfCohort || (t('ATTENDANCE.N/A')),
};
})
?.filter(Boolean);

console.log(filteredData);

setCohortsData(filteredData);

if (filteredData.length > 0) {
Expand Down Expand Up @@ -333,7 +343,10 @@ const CohortSelectionSection: React.FC<CohortSelectionSectionProps> = ({
},
}}
IconComponent={(props) => (
<ArrowDropDownIcon {...props} style={{ color: 'black' }} />
<ArrowDropDownIcon
{...props}
style={{ color: 'black' }}
/>
)}
>
{cohortsData?.length !== 0 ? (
Expand All @@ -348,7 +361,7 @@ const CohortSelectionSection: React.FC<CohortSelectionSectionProps> = ({
textTransform: 'capitalize',
}}
>
{cohort.name}
{cohort.name} ({cohort?.typeOfCohort})
</MenuItem>
))
) : (
Expand Down
13 changes: 7 additions & 6 deletions src/components/ManageUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,18 @@ const ManageUser: React.FC<ManageUsersProps> = ({
const cohortList = await getCohortList(userId);
console.log('Cohort List:', cohortList);

if (cohortList && cohortList?.length > 0) {
const hasActiveCohorts = cohortList && cohortList.length > 0 && cohortList.some((cohort: { status: string; }) => cohort.status === 'active');

if (hasActiveCohorts) {
const cohortNames = cohortList
.map((cohort: { cohortName: any }) => cohort?.cohortName)
.filter((cohort: { status: string }) => cohort.status === 'active')
.map((cohort: { cohortName: string }) => cohort.cohortName)
.join(', ');

setOpenRemoveUserModal(true);
setRemoveCohortNames(cohortNames);
} else {
console.log(
'User does not belong to any cohorts, proceed with deletion'
);
console.log('User does not belong to any cohorts, proceed with deletion');
setOpenDeleteUserModal(true);
}

Expand Down
1 change: 1 addition & 0 deletions src/utils/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export interface UpdateCustomField {
order: number;
}
export interface ICohort {
typeOfCohort: string;
presentPercentage: number;
cohortId: string;
name: string;
Expand Down

0 comments on commit 0f2c82b

Please sign in to comment.