Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add fetch courses-user endpoints #1303

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

kyleecodes
Copy link
Member

@kyleecodes kyleecodes commented Feb 10, 2025

Resolves #1223

What changes did you make and why did you make them?

(Delayed due to NextJS app router migration).
Previously, courses data was fetched as part of the larger getUser data payload on every page load via useTypedSelector. With this update, it's fetched separately only when needed on course and session pages, via new useGetUserCoursesQuery. This PR helps improve performance by reducing payload size of the main user endpoint, and provides a more focused course progress data function.

Changelog:

  • api.tsx: adds the GET request to the new endpoint courses-user, returns type Courses & generates a useGetUserCoursesQuery hook for components to use.
  • CoursesPage.tsx: fetches and courses-user data from useGetUserCoursesQuery, with skip condition for logged out users. Processes data the same as previous endpoint.
  • coursesSlice.tsx: adds new matcher that updates courses state when getUserCourses query is successful.
  • SessioProgressDisplay.tsx: migrated from useTypedSelector to useGetUserCoursesQuery to track session progress.
  • StoryblokCoursePage.tsx: similar updates as CoursesPage.tsx
  • StoryblokSessionPage.tsx: similar updates as CoursesPage.tsx

Testing:

  • courses-user called only on logged-in course and session pages.
  • UI & API response reflects correct progress course / session states (incl. empty, completed).
  • Rapid navigation between pages.
  • Slow network connection & API failure error handling.
  • Verify data in Redux store

To-Do:

  • Add to Storyblok pages after review.
  • Troubleshoot Cypress test course-session-behavior.
  • Troubleshoot pop-up not appearing after session completion

Did you run tests? Share screenshot of results:

Unit & integration pass, implementing unit tests for this in a separate issue.

How did you find us? (GitHub, Google search, social media, etc.):

N/A

- Updated frontend to call the new GET /courses_user endpoint on the course page.
- Added matchers in the coursesSlice to populate state with fetched data.
- New getUsersCourses endpoint in API client.

Purpose: These changes improve performance by reducing the payload size of the main user endpoint
and provides more focused course progress data.

To test: Run locally and verify /courses-user endpoint in Chrome devtools Network tab.
Copy link

vercel bot commented Feb 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
bloom-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2025 10:11pm

@kyleecodes kyleecodes self-assigned this Feb 10, 2025
@eleanorreem
Copy link
Contributor

@kyleecodes this looks good. I will approve once StoryblokSessionPage and StoryblokCoursePage also have the endpoint called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to fetch data using GET /courses_user endpoint
2 participants