Skip to content

Commit 6aa4f85

Browse files
authored
Merge pull request #2846 from AkshataKatwal16/feat-attendance-revamp
Issue feat: Fix loader issue on scp dashboard
2 parents 0fff95e + b595ebe commit 6aa4f85

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ const CohortSelectionSection: React.FC<CohortSelectionSectionProps> = ({
415415
if (!response?.length) {
416416
setLoading(false);
417417
}
418+
// Guaranteed fallback: always reset loading after fetchCohorts
419+
// regardless of response type, to prevent infinite loader.
420+
setLoading(false);
418421
} catch (error) {
419422
console.error('Error fetching cohort list', error);
420423
setLoading(false);

mfes/scp-teacher-repo/src/pages/dashboard.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,6 @@ const Dashboard: React.FC<DashboardProps> = () => {
260260
setRole(role);
261261
const storedUserId = localStorage.getItem('userId');
262262
setClassId(localStorage.getItem('classId') ?? '');
263-
// #region agent log
264-
fetch('http://127.0.0.1:7242/ingest/d2b738fb-79d4-4559-93b3-73b712825063',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'dashboard.tsx:auth-check',message:'H-A: dashboard token check fired',data:{hasToken:!!token,hasRole:!!role,hasUserId:!!storedUserId,userProgram:localStorage.getItem('userProgram'),tenantName:localStorage.getItem('tenantName'),willRedirectToLogin:!token},timestamp:Date.now(),hypothesisId:'H-A'})}).catch(()=>{});
265-
// #endregion
266263
if (token) {
267264
setIsAuthenticated(true);
268265
setUserId(storedUserId);

mfes/scp-teacher-repo/src/services/CohortServices.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,18 @@ export const getCohortList = async (
7171
);
7272
let res = filtered;
7373

74+
// When role is not set in localStorage, default to Teacher behaviour so
75+
// that the flresponsetotl path reconstructs the proper center hierarchy
76+
// from BATCH-level parentIds instead of returning raw BATCH items.
77+
const effectiveRole = localStorage.getItem('role') ?? localStorage.getItem('roleName')
78+
7479
res = res.filter((block: any) => {
7580
if (
7681
block?.cohortStatus === Status.ACTIVE &&
7782
//if no center then also show in list only for facilitator
78-
((localStorage.getItem('role') === Role.TEACHER &&
83+
((effectiveRole === Role.TEACHER &&
7984
block?.childData.length > 0) ||
80-
localStorage.getItem('role') !== Role.TEACHER)
85+
effectiveRole !== Role.TEACHER)
8186
//
8287
) {
8388
return block;
@@ -95,7 +100,8 @@ export const getCohortList = async (
95100
});
96101
//patch for alter response for facilitator
97102
try {
98-
if (localStorage.getItem('role') === Role.TEACHER) {
103+
// Also call flresponsetotl when role is null (defaults to Teacher)
104+
if (effectiveRole === Role.TEACHER) {
99105
res = await flresponsetotl(res);
100106
// console.log('########## response', res);
101107
}

0 commit comments

Comments
 (0)