dashboard refactor phase 3: extract home dashboard view-model helpers#3342
Draft
ChristopherChudzicki wants to merge 2 commits into
Draft
dashboard refactor phase 3: extract home dashboard view-model helpers#3342ChristopherChudzicki wants to merge 2 commits into
ChristopherChudzicki wants to merge 2 commits into
Conversation
OpenAPI ChangesNo changes detected Unexpected changes? Ensure your branch is up-to-date with |
560ffef to
7e6bfe7
Compare
Move home-only data orchestration out of the home dashboard component and into a typed composer (private function in HomeEnrollmentsDisplay.tsx) that calls named pure helpers from model/dashboardViewModel.ts. New pure helpers in dashboardViewModel.ts (with unit tests): bucketAndSortHomeEnrollments, enrollmentCourseIsInPrograms, groupModuleCoursesByProgramId, getModuleCourseIdsFromPrograms, getNonContractProgramEnrollments, getTopLevelProgramEnrollments, isProgramAsCourse, isNonContractEnrollment. ProgramEnrollmentDisplay's two inline reduces (enrollmentsByCourseId, programEnrollmentsById) now use the simplified helpers added in Phase 1. Drop the dead courses parameter from groupCourseRunEnrollmentsByCourseId — its filter never tripped because both callers only look up by ids the helper would have included. Soften the plan's "zero inline transforms" exit check across Phases 3-5 to "no inline-defined domain logic" — composing a named predicate or comparator with .filter() is glue, not orchestration. Add an Open question noting Phase 3 inlined useHomeDashboardData as a private function rather than its own file; Phase 4/5 settle the hook location and test strategy before they begin. Rename ProgramContent.test.tsx's mock testid enrollment-display → program-enrollment-display for clarity now that two dashboards exist. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
cc6c776 to
d812730
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
#3341 should be merged first
What are the relevant tickets?
For https://github.com/mitodl/hq/issues/11205
Description (What does it do?)
This PR refactors HomeEnrollmentsDisplay by extracting utils (its bucketing, filtering, grouping, and deduplication logic) into dedicated pure helper functions. The component is now much thinner, mostly composing utils. A private useHomeDashboardData hook handles query orchestration and assembles the render-ready data shape.
Tests: Intentionally split:
dashboardViewModel.test.tsnew unit tests for the utilsHomeEnrollmentsDisplay.test.tsx: All the original integration / UI tests remain in place unchanged, two addedHow can this be tested?
HomeEnrollmentsDisplay, particularlyuseHomeDashboardData. Hopefully it's easier to understand.