Skip to content

Commit b7cafa7

Browse files
committed
api change, count issue fixed
1 parent 19aa047 commit b7cafa7

File tree

2 files changed

+172
-71
lines changed

2 files changed

+172
-71
lines changed

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

Lines changed: 118 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ const ManageUser: React.FC<ManageUsersProps> = ({
639639
tenantStatus: [Status.ACTIVE],
640640
filters: {
641641
batch: mySelectedBatchIds,
642+
status: [Status.ACTIVE],
642643
},
643644
customfields: [
644645
'state',
@@ -1379,29 +1380,59 @@ const ManageUser: React.FC<ManageUsersProps> = ({
13791380
md={6}
13801381
lg={4}
13811382
key={user.userId}
1383+
sx={{ display: 'flex' }}
13821384
>
13831385
<Box
1384-
display={'flex'}
1385-
borderBottom={`1px solid ${theme.palette.warning['A100']}`}
1386-
width={'100%'}
1387-
justifyContent={'space-between'}
1388-
sx={{
1389-
cursor: 'pointer',
1390-
'@media (min-width: 600px)': {
1391-
border: `1px solid ${theme.palette.action.selected}`,
1392-
padding: '4px 10px',
1393-
borderRadius: '8px',
1394-
background:
1395-
theme.palette.warning['A400'],
1396-
},
1397-
}}
1386+
display={'flex'}
1387+
flexDirection={'column'}
1388+
borderBottom={`1px solid ${theme.palette.warning['A100']}`}
1389+
width={'100%'}
1390+
justifyContent={'space-between'}
1391+
sx={{
1392+
cursor: 'pointer',
1393+
height: '100%',
1394+
position: 'relative',
1395+
'@media (min-width: 600px)': {
1396+
border: `1px solid ${theme.palette.action.selected}`,
1397+
padding: '4px 10px',
1398+
borderRadius: '8px',
1399+
background:
1400+
theme.palette.warning['A400'],
1401+
},
1402+
}}
13981403
>
1404+
13991405
<Box
1400-
display="flex"
1401-
alignItems="center"
1402-
gap="5px"
1406+
sx={{
1407+
position: 'absolute',
1408+
top: '8px',
1409+
right: '8px',
1410+
zIndex: 1,
1411+
}}>
1412+
<MoreVertIcon
1413+
onClick={(event) => {
1414+
isMobile
1415+
? toggleDrawer(
1416+
'bottom',
1417+
true,
1418+
user
1419+
)(event)
1420+
: handleMenuOpen(event, user);
1421+
}}
1422+
sx={{
1423+
fontSize: '24px',
1424+
color: theme.palette.warning['300'],
1425+
cursor: 'pointer',
1426+
}}
1427+
/>
1428+
</Box>
1429+
<Box
1430+
display="flex"
1431+
alignItems="flex-start"
1432+
gap="5px"
1433+
flex={1}
14031434
>
1404-
<Box>
1435+
<Box sx={{ flex: 1, minWidth: 0 }}>
14051436
<CustomLink
14061437
className="word-break"
14071438
href="#"
@@ -1426,46 +1457,77 @@ const ManageUser: React.FC<ManageUsersProps> = ({
14261457
</Typography>
14271458
</CustomLink>
14281459
{/* Uncomment if batchnames to be displayed */}
1429-
<Box
1430-
sx={{
1431-
backgroundColor:
1432-
theme.palette.action.selected,
1433-
padding: '5px',
1434-
width: 'fit-content',
1435-
borderRadius: '5px',
1436-
fontSize: '12px',
1437-
fontWeight: '600',
1438-
color: 'black',
1439-
marginBottom: '10px',
1440-
}}
1441-
>
1442-
{user?.batchNames?.length > 0
1443-
? getBatchNames(user.batchNames)
1444-
: t(
1445-
'ATTENDANCE.NO_BATCHES_ASSIGNED'
1446-
)}
1447-
</Box>
1460+
<Box
1461+
sx={{
1462+
backgroundColor:
1463+
theme.palette.action.selected,
1464+
padding: '5px',
1465+
width: 'fit-content',
1466+
maxWidth: '100%',
1467+
borderRadius: '5px',
1468+
fontSize: '12px',
1469+
fontWeight: '600',
1470+
color: 'black',
1471+
marginBottom: '10px',
1472+
position: 'relative',
1473+
}}
1474+
>
1475+
<Box
1476+
ref={(el: HTMLElement | null) => {
1477+
if (!el) return;
1478+
1479+
// Use requestAnimationFrame to ensure styles are applied
1480+
requestAnimationFrame(() => {
1481+
if (!expandedBatchNames.has(user.userId)) {
1482+
// Check if content is actually truncated when collapsed
1483+
const isTruncated = el.scrollHeight > el.clientHeight;
1484+
setTruncatedBatchNames((prev) => {
1485+
const newSet = new Set(prev);
1486+
if (isTruncated) {
1487+
newSet.add(user.userId);
1488+
} else {
1489+
newSet.delete(user.userId);
1490+
}
1491+
return newSet;
1492+
});
1493+
}
1494+
// When expanded, keep it in truncated set so "Show less" button remains visible
1495+
});
1496+
}}
1497+
sx={{
1498+
display: '-webkit-box',
1499+
WebkitLineClamp: expandedBatchNames.has(user.userId) ? 'none' : 4,
1500+
WebkitBoxOrient: 'vertical',
1501+
overflow: expandedBatchNames.has(user.userId) ? 'visible' : 'hidden',
1502+
wordBreak: 'break-word',
1503+
}}
1504+
>
1505+
{user?.batchNames?.length > 0
1506+
? getBatchNames(user.batchNames)
1507+
: t(
1508+
'ATTENDANCE.NO_BATCHES_ASSIGNED'
1509+
)}
1510+
</Box>
1511+
{user?.batchNames?.length > 0 &&
1512+
getBatchNames(user.batchNames) &&
1513+
(truncatedBatchNames.has(user.userId) || expandedBatchNames.has(user.userId)) && (
1514+
<Typography
1515+
onClick={() => toggleBatchNamesExpanded(user.userId)}
1516+
sx={{
1517+
fontSize: '11px',
1518+
fontWeight: '600',
1519+
color: theme.palette.secondary.main,
1520+
cursor: 'pointer',
1521+
marginTop: '4px',
1522+
textDecoration: 'underline',
1523+
}}
1524+
>
1525+
{expandedBatchNames.has(user.userId) ? 'Show less' : 'Show more'}
1526+
</Typography>
1527+
)}
1528+
</Box>
14481529
</Box>
14491530
</Box>
1450-
<Box>
1451-
<MoreVertIcon
1452-
onClick={(event) => {
1453-
isMobile
1454-
? toggleDrawer(
1455-
'bottom',
1456-
true,
1457-
user
1458-
)(event)
1459-
: handleMenuOpen(event, user);
1460-
}}
1461-
sx={{
1462-
fontSize: '24px',
1463-
marginTop: '1rem',
1464-
color: theme.palette.warning['300'],
1465-
cursor: 'pointer',
1466-
}}
1467-
/>
1468-
</Box>
14691531
</Box>
14701532
</Grid>
14711533
))

mfes/scp-teacher-repo/src/pages/centers/[cohortId]/index.tsx

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
import {
23
formatSelectedDate,
34
getAfterDate,
@@ -33,7 +34,7 @@ import { getCohortDetails } from '@/services/CohortServices';
3334
import { getEventList } from '@/services/EventService';
3435
import reassignLearnerStore from '@/store/reassignLearnerStore';
3536
import { CustomField } from '@/utils/Interfaces';
36-
import { Role, Telemetry, sessionType } from '@/utils/app.constant';
37+
import { Role, Status, Telemetry, sessionType } from '@/utils/app.constant';
3738
import AddIcon from '@mui/icons-material/Add';
3839
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
3940
import CalendarMonthIcon from '@mui/icons-material/CalendarMonth';
@@ -78,6 +79,7 @@ import { setTimeout } from 'timers';
7879
import { isEliminatedFromBuild } from '../../../../featureEliminationUtil';
7980
import LearnerManage from '@/shared/LearnerManage/LearnerManage';
8081
import ManageUser from '@/components/ManageUser';
82+
import { HierarchicalSearchUserList } from '@shared-lib-v2/DynamicForm/services/CreateUserService';
8183

8284
let SessionCardFooter: ComponentType<any> | null = null;
8385
if (!isEliminatedFromBuild('SessionCardFooter', 'component')) {
@@ -349,28 +351,65 @@ const CohortPage = () => {
349351
const getCohortMemberList = async () => {
350352
if (cohortId) {
351353
try {
352-
const page = 0;
353-
const filters = { cohortId: cohortId };
354-
const facilitatorResponse = await getMyCohortFacilitatorList({
355-
filters,
356-
});
357-
if (facilitatorResponse?.result?.userDetails) {
354+
const bodyPayload = {
355+
limit: 1,
356+
offset: 0,
357+
role: [Role.TEACHER],
358+
tenantStatus: [Status.ACTIVE],
359+
filters: {
360+
batch: [cohortId],
361+
status: [Status.ACTIVE],
362+
},
363+
customfields: [
364+
'state',
365+
'district',
366+
'block',
367+
'village',
368+
'main_subject',
369+
'subject_taught',
370+
],
371+
sort: [
372+
"firstName",
373+
"asc"
374+
]
375+
};
376+
const facilitatorResponse = await HierarchicalSearchUserList(bodyPayload);
377+
if (facilitatorResponse?.totalCount) {
358378
setCohortFacilitatorListCount(
359-
facilitatorResponse?.result?.userDetails.length
379+
facilitatorResponse?.totalCount
360380
);
361381
} else setCohortFacilitatorListCount(0);
362382
} catch (error) {
363383
setCohortFacilitatorListCount(0);
364384
}
365385
try {
366-
const filters = { cohortId: cohortId };
367-
368-
const learnerResponse = await getMyCohortMemberList({
369-
filters,
370-
});
371-
if (learnerResponse?.result?.userDetails) {
386+
const bodyPayload = {
387+
limit: 1,
388+
offset: 0,
389+
role: [Role.STUDENT],
390+
tenantStatus: [Status.ACTIVE],
391+
filters: {
392+
batch: [cohortId],
393+
status: [Status.ACTIVE],
394+
},
395+
customfields: [
396+
'state',
397+
'district',
398+
'block',
399+
'village',
400+
'main_subject',
401+
'subject_taught',
402+
],
403+
sort: [
404+
"firstName",
405+
"asc"
406+
]
407+
};
408+
409+
const learnerResponse = await HierarchicalSearchUserList(bodyPayload);
410+
if (learnerResponse?.totalCount) {
372411
setCohortLearnerListCount(
373-
learnerResponse?.result?.userDetails.filter((user: any) => user.status !== "reassigned").length
412+
learnerResponse?.totalCount
374413
);
375414
} else {
376415
setCohortLearnerListCount(0);

0 commit comments

Comments
 (0)