Skip to content

Commit 304f926

Browse files
authored
Merge pull request #2794 from tekdi/release-1.15.0
Release 1.15.0 to teacher prod
2 parents 987dbfc + 6eba434 commit 304f926

3 files changed

Lines changed: 61 additions & 52 deletions

File tree

apps/admin-app-repo/src/pages/user-instructor.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,12 +648,15 @@ const Facilitator = () => {
648648
block.centers?.forEach((center) => {
649649
center.batches?.forEach((batch) => {
650650
// Check if centerId exists in cohortData with active status
651-
const cohortCenterBatch = cohortData?.find(
651+
// Filter all entries for the same centerId and check if any has both statuses active
652+
const cohortCenterBatch = cohortData?.filter(
652653
(item: any) => item?.centerId === center.centerId && item?.batchId === batch.batchId
653654
);
654-
const isActiveCenterBatch =
655-
cohortCenterBatch?.cohortMember?.status === 'active' && cohortCenterBatch?.centerStatus === 'active' && cohortCenterBatch?.batchStatus === 'active';
656-
655+
const isActiveCenterBatch = cohortCenterBatch?.some(
656+
(cohortCenterBatchs: any) =>
657+
cohortCenterBatchs?.cohortMember?.status === 'active' && cohortCenterBatchs?.centerStatus === 'active' && cohortCenterBatchs?.batchStatus === 'active'
658+
);
659+
657660
// Only push if center has active cohortMember status
658661
if (isActiveCenterBatch) {
659662
const centerObject = {

apps/admin-app-repo/src/pages/user-leader.tsx

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ const UserLeader = () => {
132132
const searchStoreKey = 'teamLeader';
133133
const initialFormDataSearch =
134134
localStorage.getItem(searchStoreKey) &&
135-
localStorage.getItem(searchStoreKey) != '{}'
135+
localStorage.getItem(searchStoreKey) != '{}'
136136
? JSON.parse(localStorage.getItem(searchStoreKey))
137137
: localStorage.getItem('stateId')
138-
? { state: [localStorage.getItem('stateId')] }
139-
: {};
138+
? { state: [localStorage.getItem('stateId')] }
139+
: {};
140140

141141
useEffect(() => {
142142
if (response?.result?.totalCount !== 0) {
@@ -238,7 +238,7 @@ const UserLeader = () => {
238238

239239
// Update cohort member status for each selected center
240240
const membershipIds = selectedCenters.map((center) => center.cohortMembershipId);
241-
241+
242242
for (const membershipId of membershipIds) {
243243
try {
244244
const updateResponse = await updateCohortMemberStatus({
@@ -278,7 +278,7 @@ const UserLeader = () => {
278278
const resp = await updateUserTenantStatus(userID, tenantId, {
279279
status: 'active',
280280
});
281-
281+
282282
if (resp?.responseCode === 200) {
283283
showToastMessage(t('LEARNERS.ACTIVATE_USER_SUCCESS'), 'success');
284284
// Reset state
@@ -337,7 +337,7 @@ const UserLeader = () => {
337337
render: (row) =>
338338
`${transformLabel(row.firstName) || ''} ${
339339
transformLabel(row.middleName) || ''
340-
} ${transformLabel(row.lastName) || ''}`.trim(),
340+
} ${transformLabel(row.lastName) || ''}`.trim(),
341341
},
342342
{
343343
keys: ['age'],
@@ -358,7 +358,7 @@ const UserLeader = () => {
358358
const block = transformLabel(row?.customfield?.block) || '';
359359
return `${state == '' ? '' : `${state}`}${
360360
district == '' ? '' : `, ${district}`
361-
}${block == '' ? '' : `, ${block}`}`;
361+
}${block == '' ? '' : `, ${block}`}`;
362362
},
363363
},
364364
{
@@ -499,11 +499,14 @@ const UserLeader = () => {
499499
district.blocks?.forEach((block) => {
500500
block.centers?.forEach((center) => {
501501
// Check if centerId exists in cohortData with active status
502-
const cohortCenter = cohortData?.find(
502+
// Filter all entries for the same centerId and check if any has both statuses active
503+
const cohortCenters = cohortData?.filter(
503504
(item: any) => item?.centerId === center.centerId
504505
);
505-
const isActiveCenter =
506-
cohortCenter?.cohortMember?.status === 'active' && cohortCenter?.centerStatus === 'active';
506+
const isActiveCenter = cohortCenters?.some(
507+
(cohortCenter: any) =>
508+
cohortCenter?.cohortMember?.status === 'active' && cohortCenter?.centerStatus === 'active'
509+
);
507510

508511
// Only push if center has active cohortMember status
509512
if (isActiveCenter) {
@@ -565,12 +568,12 @@ const UserLeader = () => {
565568
setAvailableCenters([]);
566569
setLoadingCenters(true);
567570
setArchiveToActiveOpen(true);
568-
571+
569572
try {
570573
// Fetch cohort list for the user
571574
const cohortResponse = await getCohortList(selectedUserId);
572575
const cohortList = cohortResponse?.result || [];
573-
576+
574577
// Filter centers where cohortMemberStatus = "archived", cohortStatus = "active", and type = "CENTER" or "COHORT"
575578
// Filter and remove duplicates based on cohortId
576579
const filteredCenters = [];
@@ -587,7 +590,7 @@ const UserLeader = () => {
587590
}
588591
}
589592
}
590-
593+
591594
setAvailableCenters(filteredCenters);
592595
} catch (error) {
593596
console.error('Error fetching cohort list:', error);
@@ -1139,7 +1142,7 @@ const UserLeader = () => {
11391142
} else {
11401143
showToastMessage(
11411144
response?.data?.params?.errmsg ||
1142-
t(failureCreateMessage),
1145+
t(failureCreateMessage),
11431146
'error'
11441147
);
11451148
}
@@ -1151,7 +1154,7 @@ const UserLeader = () => {
11511154
console.error('Error creating cohort member:', error);
11521155
showToastMessage(
11531156
error?.response?.data?.params?.errmsg ||
1154-
t(failureCreateMessage),
1157+
t(failureCreateMessage),
11551158
'error'
11561159
);
11571160
} finally {
@@ -1312,7 +1315,7 @@ const UserLeader = () => {
13121315
console.error('Error creating cohort member:', error);
13131316
showToastMessage(
13141317
error?.response?.data?.params?.errmsg ||
1315-
t(failureCreateMessage),
1318+
t(failureCreateMessage),
13161319
'error'
13171320
);
13181321
} finally {
@@ -1398,21 +1401,21 @@ const UserLeader = () => {
13981401
try {
13991402
const { userData, customFields } =
14001403
splitUserData(userDetails);
1401-
1404+
14021405
delete userData.email;
1403-
1406+
14041407
const object = {
14051408
userData: userData,
14061409
customFields: customFields,
14071410
};
1408-
1411+
14091412
//update user details
14101413
const updateUserResponse = await updateUser(selectedUserIdEdit, object);
14111414
console.log(
14121415
'######### updatedResponse',
14131416
updateUserResponse
14141417
);
1415-
1418+
14161419
if (
14171420
updateUserResponse &&
14181421
updateUserResponse?.status == 200
@@ -1430,7 +1433,7 @@ const UserLeader = () => {
14301433
console.error('Error creating cohort member:', error);
14311434
showToastMessage(
14321435
error?.response?.data?.params?.errmsg ||
1433-
t(failureCreateMessage),
1436+
t(failureCreateMessage),
14341437
'error'
14351438
);
14361439
} finally {
@@ -1455,29 +1458,29 @@ const UserLeader = () => {
14551458
)}
14561459
</DialogContent>
14571460
<DialogActions sx={{ p: 2, borderTop: '1px solid #eee' }}>
1458-
<Button
1459-
sx={{
1460-
backgroundColor: '#FFC107',
1461-
color: '#000',
1462-
fontFamily: 'Poppins',
1463-
fontWeight: 500,
1464-
fontSize: '14px',
1465-
height: '40px',
1466-
lineHeight: '20px',
1467-
letterSpacing: '0.1px',
1468-
textAlign: 'center',
1469-
verticalAlign: 'middle',
1470-
'&:hover': {
1471-
backgroundColor: '#ffb300',
1472-
},
1473-
width: '100%',
1474-
}}
1475-
disabled={!selectedUserIdEdit || isEditInProgress}
1476-
form="dynamic-form-id"
1477-
type="submit"
1478-
>
1479-
{t('COMMON.SAVE')}
1480-
</Button>
1461+
<Button
1462+
sx={{
1463+
backgroundColor: '#FFC107',
1464+
color: '#000',
1465+
fontFamily: 'Poppins',
1466+
fontWeight: 500,
1467+
fontSize: '14px',
1468+
height: '40px',
1469+
lineHeight: '20px',
1470+
letterSpacing: '0.1px',
1471+
textAlign: 'center',
1472+
verticalAlign: 'middle',
1473+
'&:hover': {
1474+
backgroundColor: '#ffb300',
1475+
},
1476+
width: '100%',
1477+
}}
1478+
disabled={!selectedUserIdEdit || isEditInProgress}
1479+
form="dynamic-form-id"
1480+
type="submit"
1481+
>
1482+
{t('COMMON.SAVE')}
1483+
</Button>
14811484
</DialogActions>
14821485
</Dialog>
14831486

mfes/scp-teacher-repo/src/components/ManageUser.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -915,12 +915,15 @@ const ManageUser: React.FC<ManageUsersProps> = ({
915915
block.centers?.forEach((center) => {
916916
center.batches?.forEach((batch) => {
917917
// Check if centerId exists in cohortData with active status
918-
const cohortCenterBatch = cohortData?.find(
918+
// Filter all entries for the same centerId and check if any has both statuses active
919+
const cohortCenterBatch = cohortData?.filter(
919920
(item: any) => item?.centerId === center.centerId && item?.batchId === batch.batchId
920921
);
921-
const isActiveCenterBatch =
922-
cohortCenterBatch?.cohortMember?.status === 'active' && cohortCenterBatch?.centerStatus === 'active' && cohortCenterBatch?.batchStatus === 'active';
923-
922+
const isActiveCenterBatch = cohortCenterBatch?.some(
923+
(cohortCenterBatchs: any) =>
924+
cohortCenterBatchs?.cohortMember?.status === 'active' && cohortCenterBatchs?.centerStatus === 'active' && cohortCenterBatchs?.batchStatus === 'active'
925+
);
926+
924927
// Only push if center has active cohortMember status
925928
if (isActiveCenterBatch) {
926929
const centerObject = {

0 commit comments

Comments
 (0)