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

[REFERENCE] feat: incrementally adopt Dashboard BFF API #1205

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adamstankiewicz
Copy link
Member

@adamstankiewicz adamstankiewicz commented Oct 10, 2024

Description

[Context] Tech Spec

  • Adds a new queryEnterpriseLearnerDashboardBFF to the queryKeyFactory, integrating with the new Dashboard BFF exposed via [REFERENCE] feat: introduce Gateway Aggregation / Backend-for-Frontend abstraction via LearnerPortalBFFAPIView enterprise-access#572.
  • In dashboardLoader, the existing ensureQueryData(queryEnterpriseCourseEnrollments) is now replaced with queryEnterpriseLearnerDashboardBFF, which returns the same enterprise course enrollments metadata in its API response.
  • In rootLoader, only executes the ensureQueryData(querySubscriptions) when not a page route configured with a BFF API endpoint. That is, since only the Dashboard page route has a BFF configured, all other page routes continue to work as normal (retrieving data from specific micro-services vs the BFF).
  • Updates useEnterpriseCourseEnrollments to compose a new hook useBaseEnterpriseCourseEnrollments. The new hook is responsible for determining which query config to to retrieve enterprise course enrollments. It does so via a resolveBFFQuery helper function that determines which BFF query is configured for any given route pattern. In practice, when on the Dashboard page route, useBaseEnterpriseCourseEnrollments will extract enterpriseCourseEnrollments from the BFF query; when on non-Dashboard page routes, useBaseEnterpriseCourseEnrollments will continue extracting enrollments from queryEnterpriseCourseEnrollments (independent query to enterprise_course_enrollments).
  • Updates useSubscriptions with a similar treatment as useBaseEnterpriseCourseEnrollments, described above. useSubscriptions will now extract subscriptions-related data from the BFF query for the current route, if configured; otherwise, falls back to current state querySubscriptions (independent query to learner-licenses).

Jira

ENT-9427

For all changes

  • Ensure adequate tests are in place (or reviewed existing tests cover changes)
  • Ensure English strings are marked for translation. See documentation for more details.

Only if submitting a visual change

  • Ensure to attach screenshots
  • Ensure to have UX team confirm screenshots

@@ -193,9 +193,59 @@ export async function activateOrAutoApplySubscriptionLicense({
return activatedOrAutoAppliedLicense;
}

export function transformSubscriptionsData(customerAgreement, subscriptionLicenses) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[inform] Abstracted from fetchSubscriptions below. Now re-used along with the BFF response, but these types of transforms should ultimately live in the BFF.

const subscriptionsQuery = querySubscriptions(enterpriseCustomer.uuid);
const enterpriseAppDataQueries = [
// Enterprise Customer User Subsidies
queryClient.ensureQueryData(subscriptionsQuery).then(async (subscriptionsData) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The queryClient.ensureQueryData(subscriptionsQuery).then(...) is now conditional based on which route the user is currently on and/or navigating to. If a BFF query is configured for the current page route, the existing fetching of learner-licenses directly is skipped in favor of relying on the BFF query instead (which should fetch the same data and perform the side effects as below).

@adamstankiewicz adamstankiewicz force-pushed the ags/poc-learner-portal-bff branch 4 times, most recently from 284b686 to d5ea4f5 Compare October 10, 2024 15:19
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.

1 participant