You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
frontend/src/components/PanelViews.tsx is 1,665 lines and, like RoleDashboards.tsx (#136), renders a different screen depending on which nav item is active (if (panel === 'reports') { ... }, if (panel === 'districts') { ... }, etc. — about 20 of these).
This one is harder than #136 and needs some design thought before jumping in, so it's not broken into ready-to-go sub-issues yet the way #136 was. Read this whole issue before starting.
Why it's harder than the RoleDashboards split
RoleDashboards.tsx's 8 dashboards are fully independent — no shared code between them. PanelViews.tsx is different: at the top of the component there's a shared block of state, data-fetching, and helper functions that almost every panel branch below it depends on — things like:
students, schools, usersList, reportsList, teachersList (the fetched/fallback data)
Various useState/useEffect hooks for search, filters, selected student, etc.
If you just cut a panel branch out into its own file, it'll break unless you also pass all the shared stuff it needs in as props (or find some other way to share it, e.g. a custom hook).
What needs to happen first (do this before moving any panel)
Read through PanelViews.tsx top to bottom and list, for each panel branch, which of the shared variables/functions/state it actually uses (many panels only need 2-3 of them, not all).
Design a shared pattern — the simplest is probably a custom hook (e.g. usePanelData(token, currentUser)) that returns { students, schools, usersList, reportsList, teachersList, getDistrictStats, getBlockStats }, which every extracted panel file can call.
Propose the design (a short comment on this issue, or a small draft PR) before doing the full extraction — this is the part most worth a second pair of eyes.
How to check your work (once you get to actually moving panels)
cd frontend && npm run lint — no errors.
npm run build — succeeds.
Run npm run dev and click through every panel for every role that can see it — confirm identical behavior to before (this file has more panels reachable by more roles than RoleDashboards, so there's more to check).
Not in scope here
No behavior or logic changes — this is purely about making the file smaller and easier to navigate, not changing what anything does.
What this is for
frontend/src/components/PanelViews.tsxis 1,665 lines and, likeRoleDashboards.tsx(#136), renders a different screen depending on which nav item is active (if (panel === 'reports') { ... },if (panel === 'districts') { ... }, etc. — about 20 of these).This one is harder than #136 and needs some design thought before jumping in, so it's not broken into ready-to-go sub-issues yet the way #136 was. Read this whole issue before starting.
Why it's harder than the RoleDashboards split
RoleDashboards.tsx's 8 dashboards are fully independent — no shared code between them.PanelViews.tsxis different: at the top of the component there's a shared block of state, data-fetching, and helper functions that almost every panel branch below it depends on — things like:students,schools,usersList,reportsList,teachersList(the fetched/fallback data)getDistrictStats(stateCode),getBlockStats(districtCode)(aggregation helpers)useState/useEffecthooks for search, filters, selected student, etc.If you just cut a panel branch out into its own file, it'll break unless you also pass all the shared stuff it needs in as props (or find some other way to share it, e.g. a custom hook).
What needs to happen first (do this before moving any panel)
PanelViews.tsxtop to bottom and list, for each panel branch, which of the shared variables/functions/state it actually uses (many panels only need 2-3 of them, not all).usePanelData(token, currentUser)) that returns{ students, schools, usersList, reportsList, teachersList, getDistrictStats, getBlockStats }, which every extracted panel file can call.How to check your work (once you get to actually moving panels)
cd frontend && npm run lint— no errors.npm run build— succeeds.npm run devand click through every panel for every role that can see it — confirm identical behavior to before (this file has more panels reachable by more roles than RoleDashboards, so there's more to check).Not in scope here
No behavior or logic changes — this is purely about making the file smaller and easier to navigate, not changing what anything does.