From ff14552fd2a5b86f51b6e96871b2d052d568471d Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 12 Dec 2024 17:39:14 -0500 Subject: [PATCH] fix: conditional select in useSubscriptions based on BFF select --- src/components/app/data/utils.js | 11 +++++++++++ .../main-content/course-enrollments/data/hooks.js | 9 +++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/app/data/utils.js b/src/components/app/data/utils.js index fa32b56c5..05d5f1344 100644 --- a/src/components/app/data/utils.js +++ b/src/components/app/data/utils.js @@ -165,6 +165,14 @@ export function determineEnterpriseCustomerUserForDisplay({ * hasCanceledAssignments: Boolean, * acceptedAssignments: Array, * hasAcceptedAssignments: Boolean, +* expiredAssignments: Array, +* hasExpiredAssignments: Boolean, +* erroredAssignments: Array, +* hasErroredAssignments: Boolean, +* reversedAssignments: Array, +* hasReversedAssignments: Boolean, +* assignmentsForDisplay: Array, +* hasAssignmentsForDisplay: Boolean * }} */ export function getAssignmentsByState(assignments = []) { @@ -208,6 +216,7 @@ export function getAssignmentsByState(assignments = []) { const hasCanceledAssignments = canceledAssignments.length > 0; const hasExpiredAssignments = expiredAssignments.length > 0; const hasErroredAssignments = erroredAssignments.length > 0; + const hasReversedAssignments = reversedAssignments.length > 0; // Concatenate all assignments for display (includes allocated and canceled assignments) assignmentsForDisplay.push(...allocatedAssignments); @@ -228,6 +237,8 @@ export function getAssignmentsByState(assignments = []) { hasExpiredAssignments, erroredAssignments, hasErroredAssignments, + reversedAssignments, + hasReversedAssignments, assignmentsForDisplay, hasAssignmentsForDisplay, }; diff --git a/src/components/dashboard/main-content/course-enrollments/data/hooks.js b/src/components/dashboard/main-content/course-enrollments/data/hooks.js index 2804f9054..3c6e4b47e 100644 --- a/src/components/dashboard/main-content/course-enrollments/data/hooks.js +++ b/src/components/dashboard/main-content/course-enrollments/data/hooks.js @@ -160,8 +160,13 @@ export const useCourseUpgradeData = ({ // Metadata required to allow upgrade via applicable subscription license const { data: subscriptionLicense } = useSubscriptions({ - select: ({ transformed }) => { - const license = transformed?.subscriptionLicense; + select: (data) => { + let license; + if (data.transformed) { + license = data.transformed.subscriptionLicense; + } else { + license = data?.subscriptionLicense; + } const isLicenseActivated = !!(license?.status === LICENSE_STATUS.ACTIVATED); const isSubscriptionPlanCurrent = !!license?.subscriptionPlan.isCurrent; if (!isLicenseActivated || !isSubscriptionPlanCurrent) {