Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ner-portal-enterprise into bilalqamar95/jest-v29-upgrade
  • Loading branch information
BilalQamar95 committed Sep 18, 2024
2 parents 28cd8bb + b2a91d6 commit a66dfb2
Show file tree
Hide file tree
Showing 43 changed files with 684 additions and 225 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Adding new check for github-actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ concurrency:
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
node: [18, 20]

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Nodejs
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
- name: Lint
Expand Down
99 changes: 55 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"@edx/brand": "npm:@openedx/[email protected]",
"@edx/frontend-component-footer": "14.0.1",
"@edx/frontend-enterprise-catalog-search": "10.6.0",
"@edx/frontend-enterprise-catalog-search": "10.7.1",
"@edx/frontend-enterprise-hotjar": "7.1.0",
"@edx/frontend-enterprise-logistration": "9.1.0",
"@edx/frontend-enterprise-utils": "9.1.0",
Expand Down
5 changes: 4 additions & 1 deletion src/components/app/data/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const ENTERPRISE_OFFER_SUBSIDY_TYPE = 'enterpriseOffer';
export const LEARNER_CREDIT_SUBSIDY_TYPE = 'learnerCredit';

export const ENROLL_BY_DATE_WARNING_THRESHOLD_DAYS = 10;
export const MAX_HIGHLIGHT_SETS = 12;
export const MAX_HIGHLIGHT_SETS = 16;

// Note: `cancelled` is correct and matches backend state
// despite how the key is spelled
Expand All @@ -64,3 +64,6 @@ export const ASSIGNMENT_TYPES = {
ERRORED: 'errored',
EXPIRING: 'expiring',
};

// When the start date is before this number of days before today, display the alternate start date (fixed to today).
export const START_DATE_DEFAULT_TO_TODAY_THRESHOLD_DAYS = 14;
7 changes: 2 additions & 5 deletions src/components/app/data/hooks/useCourseMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useParams, useSearchParams } from 'react-router-dom';

import { queryCourseMetadata } from '../queries';
import {
determineAllocatedCourseRunAssignmentsForCourse,
determineAllocatedAssignmentsForCourse,
getAvailableCourseRuns,
transformCourseMetadataByAllocatedCourseRunAssignments,
} from '../utils';
Expand All @@ -23,10 +23,7 @@ export default function useCourseMetadata(queryOptions = {}) {
allocatedCourseRunAssignmentKeys,
hasAssignedCourseRuns,
hasMultipleAssignedCourseRuns,
} = determineAllocatedCourseRunAssignmentsForCourse({
courseKey,
redeemableLearnerCreditPolicies,
});
} = determineAllocatedAssignmentsForCourse({ courseKey, redeemableLearnerCreditPolicies });
// `requestUrl.searchParams` uses `URLSearchParams`, which decodes `+` as a space, so we
// need to replace it with `+` again to be a valid course run key.
let courseRunKey = searchParams.get('course_run_key')?.replaceAll(' ', '+');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function useEnterpriseCourseEnrollments(queryOptions = {}) {
},
enabled: isEnabled,
});

// TODO: Talk about how we don't have access to weeksToComplete on the dashboard page.
const allEnrollmentsByStatus = useMemo(() => transformAllEnrollmentsByStatus({
enterpriseCourseEnrollments,
requests,
Expand Down
3 changes: 0 additions & 3 deletions src/components/app/data/hooks/useEnterpriseFeatures.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ const mockEnterpriseLearnerData = {
activeEnterpriseCustomer: null,
activeEnterpriseCustomerUserRoleAssignments: [],
allLinkedEnterpriseCustomerUsers: [],
enterpriseFeatures: {
featurePrequerySearchSuggestions: true,
},
staffEnterpriseCustomer: null,
};
const mockEnterpriseFeatures = mockEnterpriseLearnerData.enterpriseFeatures;
Expand Down
31 changes: 23 additions & 8 deletions src/components/app/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ export const canUnenrollCourseEnrollment = (courseEnrollment) => {
*/
export const transformCourseEnrollment = (rawCourseEnrollment) => {
const courseEnrollment = { ...rawCourseEnrollment };

// Return the fields expected by the component(s)
courseEnrollment.title = courseEnrollment.displayName;
courseEnrollment.microMastersTitle = courseEnrollment.micromastersTitle;
Expand Down Expand Up @@ -409,7 +408,6 @@ export const transformLearnerContentAssignment = (learnerContentAssignment, ente
courseKey = parentContentKey;
courseRunId = contentKey;
}

return {
linkToCourse: `/${enterpriseSlug}/course/${courseKey}`,
courseRunId,
Expand Down Expand Up @@ -510,7 +508,6 @@ export function getAvailableCourseRuns({ course, lateEnrollmentBufferDays }) {
if (!course?.courseRuns) {
return [];
}

// These are the standard rules used for determining whether a run is "available".
const standardAvailableCourseRunsFilter = (courseRun) => (
courseRun.isMarketable && !isArchived(courseRun) && courseRun.isEnrollable
Expand Down Expand Up @@ -806,27 +803,45 @@ export function isEnrollmentUpgradeable(enrollment) {
* }
* }
*/
export function determineAllocatedCourseRunAssignmentsForCourse({
export function determineAllocatedAssignmentsForCourse({
redeemableLearnerCreditPolicies,
courseKey,
}) {
const { learnerContentAssignments } = redeemableLearnerCreditPolicies;
// note: checking the non-happy path first, with early return so happy path code isn't nested in conditional.
if (!learnerContentAssignments.hasAllocatedAssignments) {
return {
isCourseAssigned: false,
allocatedAssignmentsForCourse: [],
allocatedCourseRunAssignmentKeys: [],
allocatedCourseRunAssignments: [],
hasAssignedCourseRuns: false,
hasMultipleAssignedCourseRuns: false,
};
}
const allocatedCourseRunAssignments = learnerContentAssignments.allocatedAssignments.filter((assignment) => (
assignment.isAssignedCourseRun && assignment.parentContentKey === courseKey
));

const allocatedAssignmentsForCourse = [];
const allocatedCourseRunAssignments = [];

learnerContentAssignments.allocatedAssignments.forEach((assignment) => {
const isCourseRunAssignment = assignment.isAssignedCourseRun && assignment.parentContentKey === courseKey;
const isCourseAssignment = !assignment.isAssignedCourseRun && assignment.contentKey === courseKey;
if (isCourseRunAssignment || isCourseAssignment) {
allocatedAssignmentsForCourse.push(assignment);
}
if (isCourseRunAssignment) {
allocatedCourseRunAssignments.push(assignment);
}
});

const isCourseAssigned = allocatedAssignmentsForCourse.length > 0;
const allocatedCourseRunAssignmentKeys = allocatedCourseRunAssignments.map(assignment => assignment.contentKey);
const hasAssignedCourseRuns = allocatedCourseRunAssignmentKeys.length > 0;
const hasMultipleAssignedCourseRuns = allocatedCourseRunAssignmentKeys.length > 1;

return {
isCourseAssigned,
allocatedAssignmentsForCourse,
allocatedCourseRunAssignmentKeys,
allocatedCourseRunAssignments,
hasAssignedCourseRuns,
Expand Down Expand Up @@ -861,7 +876,7 @@ export function transformCourseMetadataByAllocatedCourseRunAssignments({
courseRuns: courseMetadata.courseRuns.filter(
courseRun => allocatedCourseRunAssignmentKeys.includes(courseRun.key),
),
availableCourseRuns: courseMetadata.courseRuns.filter(
availableCourseRuns: courseMetadata.availableCourseRuns.filter(
courseRun => allocatedCourseRunAssignmentKeys.includes(courseRun.key),
),
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/course/CourseSidebarPrice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const CourseSidebarPrice = () => {
const intl = useIntl();
const { data: enterpriseCustomer } = useEnterpriseCustomer();
const { coursePrice, currency } = useCoursePrice();
const isCourseAssigned = useIsCourseAssigned();
const { isCourseAssigned } = useIsCourseAssigned();
const canRequestSubsidy = useCanUserRequestSubsidyForCourse();
const { userSubsidyApplicableToCourse } = useUserSubsidyApplicableToCourse();

Expand Down
Loading

0 comments on commit a66dfb2

Please sign in to comment.