Skip to content

Commit

Permalink
fix: conditional select in useSubscriptions based on BFF select
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz committed Dec 12, 2024
1 parent f371801 commit ff14552
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/components/app/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []) {
Expand Down Expand Up @@ -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);
Expand All @@ -228,6 +237,8 @@ export function getAssignmentsByState(assignments = []) {
hasExpiredAssignments,
erroredAssignments,
hasErroredAssignments,
reversedAssignments,
hasReversedAssignments,
assignmentsForDisplay,
hasAssignmentsForDisplay,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ff14552

Please sign in to comment.