From dd0cb8db3b95569a46d13d0c2ba5a185dcb5a70b Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 18 Dec 2024 10:13:08 -0500 Subject: [PATCH] feat: extend BFF feature flag to take into account Waffle flag (#1239) --- src/components/NotFoundPage/index.jsx | 1 - src/components/TagCloud/index.jsx | 1 - src/components/Toasts/Toasts.jsx | 2 +- src/components/Toasts/Toasts.test.jsx | 5 +- src/components/Toasts/ToastsProvider.jsx | 2 +- .../academies/AcademyContentCard.jsx | 2 +- .../academies/AcademyDetailPage.jsx | 2 +- src/components/academies/GoToAcademy.jsx | 4 +- src/components/academies/PathwaysSection.jsx | 1 - .../tests/AcademyDetailPage.test.jsx | 1 - .../academies/tests/PathwaysSection.test.jsx | 1 - src/components/app/Layout.test.jsx | 29 ++- src/components/app/data/hooks/index.js | 1 + src/components/app/data/hooks/useBFF.js | 7 +- src/components/app/data/hooks/useBFF.test.jsx | 193 +++++++++++------- .../hooks/useDefaultSearchFilters.test.js | 1 - .../app/data/hooks/useEnterpriseFeatures.js | 10 +- .../data/hooks/useEnterpriseFeatures.test.jsx | 26 ++- .../app/data/hooks/useIsBFFEnabled.js | 9 + .../app/data/hooks/useIsBFFEnabled.test.js | 36 ++++ .../app/data/hooks/useSubscriptions.test.jsx | 12 +- src/components/app/data/queries/utils.js | 9 +- src/components/app/data/utils.js | 13 ++ .../app/routes/RouteErrorBoundary.test.jsx | 1 - .../app/routes/RouterFallback.test.jsx | 1 - src/components/app/routes/data/utils.js | 9 +- .../app/routes/loaders/rootLoader.ts | 1 + .../budget-expiry-notification/index.jsx | 2 +- .../tests/BudgetExpiryNotification.test.jsx | 1 - src/components/contact-admin-mailto/index.jsx | 1 - .../course/CourseEnrollmentFailedAlert.jsx | 2 +- .../course/CourseRecommendationCard.jsx | 2 +- .../course/CourseSidebarListItem.jsx | 1 - src/components/course/VerifiedCertPitch.jsx | 1 - .../course/course-header/CoursePreview.jsx | 2 +- .../course-header/CourseRunCardStatus.jsx | 1 - .../course-header/RedemptionStatusText.jsx | 1 - .../BasicNavigateToCourseware.jsx | 1 - .../NavigateToCourseware.jsx | 1 - .../UpgradeAndNavigateToCourseware.jsx | 1 - .../course-header/tests/CourseHeader.test.jsx | 1 - .../tests/CoursePreview.test.jsx | 2 - .../tests/CourseRunCard.test.jsx | 1 - .../tests/CourseRunCardStatus.test.jsx | 1 - .../tests/DeprecatedCourseRunCard.test.jsx | 1 - src/components/course/data/utils.jsx | 1 - .../course/enrollment/EnrollAction.jsx | 1 - src/components/course/enrollment/common.jsx | 1 - .../enrollment/components/DisabledEnroll.jsx | 1 - .../components/ToCoursewarePage.jsx | 1 - .../ToExecutiveEducation2UEnrollment.jsx | 1 - .../enrollment/tests/EnrollAction.test.jsx | 1 - .../tests/ToEcomBasketPage.test.jsx | 1 - .../tests/CourseAssociatedPrograms.test.jsx | 1 - .../CourseEnrollmentFailedAlert.test.jsx | 1 - .../course/tests/CoursePage.test.jsx | 1 - .../tests/CourseRecommendationCard.test.jsx | 1 - .../tests/CourseRecommendations.test.jsx | 1 - .../tests/CourseSidebarListItem.test.jsx | 1 - .../course/tests/CourseSidebarPrice.test.jsx | 1 - .../course/tests/CourseSkills.test.jsx | 1 - .../course/tests/CreatedBy.test.jsx | 1 - .../course/tests/EnrollModal.test.jsx | 1 - .../tests/SubsidyRequestButton.test.jsx | 1 - .../course/tests/VerifiedCertPitch.test.jsx | 1 - src/components/dashboard/DashboardPage.jsx | 4 +- .../dashboard/SubscriptionExpirationModal.jsx | 2 +- .../dashboard/data/dashboardLoader.ts | 8 +- .../main-content/CoursesTabComponent.jsx | 1 - .../course-enrollments/CourseEnrollments.jsx | 2 +- .../CourseEnrollmentsEmptyState.jsx | 2 +- .../course-cards/CompletedCourseCard.jsx | 2 +- .../course-cards/Notification.jsx | 1 - .../course-cards/RequestedCourseCard.jsx | 2 - .../course-cards/SavedForLaterCourseCard.jsx | 2 +- .../email-settings/EmailSettingsModal.jsx | 2 +- .../tests/EmailSettingsModal.test.jsx | 1 - .../mark-complete-modal/MarkCompleteModal.jsx | 2 +- .../mark-complete-modal/ModalBody.jsx | 2 +- .../mark-complete-modal/ModalError.jsx | 2 +- .../tests/MarkCompleteModal.test.jsx | 1 - .../move-to-in-progress-modal/ModalBody.jsx | 2 +- .../move-to-in-progress-modal/ModalError.jsx | 2 +- .../MoveToInProgressModal.jsx | 2 +- .../tests/AssignedCourseCard.test.jsx | 1 - .../tests/BaseCourseCard.test.jsx | 5 +- .../tests/InProgressCourseCard.test.jsx | 4 +- .../course-cards/unenroll/UnenrollModal.jsx | 5 +- .../unenroll/UnenrollModal.test.jsx | 8 +- .../course-enrollments/data/hooks.js | 8 +- .../data/tests/hooks.test.jsx | 6 +- .../tests/CourseEnrollments.test.jsx | 22 +- .../sidebar/CouponCodesSummaryCard.jsx | 2 +- .../dashboard/sidebar/DashboardSidebar.jsx | 3 +- .../sidebar/LearnerCreditSummaryCard.jsx | 1 - .../sidebar/SubscriptionSummaryCard.jsx | 1 - .../data/hooks/useSubscriptionSummaryCard.jsx | 1 - .../tests/CouponCodesSummaryCard.test.jsx | 1 - .../sidebar/tests/DashboardSidebar.test.jsx | 1 - .../tests/LearnerCreditSummaryCard.test.jsx | 1 - .../tests/SubscriptionSummaryCard.test.jsx | 1 - .../tests/CourseRecommendations.test.jsx | 1 - .../dashboard/tests/DashboardPage.test.jsx | 1 - .../tests/EnterpriseBanner.test.jsx | 1 - .../enterprise-page/EnterprisePage.jsx | 13 +- .../enterprise-page/EnterprisePage.test.jsx | 6 +- .../EnterpriseOffersBalanceAlert.jsx | 1 - .../EnterpriseOffersBalanceAlert.test.jsx | 1 - src/components/error-page/ErrorPage.test.jsx | 1 - .../error-page/ErrorPageContent.jsx | 5 +- src/components/error-page/ErrorPageHeader.jsx | 2 +- .../EnrollmentCompletedSummaryCard.test.jsx | 1 - .../ExecutiveEducation2UError.jsx | 1 - .../UserEnrollmentForm.jsx | 7 +- .../UserEnrollmentForm.test.jsx | 8 +- .../components/RegistrationSummaryCard.jsx | 1 - .../IntegrationWarningModal.jsx | 2 +- .../integration-warning-modal/ModalBody.jsx | 2 - src/components/layout/MainContent.jsx | 1 - src/components/layout/Sidebar.jsx | 1 - src/components/layout/SidebarBlock.jsx | 1 - .../loading-spinner/LoadingSpinner.jsx | 1 - .../microlearning/VideoCourseReview.jsx | 1 - .../microlearning/VideoDetailPage.jsx | 4 +- .../microlearning/VideoFeedbackCard.jsx | 2 +- .../__mocks__/@loadable/component.jsx | 2 - src/components/my-career/CategoryCard.jsx | 2 +- src/components/my-career/LevelBars.jsx | 1 - .../my-career/MyCareerTabSkeleton.jsx | 1 - src/components/my-career/SearchJobRole.jsx | 2 +- .../my-career/SkillsRecommendationCourses.jsx | 2 +- src/components/my-career/VisualizeCareer.jsx | 2 +- .../my-career/tests/AddJobRole.test.jsx | 1 - .../my-career/tests/CategoryCard.test.jsx | 1 - .../my-career/tests/LevelBars.test.jsx | 1 - .../my-career/tests/SearchJobRole.test.jsx | 1 - .../SkillsRecommendationCourses.test.jsx | 1 - .../my-career/tests/SpiderChart.test.jsx | 1 - .../my-career/tests/VisualizeCareer.test.jsx | 1 - .../pathway-progress/PathwayNode.jsx | 2 +- .../pathway-progress/PathwayStep.jsx | 2 +- .../tests/PathwayNode.test.jsx | 1 - .../tests/PathwayProgressListingCard.test.jsx | 1 - .../tests/PathwayProgressListingPage.test.jsx | 1 - .../tests/PathwayRequirements.test.jsx | 1 - .../tests/PathwayStep.test.jsx | 1 - .../tests/SubscriptionStatusCard.test.jsx | 1 - src/components/pathway/PathwayModal.jsx | 1 - src/components/pathway/SearchPathwayCard.jsx | 2 +- .../pathway/tests/PathwayModal.test.jsx | 1 - .../pathway/tests/SearchPathwayCard.test.jsx | 1 - .../preview-expand/PreviewExpand.jsx | 2 +- .../tests/ProgramListingCard.test.jsx | 1 - .../tests/ProgramListingPage.test.jsx | 1 - .../tests/ProgramPathwayOpportunity.test.jsx | 1 - .../tests/ProgramProgressCircle.test.jsx | 1 - .../tests/ProgramProgressCourses.test.jsx | 1 - .../tests/ProgramProgressHeader.test.jsx | 1 - .../tests/ProgramProgressPage.test.jsx | 1 - .../tests/ProgramProgressSidebar.test.jsx | 1 - .../program/tests/ProgramCTA.test.jsx | 1 - .../program/tests/ProgramCourses.test.jsx | 1 - .../program/tests/ProgramDataBar.test.jsx | 1 - .../tests/ProgramEndorsements.test.jsx | 1 - .../program/tests/ProgramFAQ.test.jsx | 1 - .../program/tests/ProgramHeader.test.jsx | 1 - .../program/tests/ProgramSidebar.test.jsx | 1 - .../ProgressCategoryBubbles.jsx | 1 - .../ContentTypeSearchResultsContainer.jsx | 1 - src/components/search/SearchCourse.jsx | 1 - src/components/search/SearchCourseCard.jsx | 2 +- src/components/search/SearchError.jsx | 1 - src/components/search/SearchNoResults.jsx | 1 - src/components/search/SearchPage.jsx | 1 - src/components/search/SearchPathway.jsx | 1 - src/components/search/SearchProgram.jsx | 1 - src/components/search/SearchProgramCard.jsx | 2 +- src/components/search/SearchResults.jsx | 2 +- src/components/search/SearchVideo.jsx | 1 - src/components/search/SearchVideoCard.jsx | 2 +- .../content-highlights/ContentHighlights.jsx | 2 +- .../HighlightedContentCard.jsx | 1 - .../search/popular-results/PopularResults.jsx | 1 - .../popular-results/PopularResultsIndex.jsx | 1 - src/components/search/tests/Search.test.jsx | 1 - .../search/tests/SearchCourseCard.test.jsx | 1 - .../search/tests/SearchPage.test.jsx | 1 - .../search/tests/SearchProgramCard.test.jsx | 1 - .../search/tests/SearchResults.test.jsx | 1 - .../search/tests/SearchSections.test.jsx | 1 - .../search/tests/SearchVideoCard.test.jsx | 1 - src/components/site-header/AvatarDropdown.jsx | 2 +- .../site-header/SiteHeaderLogos.jsx | 1 - src/components/site-header/menu/Menu.jsx | 22 +- .../site-header/tests/SiteHeader.test.jsx | 1 - .../skills-quiz-v2/JobCardComponent.jsx | 2 +- .../skills-quiz-v2/SkillsQuizHeader.jsx | 1 - .../skills-quiz-v2/tests/SkillsQuiz.test.jsx | 1 - .../tests/SkillsQuizForm.test.jsx | 1 - .../tests/SkillsQuizHeader.test.jsx | 1 - .../skills-quiz/CardLoadingSkeleton.jsx | 1 - src/components/skills-quiz/CourseCard.jsx | 2 +- .../skills-quiz/CurrentJobDropdown.jsx | 2 +- src/components/skills-quiz/GoalDropdown.jsx | 2 +- .../skills-quiz/IndustryDropdown.jsx | 2 +- .../skills-quiz/SearchCourseCard.jsx | 2 +- .../skills-quiz/SearchCurrentJobCard.jsx | 2 +- src/components/skills-quiz/SearchJobCard.jsx | 2 +- .../skills-quiz/SearchJobDropdown.jsx | 2 +- src/components/skills-quiz/SearchPathways.jsx | 2 +- .../skills-quiz/SearchProgramCard.jsx | 2 +- src/components/skills-quiz/SelectJobCard.jsx | 2 +- .../skills-quiz/SelectedJobSkills.jsx | 2 +- src/components/skills-quiz/SimilarJobs.jsx | 2 +- .../skills-quiz/SkillsContextProvider.jsx | 2 +- src/components/skills-quiz/SkillsCourses.jsx | 8 +- src/components/skills-quiz/SkillsQuiz.jsx | 1 - .../skills-quiz/SkillsQuizHeader.jsx | 1 - src/components/skills-quiz/SkillsQuizPage.jsx | 4 +- .../skills-quiz/SkillsQuizStepper.jsx | 2 +- .../skills-quiz/TopSkillsOverview.jsx | 2 +- .../skills-quiz/data/tests/hooks.test.jsx | 1 - .../skills-quiz/tests/GoalsDropdown.test.jsx | 1 - .../tests/JobDescriptions.test.jsx | 1 - .../tests/SearchCourseCard.test.jsx | 1 - .../tests/SearchCurrentJobCard.test.jsx | 1 - .../skills-quiz/tests/SearchFilters.test.jsx | 1 - .../skills-quiz/tests/SearchJobCard.test.jsx | 1 - .../skills-quiz/tests/SearchPathways.test.jsx | 1 - .../tests/SearchProgramCard.test.jsx | 1 - .../skills-quiz/tests/SelectJobCard.test.jsx | 1 - .../tests/SelectedJobSkills.test.jsx | 1 - .../skills-quiz/tests/SkillsCourses.test.jsx | 1 - .../skills-quiz/tests/SkillsQuiz.test.jsx | 1 - .../tests/SkillsQuizHeader.test.jsx | 1 - .../skills-quiz/tests/SkillsQuizPage.test.jsx | 1 - .../tests/SkillsQuizStepper.test.jsx | 1 - src/components/skills-quiz/tests/utils.jsx | 1 - .../skills-quiz/tests/utils.test.jsx | 1 - .../stateful-enroll/StatefulEnroll.jsx | 2 +- .../SystemWideWarningBanner.jsx | 1 - src/components/video/VideoPlayer.jsx | 2 +- src/components/video/tests/VideoJS.test.jsx | 1 - .../video/tests/VideoPlayer.test.jsx | 1 - src/index.jsx | 1 - src/types.d.ts | 4 + src/utils/hooks.jsx | 2 +- src/utils/tests.jsx | 2 +- 248 files changed, 408 insertions(+), 386 deletions(-) create mode 100644 src/components/app/data/hooks/useIsBFFEnabled.js create mode 100644 src/components/app/data/hooks/useIsBFFEnabled.test.js diff --git a/src/components/NotFoundPage/index.jsx b/src/components/NotFoundPage/index.jsx index d0d4c60df4..59163d4ee8 100644 --- a/src/components/NotFoundPage/index.jsx +++ b/src/components/NotFoundPage/index.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Helmet } from 'react-helmet'; import { Container } from '@openedx/paragon'; diff --git a/src/components/TagCloud/index.jsx b/src/components/TagCloud/index.jsx index 9463abaa61..7a3632c2b0 100644 --- a/src/components/TagCloud/index.jsx +++ b/src/components/TagCloud/index.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Chip } from '@openedx/paragon'; import { Close } from '@openedx/paragon/icons'; diff --git a/src/components/Toasts/Toasts.jsx b/src/components/Toasts/Toasts.jsx index 9376c49f12..bc02d6b69f 100644 --- a/src/components/Toasts/Toasts.jsx +++ b/src/components/Toasts/Toasts.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import { Toast } from '@openedx/paragon'; import { ToastsContext } from './ToastsProvider'; diff --git a/src/components/Toasts/Toasts.test.jsx b/src/components/Toasts/Toasts.test.jsx index 0826746698..14705fdb0d 100644 --- a/src/components/Toasts/Toasts.test.jsx +++ b/src/components/Toasts/Toasts.test.jsx @@ -1,7 +1,4 @@ -import React from 'react'; -import { - render, screen, act, -} from '@testing-library/react'; +import { render, screen, act } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import userEvent from '@testing-library/user-event'; import ToastsProvider, { ToastsContext } from './ToastsProvider'; diff --git a/src/components/Toasts/ToastsProvider.jsx b/src/components/Toasts/ToastsProvider.jsx index 6a302798f7..e3803b8650 100644 --- a/src/components/Toasts/ToastsProvider.jsx +++ b/src/components/Toasts/ToastsProvider.jsx @@ -1,4 +1,4 @@ -import React, { +import { createContext, useState, useMemo, diff --git a/src/components/academies/AcademyContentCard.jsx b/src/components/academies/AcademyContentCard.jsx index db7b5376c5..11fd0ce87c 100644 --- a/src/components/academies/AcademyContentCard.jsx +++ b/src/components/academies/AcademyContentCard.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; import { Button, CardGrid, diff --git a/src/components/academies/AcademyDetailPage.jsx b/src/components/academies/AcademyDetailPage.jsx index 1f8461375c..efad78a46d 100644 --- a/src/components/academies/AcademyDetailPage.jsx +++ b/src/components/academies/AcademyDetailPage.jsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; import { Container, Breadcrumb, } from '@openedx/paragon'; diff --git a/src/components/academies/GoToAcademy.jsx b/src/components/academies/GoToAcademy.jsx index dddbfa084c..a9e5802a19 100644 --- a/src/components/academies/GoToAcademy.jsx +++ b/src/components/academies/GoToAcademy.jsx @@ -1,9 +1,7 @@ import { Link } from 'react-router-dom'; import { Button } from '@openedx/paragon'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; -import React from 'react'; -import useEnterpriseCustomer from '../app/data/hooks/useEnterpriseCustomer'; -import { useAcademies } from '../app/data'; +import { useEnterpriseCustomer, useAcademies } from '../app/data'; const GoToAcademy = () => { const { data: academies } = useAcademies(); diff --git a/src/components/academies/PathwaysSection.jsx b/src/components/academies/PathwaysSection.jsx index 116ff19731..eae4902962 100644 --- a/src/components/academies/PathwaysSection.jsx +++ b/src/components/academies/PathwaysSection.jsx @@ -1,5 +1,4 @@ import { Button, Container, useToggle } from '@openedx/paragon'; -import React from 'react'; import PropTypes from 'prop-types'; import DOMPurify from 'dompurify'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; diff --git a/src/components/academies/tests/AcademyDetailPage.test.jsx b/src/components/academies/tests/AcademyDetailPage.test.jsx index 2468f12a96..03571677b6 100644 --- a/src/components/academies/tests/AcademyDetailPage.test.jsx +++ b/src/components/academies/tests/AcademyDetailPage.test.jsx @@ -1,5 +1,4 @@ import axios from 'axios'; -import React from 'react'; import { screen } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/academies/tests/PathwaysSection.test.jsx b/src/components/academies/tests/PathwaysSection.test.jsx index a21b595f96..c154bc8b16 100644 --- a/src/components/academies/tests/PathwaysSection.test.jsx +++ b/src/components/academies/tests/PathwaysSection.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { render, screen, fireEvent } from '@testing-library/react'; import '@testing-library/jest-dom'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/app/Layout.test.jsx b/src/components/app/Layout.test.jsx index 06753f0548..bc84b66ee7 100644 --- a/src/components/app/Layout.test.jsx +++ b/src/components/app/Layout.test.jsx @@ -9,7 +9,7 @@ import '@testing-library/jest-dom/extend-expect'; import Layout from './Layout'; import { queryClient, renderWithRouterProvider } from '../../utils/tests'; -import { useEnterpriseCustomer } from './data'; +import { useEnterpriseCustomer, useIsBFFEnabled } from './data'; import { authenticatedUserFactory, enterpriseCustomerFactory } from './data/services/data/__factories__'; const mockEnterpriseCustomer = enterpriseCustomerFactory(); @@ -49,6 +49,7 @@ jest.mock('../../utils/common', () => ({ jest.mock('./data', () => ({ ...jest.requireActual('./data'), useEnterpriseCustomer: jest.fn(), + useIsBFFEnabled: jest.fn(), })); const LayoutWrapper = ({ @@ -67,6 +68,7 @@ describe('Layout', () => { beforeEach(() => { jest.clearAllMocks(); useEnterpriseCustomer.mockReturnValue({ data: mockEnterpriseCustomer }); + useIsBFFEnabled.mockReturnValue(false); }); it('renders the not found page when the user is not linked to an enterprise customer', () => { @@ -103,43 +105,61 @@ describe('Layout', () => { maintenanceMessage: undefined, maintenanceStartTimestamp: undefined, maintenanceEndTimestamp: undefined, + isBFFEnabled: false, + }, + { + isSystemMaintenanceAlertOpen: false, + maintenanceMessage: undefined, + maintenanceStartTimestamp: undefined, + maintenanceEndTimestamp: undefined, + isBFFEnabled: true, }, { isSystemMaintenanceAlertOpen: true, maintenanceMessage: 'Hello World!', maintenanceStartTimestamp: undefined, maintenanceEndTimestamp: undefined, + isBFFEnabled: false, }, { isSystemMaintenanceAlertOpen: true, maintenanceMessage: 'Hello World!', maintenanceStartTimestamp: dayjs().subtract(1, 'm').toISOString(), maintenanceEndTimestamp: dayjs().add(2, 'm').toISOString(), + isBFFEnabled: false, }, { isSystemMaintenanceAlertOpen: false, maintenanceMessage: 'Hello World!', maintenanceStartTimestamp: dayjs().subtract(1, 'm').toISOString(), maintenanceEndTimestamp: dayjs().add(2, 'm').toISOString(), + isBFFEnabled: false, }, { isSystemMaintenanceAlertOpen: true, maintenanceMessage: 'Hello World!', maintenanceStartTimestamp: undefined, maintenanceEndTimestamp: dayjs().add(2, 'm').toISOString(), + isBFFEnabled: false, }, { isSystemMaintenanceAlertOpen: true, maintenanceMessage: 'Hello World!', maintenanceStartTimestamp: dayjs().subtract(1, 'm').toISOString(), maintenanceEndTimestamp: undefined, + isBFFEnabled: false, }, ])('renders with enterprise customer (%s)', ({ isSystemMaintenanceAlertOpen, maintenanceMessage, maintenanceStartTimestamp, maintenanceEndTimestamp, + isBFFEnabled, }) => { + // Mock the BFF-enabled status + useIsBFFEnabled.mockReturnValue(isBFFEnabled); + + // Merge the config values related to maintenance banner message if (maintenanceMessage) { mergeConfig({ IS_MAINTENANCE_ALERT_ENABLED: isSystemMaintenanceAlertOpen, @@ -151,7 +171,6 @@ describe('Layout', () => { MAINTENANCE_ALERT_START_TIMESTAMP: maintenanceStartTimestamp ?? '', }); } - if (maintenanceEndTimestamp) { mergeConfig({ MAINTENANCE_ALERT_END_TIMESTAMP: maintenanceEndTimestamp ?? '', @@ -168,7 +187,7 @@ describe('Layout', () => { }, ], }, { - initialEntries: ['/test-enterprise'], + initialEntries: [`/${mockEnterpriseCustomer.slug}`], }); expect(screen.getByTestId('site-header')).toBeInTheDocument(); expect(screen.getByTestId('enterprise-banner')).toBeInTheDocument(); @@ -180,5 +199,9 @@ describe('Layout', () => { } else if (maintenanceMessage) { expect(screen.queryByText(maintenanceMessage)).not.toBeInTheDocument(); } + + // Verify logging service is called with the correct custom attributes + expect(mockSetCustomAttribute).toHaveBeenCalledWith('enterprise_customer_uuid', mockEnterpriseCustomer.uuid); + expect(mockSetCustomAttribute).toHaveBeenCalledWith('is_bff_enabled', isBFFEnabled); }); }); diff --git a/src/components/app/data/hooks/index.js b/src/components/app/data/hooks/index.js index e2f5159403..3eee9934f6 100644 --- a/src/components/app/data/hooks/index.js +++ b/src/components/app/data/hooks/index.js @@ -47,3 +47,4 @@ export { default as useVideoDetails } from './useVideoDetails'; export { default as useVideoCourseMetadata } from './useVideoCourseMetadata'; export { default as useVideoCourseReviews } from './useVideoCourseReviews'; export { default as useBFF } from './useBFF'; +export { default as useIsBFFEnabled } from './useIsBFFEnabled'; diff --git a/src/components/app/data/hooks/useBFF.js b/src/components/app/data/hooks/useBFF.js index 0814175b83..fd100e3a0a 100644 --- a/src/components/app/data/hooks/useBFF.js +++ b/src/components/app/data/hooks/useBFF.js @@ -3,6 +3,7 @@ import { useQuery } from '@tanstack/react-query'; import { logError } from '@edx/frontend-platform/logging'; import useEnterpriseCustomer from './useEnterpriseCustomer'; import { resolveBFFQuery } from '../queries'; +import useEnterpriseFeatures from './useEnterpriseFeatures'; /** * Uses the route to determine which API call to make for the BFF @@ -19,13 +20,17 @@ export default function useBFF({ fallbackQueryConfig = null, }) { const { data: enterpriseCustomer } = useEnterpriseCustomer(); + const enterpriseFeatures = useEnterpriseFeatures(); const { enterpriseSlug } = useParams(); const location = useLocation(); // Determine the BFF query to use based on the current location const matchedBFFQuery = resolveBFFQuery( location.pathname, - { enterpriseCustomerUuid: enterpriseCustomer.uuid }, + { + enterpriseCustomerUuid: enterpriseCustomer.uuid, + enterpriseFeatures, + }, ); // Determine which query to call, the original hook or the new BFF diff --git a/src/components/app/data/hooks/useBFF.test.jsx b/src/components/app/data/hooks/useBFF.test.jsx index e2907b4322..105c16d6be 100644 --- a/src/components/app/data/hooks/useBFF.test.jsx +++ b/src/components/app/data/hooks/useBFF.test.jsx @@ -3,27 +3,22 @@ import { QueryClientProvider } from '@tanstack/react-query'; import { v4 as uuidv4 } from 'uuid'; import { useLocation, useParams } from 'react-router-dom'; import { getConfig } from '@edx/frontend-platform/config'; -import { waitFor } from '@testing-library/react'; import { enterpriseCustomerFactory } from '../services/data/__factories__'; -import useEnterpriseCustomer from './useEnterpriseCustomer'; import { queryClient } from '../../../../utils/tests'; -import { fetchEnterpriseCourseEnrollments, fetchEnterpriseLearnerDashboard } from '../services'; +import { fetchEnterpriseLearnerDashboard } from '../services'; import useBFF from './useBFF'; -import { queryEnterpriseCourseEnrollments, queryEnterpriseLearnerDashboardBFF, resolveBFFQuery } from '../queries'; +import useEnterpriseCustomer from './useEnterpriseCustomer'; +import useEnterpriseFeatures from './useEnterpriseFeatures'; jest.mock('./useEnterpriseCustomer'); -jest.mock('../queries', () => ({ - ...jest.requireActual('../queries'), - resolveBFFQuery: jest.fn(), -})); +jest.mock('./useEnterpriseFeatures'); jest.mock('../services', () => ({ ...jest.requireActual('../services'), fetchEnterpriseLearnerDashboard: jest.fn().mockResolvedValue(null), - fetchEnterpriseCourseEnrollments: jest.fn().mockResolvedValue(null), })); jest.mock('react-router-dom', () => ({ + ...jest.requireActual('react-router-dom'), useLocation: jest.fn(), - matchPath: jest.fn(), useParams: jest.fn(), })); jest.mock('@edx/frontend-platform/config', () => ({ @@ -132,106 +127,152 @@ const mockBFFDashboardData = { errors: [], warnings: [], }; -// TODO: Test with select function passed to to validate args + describe('useBFF', () => { const Wrapper = ({ children }) => ( {children} ); + beforeEach(() => { jest.clearAllMocks(); useEnterpriseCustomer.mockReturnValue({ data: mockEnterpriseCustomer }); + useEnterpriseFeatures.mockReturnValue({ + enterpriseLearnerBFFEnabled: false, + }); fetchEnterpriseLearnerDashboard.mockResolvedValue(mockBFFDashboardData); useLocation.mockReturnValue({ pathname: '/test-enterprise' }); useParams.mockReturnValue({ enterpriseSlug: 'test-enterprise' }); - resolveBFFQuery.mockReturnValue(null); getConfig.mockReturnValue({ FEATURE_ENABLE_BFF_API_FOR_ENTERPRISE_CUSTOMERS: [mockEnterpriseCustomer.uuid], }); }); - it('should handle resolved value correctly for the dashboard route, and the config enabled', async () => { - resolveBFFQuery.mockReturnValue(queryEnterpriseLearnerDashboardBFF); - const { result, waitForNextUpdate } = renderHook(() => useBFF({}), { wrapper: Wrapper }); - await waitForNextUpdate(); - expect(result.current).toEqual( - expect.objectContaining({ - data: mockBFFDashboardData, - isLoading: false, - isFetching: false, - }), - ); - }); it.each([ + // BFF enabled via customer opt-in (without query options) { - enterpriseCustomerUuids: [mockEnterpriseCustomer.uuid], - isCustomerWithBFF: true, - shouldResolve: true, + isBFFEnabledForCustomer: true, + isBFFEnabledForUser: false, + hasQueryOptions: false, }, + // BFF enabled via customer opt-in (with query options) { - enterpriseCustomerUuids: [mockEnterpriseCustomer.uuid, uuidv4()], - isCustomerWithBFF: true, - shouldResolve: true, + isBFFEnabledForCustomer: true, + isBFFEnabledForUser: false, + hasQueryOptions: true, }, + // BFF enabled via Waffle flag (without query options) { - enterpriseCustomerUuids: [uuidv4()], - isCustomerWithBFF: true, - shouldResolve: false, + isBFFEnabledForCustomer: false, + isBFFEnabledForUser: true, + hasQueryOptions: false, }, + // BFF enabled via Waffle flag (with query options) { - enterpriseCustomerUuids: [], - isCustomerWithBFF: true, - shouldResolve: false, + isBFFEnabledForCustomer: false, + isBFFEnabledForUser: true, + hasQueryOptions: true, }, + // BFF enabled via customer opt-in and Waffle flag (without query options) { - enterpriseCustomerUuids: [uuidv4()], - isCustomerWithBFF: false, - shouldResolve: true, + isBFFEnabledForCustomer: true, + isBFFEnabledForUser: true, + hasQueryOptions: false, }, + // BFF enabled via customer opt-in and Waffle flag (with query options) { - enterpriseCustomerUuids: [], - isCustomerWithBFF: false, - shouldResolve: true, + isBFFEnabledForCustomer: true, + isBFFEnabledForUser: true, + hasQueryOptions: true, }, - ])('tests whether the API resolves on the dashboard based on the feature flag (%s)', async ({ enterpriseCustomerUuids, isCustomerWithBFF, shouldResolve }) => { - if (shouldResolve) { - resolveBFFQuery.mockReturnValue( - isCustomerWithBFF ? queryEnterpriseLearnerDashboardBFF : queryEnterpriseCourseEnrollments, - ); - fetchEnterpriseCourseEnrollments.mockResolvedValue(mockBFFDashboardData.enterpriseCourseEnrollments); - } else { - resolveBFFQuery.mockReturnValue(null); + // BFF disabled (without query options) + { + isBFFEnabledForCustomer: false, + isBFFEnabledForUser: false, + hasQueryOptions: false, + }, + // BFF disabled (with query options) + { + isBFFEnabledForCustomer: false, + isBFFEnabledForUser: false, + hasQueryOptions: true, + }, + ])('should handle resolved value correctly for the dashboard route, and the config enabled (%s)', async ({ + isBFFEnabledForCustomer, + isBFFEnabledForUser, + hasQueryOptions, + }) => { + if (!isBFFEnabledForCustomer) { + getConfig.mockReturnValue({ + FEATURE_ENABLE_BFF_API_FOR_ENTERPRISE_CUSTOMERS: [], + }); } - getConfig.mockReturnValue({ - FEATURE_ENABLE_BFF_API_FOR_ENTERPRISE_CUSTOMERS: enterpriseCustomerUuids, + if (isBFFEnabledForUser) { + useEnterpriseFeatures.mockReturnValue({ + enterpriseLearnerBFFEnabled: true, + }); + } + const isBFFEnabled = isBFFEnabledForCustomer || isBFFEnabledForUser; + const mockFallbackData = { fallback: 'data' }; + const mockSelect = jest.fn(() => { + if (isBFFEnabled) { + return mockBFFDashboardData; + } + return mockFallbackData; }); - if (!shouldResolve) { - expect(() => { - const { result } = renderHook(() => useBFF({}), { wrapper: Wrapper }); - return result.current; - }).toThrow('No BFF query found for the current route and no fallback query provided'); + const mockFallbackQueryFn = jest.fn().mockReturnValue(mockFallbackData); + const mockFallbackQueryConfig = { + queryKey: ['fallback-query'], + queryFn: mockFallbackQueryFn, + }; + const mockBFFQueryOptions = {}; + if (hasQueryOptions) { + mockBFFQueryOptions.select = mockSelect; + mockFallbackQueryConfig.select = mockSelect; } + const { result, waitForNextUpdate } = renderHook( + () => useBFF({ + bffQueryOptions: { + select: mockSelect, + }, + fallbackQueryConfig: mockFallbackQueryConfig, + }), + { wrapper: Wrapper }, + ); + await waitForNextUpdate(); + + const expectedData = isBFFEnabled ? mockBFFDashboardData : mockFallbackData; + expect(result.current).toEqual( + expect.objectContaining({ + data: expectedData, + isLoading: false, + isFetching: false, + }), + ); - const { result } = renderHook(() => useBFF({}), { wrapper: Wrapper }); - await waitFor(() => { - if (shouldResolve && isCustomerWithBFF) { - expect(result.current).toEqual( - expect.objectContaining({ - data: mockBFFDashboardData, - isLoading: false, - isFetching: false, - }), - ); - } else if (shouldResolve) { - expect(result.current).toEqual( - expect.objectContaining({ - data: mockBFFDashboardData.enterpriseCourseEnrollments, - isLoading: false, - isFetching: false, - }), - ); + if (hasQueryOptions) { + expect(mockSelect).toHaveBeenCalledTimes(1); + if (isBFFEnabled) { + // Expects the select function to be called with the resolved BFF data + expect(mockSelect).toHaveBeenCalledWith(mockBFFDashboardData); + } else { + // Expects the select function to be called with the resolved fallback data + expect(mockSelect).toHaveBeenCalledWith(mockFallbackData); } - }); + } + + if (isBFFEnabled) { + expect(fetchEnterpriseLearnerDashboard).toHaveBeenCalledTimes(1); + expect(fetchEnterpriseLearnerDashboard).toHaveBeenCalledWith( + expect.objectContaining({ + enterpriseSlug: 'test-enterprise', + }), + ); + expect(mockFallbackQueryFn).not.toHaveBeenCalled(); + } else { + expect(fetchEnterpriseLearnerDashboard).not.toHaveBeenCalled(); + expect(mockFallbackQueryFn).toHaveBeenCalledTimes(1); + } }); }); diff --git a/src/components/app/data/hooks/useDefaultSearchFilters.test.js b/src/components/app/data/hooks/useDefaultSearchFilters.test.js index f8034ca542..96fea0748e 100644 --- a/src/components/app/data/hooks/useDefaultSearchFilters.test.js +++ b/src/components/app/data/hooks/useDefaultSearchFilters.test.js @@ -1,7 +1,6 @@ import { renderHook } from '@testing-library/react-hooks'; import * as frontendEnterpriseCatalogSearch from '@edx/frontend-enterprise-catalog-search'; import { SearchContext, SHOW_ALL_NAME } from '@edx/frontend-enterprise-catalog-search'; -import React from 'react'; import useDefaultSearchFilters from './useDefaultSearchFilters'; import useEnterpriseCustomer from './useEnterpriseCustomer'; import useSearchCatalogs from './useSearchCatalogs'; diff --git a/src/components/app/data/hooks/useEnterpriseFeatures.js b/src/components/app/data/hooks/useEnterpriseFeatures.js index 84a119c0c2..d9afb601e1 100644 --- a/src/components/app/data/hooks/useEnterpriseFeatures.js +++ b/src/components/app/data/hooks/useEnterpriseFeatures.js @@ -4,6 +4,14 @@ export default function useEnterpriseFeatures(queryOptions = {}) { const { select, ...queryOptionsRest } = queryOptions; return useEnterpriseLearner({ ...queryOptionsRest, - select: (data) => data.enterpriseFeatures, + select: (data) => { + if (select) { + return select({ + original: data, + transformed: data?.enterpriseFeatures, + }); + } + return data?.enterpriseFeatures; + }, }); } diff --git a/src/components/app/data/hooks/useEnterpriseFeatures.test.jsx b/src/components/app/data/hooks/useEnterpriseFeatures.test.jsx index 41f98dd617..070e3fda49 100644 --- a/src/components/app/data/hooks/useEnterpriseFeatures.test.jsx +++ b/src/components/app/data/hooks/useEnterpriseFeatures.test.jsx @@ -30,13 +30,35 @@ describe('useEnterpriseFeatures', () => { ); + beforeEach(() => { jest.clearAllMocks(); fetchEnterpriseLearnerData.mockResolvedValue(mockEnterpriseLearnerData); }); - it('should return enterprise features correctly', async () => { - const { result, waitForNextUpdate } = renderHook(() => useEnterpriseFeatures(), { wrapper: Wrapper }); + + it.each([ + { hasQueryOptions: false }, + { hasQueryOptions: true }, + ])('should return enterprise features correctly (%s)', async ({ hasQueryOptions }) => { + const mockSelect = jest.fn(data => data.transformed); + const { result, waitForNextUpdate } = renderHook( + () => { + if (hasQueryOptions) { + return useEnterpriseFeatures({ select: mockSelect }); + } + return useEnterpriseFeatures(); + }, + { wrapper: Wrapper }, + ); await waitForNextUpdate(); + + if (hasQueryOptions) { + expect(mockSelect).toHaveBeenCalledWith({ + original: mockEnterpriseLearnerData, + transformed: mockEnterpriseFeatures, + }); + } + const actualEnterpriseFeatures = result.current.data; expect(actualEnterpriseFeatures).toEqual(mockEnterpriseFeatures); }); diff --git a/src/components/app/data/hooks/useIsBFFEnabled.js b/src/components/app/data/hooks/useIsBFFEnabled.js new file mode 100644 index 0000000000..dd1597428d --- /dev/null +++ b/src/components/app/data/hooks/useIsBFFEnabled.js @@ -0,0 +1,9 @@ +import { isBFFEnabled } from '../utils'; +import useEnterpriseCustomer from './useEnterpriseCustomer'; +import useEnterpriseFeatures from './useEnterpriseFeatures'; + +export default function useIsBFFEnabled() { + const { data: enterpriseCustomer } = useEnterpriseCustomer(); + const enterpriseFeatures = useEnterpriseFeatures(); + return isBFFEnabled(enterpriseCustomer.uuid, enterpriseFeatures); +} diff --git a/src/components/app/data/hooks/useIsBFFEnabled.test.js b/src/components/app/data/hooks/useIsBFFEnabled.test.js new file mode 100644 index 0000000000..4574966fb0 --- /dev/null +++ b/src/components/app/data/hooks/useIsBFFEnabled.test.js @@ -0,0 +1,36 @@ +import { renderHook } from '@testing-library/react-hooks'; +import useIsBFFEnabled from './useIsBFFEnabled'; +import useEnterpriseCustomer from './useEnterpriseCustomer'; +import useEnterpriseFeatures from './useEnterpriseFeatures'; +import { isBFFEnabled } from '../utils'; + +jest.mock('./useEnterpriseCustomer'); +jest.mock('./useEnterpriseFeatures'); +jest.mock('../utils', () => ({ + isBFFEnabled: jest.fn(), +})); + +describe('useIsBFFEnabled', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it.each([ + { hasBFFEnabled: false }, + { hasBFFEnabled: true }, + ])('should return expected value based on whether BFF is enabled (%s)', ({ hasBFFEnabled }) => { + const mockEnterpriseCustomer = { uuid: '12345' }; + const mockEnterpriseFeatures = { featureX: true }; + + useEnterpriseCustomer.mockReturnValue({ data: mockEnterpriseCustomer }); + useEnterpriseFeatures.mockReturnValue(mockEnterpriseFeatures); + isBFFEnabled.mockReturnValue(hasBFFEnabled); + + const { result } = renderHook(() => useIsBFFEnabled()); + + expect(useEnterpriseCustomer).toHaveBeenCalled(); + expect(useEnterpriseFeatures).toHaveBeenCalled(); + expect(isBFFEnabled).toHaveBeenCalledWith(mockEnterpriseCustomer.uuid, mockEnterpriseFeatures); + expect(result.current).toBe(hasBFFEnabled); + }); +}); diff --git a/src/components/app/data/hooks/useSubscriptions.test.jsx b/src/components/app/data/hooks/useSubscriptions.test.jsx index 9a9f5fc0d9..6fdcfe3a3d 100644 --- a/src/components/app/data/hooks/useSubscriptions.test.jsx +++ b/src/components/app/data/hooks/useSubscriptions.test.jsx @@ -8,8 +8,10 @@ import useEnterpriseCustomer from './useEnterpriseCustomer'; import useSubscriptions from './useSubscriptions'; import { LICENSE_STATUS } from '../../../enterprise-user-subsidy/data/constants'; import { queryEnterpriseLearnerDashboardBFF, resolveBFFQuery } from '../queries'; +import useEnterpriseFeatures from './useEnterpriseFeatures'; jest.mock('./useEnterpriseCustomer'); +jest.mock('./useEnterpriseFeatures'); jest.mock('../services', () => ({ ...jest.requireActual('../services'), fetchSubscriptions: jest.fn().mockResolvedValue(null), @@ -19,6 +21,11 @@ jest.mock('../queries', () => ({ ...jest.requireActual('../queries'), resolveBFFQuery: jest.fn(), })); +jest.mock('react-router-dom', () => ({ + ...jest.requireActual('react-router-dom'), + useLocation: jest.fn(), + useParams: jest.fn(), +})); const mockEnterpriseCustomer = enterpriseCustomerFactory(); const licensesByStatus = { @@ -34,10 +41,6 @@ const mockSubscriptionsData = { licensesByStatus, showExpirationNotifications: false, }; -jest.mock('react-router-dom', () => ({ - useLocation: jest.fn(), - useParams: jest.fn(), -})); describe('useSubscriptions', () => { const Wrapper = ({ children }) => ( @@ -49,6 +52,7 @@ describe('useSubscriptions', () => { beforeEach(() => { jest.clearAllMocks(); useEnterpriseCustomer.mockReturnValue({ data: mockEnterpriseCustomer }); + useEnterpriseFeatures.mockReturnValue(null); fetchSubscriptions.mockResolvedValue(mockSubscriptionsData); useLocation.mockReturnValue({ pathname: '/test-enterprise' }); useParams.mockReturnValue({ enterpriseSlug: 'test-enterprise' }); diff --git a/src/components/app/data/queries/utils.js b/src/components/app/data/queries/utils.js index 34b77aedd6..246685e0a6 100644 --- a/src/components/app/data/queries/utils.js +++ b/src/components/app/data/queries/utils.js @@ -1,6 +1,6 @@ import { matchPath } from 'react-router-dom'; import { queryEnterpriseLearnerDashboardBFF } from './queries'; -import { isBFFEnabledForEnterpriseCustomer } from '../utils'; +import { isBFFEnabled } from '../utils'; /** * Resolves the appropriate BFF query function to use for the current route. @@ -9,11 +9,10 @@ import { isBFFEnabledForEnterpriseCustomer } from '../utils'; * @returns {Function|null} The BFF query function to use for the current route, or null if no match is found. */ export function resolveBFFQuery(pathname, options = {}) { - const { enterpriseCustomerUuid } = options; + const { enterpriseCustomerUuid, enterpriseFeatures } = options; - // Exit early if BFF is not enabled for the enterprise customer - const isBFFEnabledForCustomer = isBFFEnabledForEnterpriseCustomer(enterpriseCustomerUuid); - if (!isBFFEnabledForCustomer) { + // Exit early if BFF is not enabled for the enterprise customer and/or request user + if (!isBFFEnabled(enterpriseCustomerUuid, enterpriseFeatures)) { return null; } diff --git a/src/components/app/data/utils.js b/src/components/app/data/utils.js index 05d5f1344d..2da2360c5d 100644 --- a/src/components/app/data/utils.js +++ b/src/components/app/data/utils.js @@ -907,3 +907,16 @@ export function isBFFEnabledForEnterpriseCustomer(enterpriseCustomerUuid) { } return FEATURE_ENABLE_BFF_API_FOR_ENTERPRISE_CUSTOMERS.includes(enterpriseCustomerUuid); } + +export function isBFFEnabled(enterpriseCustomerUuid, enterpriseFeatures) { + // Check the following conditions: + // 1. BFF is enabled for the enterprise customer. + // 2. BFF is enabled for the request user via Waffle flag (supporting percentage-based rollout) + const isBFFEnabledForCustomer = isBFFEnabledForEnterpriseCustomer(enterpriseCustomerUuid); + if (isBFFEnabledForCustomer || enterpriseFeatures?.enterpriseLearnerBFFEnabled) { + return true; + } + + // Otherwise, BFF is not enabled. + return false; +} diff --git a/src/components/app/routes/RouteErrorBoundary.test.jsx b/src/components/app/routes/RouteErrorBoundary.test.jsx index 302be5b7a4..f8614b7502 100644 --- a/src/components/app/routes/RouteErrorBoundary.test.jsx +++ b/src/components/app/routes/RouteErrorBoundary.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { useAsyncError, useRouteError } from 'react-router-dom'; import { screen } from '@testing-library/react'; diff --git a/src/components/app/routes/RouterFallback.test.jsx b/src/components/app/routes/RouterFallback.test.jsx index ab42276f9e..765749902c 100644 --- a/src/components/app/routes/RouterFallback.test.jsx +++ b/src/components/app/routes/RouterFallback.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/app/routes/data/utils.js b/src/components/app/routes/data/utils.js index de773a0c94..eb60ecbcfe 100644 --- a/src/components/app/routes/data/utils.js +++ b/src/components/app/routes/data/utils.js @@ -47,8 +47,15 @@ export async function ensureEnterpriseAppData({ userEmail, queryClient, requestUrl, + enterpriseFeatures, }) { - const matchedBFFQuery = resolveBFFQuery(requestUrl.pathname, { enterpriseCustomerUuid: enterpriseCustomer.uuid }); + const matchedBFFQuery = resolveBFFQuery( + requestUrl.pathname, + { + enterpriseCustomerUuid: enterpriseCustomer.uuid, + enterpriseFeatures, + }, + ); const enterpriseAppDataQueries = []; if (!matchedBFFQuery) { const subscriptionsQuery = querySubscriptions(enterpriseCustomer.uuid); diff --git a/src/components/app/routes/loaders/rootLoader.ts b/src/components/app/routes/loaders/rootLoader.ts index f14ce5aa92..25d430c2a8 100644 --- a/src/components/app/routes/loaders/rootLoader.ts +++ b/src/components/app/routes/loaders/rootLoader.ts @@ -68,6 +68,7 @@ const makeRootLoader: Types.MakeRouteLoaderFunctionWithQueryClient = function ma userEmail, queryClient, requestUrl, + enterpriseFeatures: enterpriseCustomer.enterpriseFeatures, }); // Redirect to the same URL without a trailing slash, if applicable. diff --git a/src/components/budget-expiry-notification/index.jsx b/src/components/budget-expiry-notification/index.jsx index 532d618bf4..e963d6623f 100644 --- a/src/components/budget-expiry-notification/index.jsx +++ b/src/components/budget-expiry-notification/index.jsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; import { ActionRow, Alert, AlertModal, diff --git a/src/components/budget-expiry-notification/tests/BudgetExpiryNotification.test.jsx b/src/components/budget-expiry-notification/tests/BudgetExpiryNotification.test.jsx index 6ca079df5a..b0d94b015d 100644 --- a/src/components/budget-expiry-notification/tests/BudgetExpiryNotification.test.jsx +++ b/src/components/budget-expiry-notification/tests/BudgetExpiryNotification.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { render, screen } from '@testing-library/react'; import { AppContext } from '@edx/frontend-platform/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/contact-admin-mailto/index.jsx b/src/components/contact-admin-mailto/index.jsx index 7c04718421..fcd464a5e1 100644 --- a/src/components/contact-admin-mailto/index.jsx +++ b/src/components/contact-admin-mailto/index.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { MailtoLink } from '@openedx/paragon'; import PropTypes from 'prop-types'; import { getContactEmail } from '../../utils/common'; diff --git a/src/components/course/CourseEnrollmentFailedAlert.jsx b/src/components/course/CourseEnrollmentFailedAlert.jsx index f0aed148cb..417f8a85b6 100644 --- a/src/components/course/CourseEnrollmentFailedAlert.jsx +++ b/src/components/course/CourseEnrollmentFailedAlert.jsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; import PropTypes from 'prop-types'; import { useLocation } from 'react-router-dom'; import { Container, Alert } from '@openedx/paragon'; diff --git a/src/components/course/CourseRecommendationCard.jsx b/src/components/course/CourseRecommendationCard.jsx index 9c9e3a0b97..e04cadd2ac 100644 --- a/src/components/course/CourseRecommendationCard.jsx +++ b/src/components/course/CourseRecommendationCard.jsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; import { Card, Truncate } from '@openedx/paragon'; diff --git a/src/components/course/CourseSidebarListItem.jsx b/src/components/course/CourseSidebarListItem.jsx index 76c97e469c..2b35c6fdd3 100644 --- a/src/components/course/CourseSidebarListItem.jsx +++ b/src/components/course/CourseSidebarListItem.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Col, Icon, Row } from '@openedx/paragon'; diff --git a/src/components/course/VerifiedCertPitch.jsx b/src/components/course/VerifiedCertPitch.jsx index 39e9455867..f2c311144f 100644 --- a/src/components/course/VerifiedCertPitch.jsx +++ b/src/components/course/VerifiedCertPitch.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Icon } from '@openedx/paragon'; import { ContentPasteGo, RocketLaunch } from '@openedx/paragon/icons'; diff --git a/src/components/course/course-header/CoursePreview.jsx b/src/components/course/course-header/CoursePreview.jsx index f82ce09559..d22384786d 100644 --- a/src/components/course/course-header/CoursePreview.jsx +++ b/src/components/course/course-header/CoursePreview.jsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import { useEffect } from 'react'; import PropTypes from 'prop-types'; import loadable from '@loadable/component'; diff --git a/src/components/course/course-header/CourseRunCardStatus.jsx b/src/components/course/course-header/CourseRunCardStatus.jsx index 76f338032c..03930b9f06 100644 --- a/src/components/course/course-header/CourseRunCardStatus.jsx +++ b/src/components/course/course-header/CourseRunCardStatus.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Card } from '@openedx/paragon'; import { Lock } from '@openedx/paragon/icons'; diff --git a/src/components/course/course-header/RedemptionStatusText.jsx b/src/components/course/course-header/RedemptionStatusText.jsx index f5630a04ca..6b07c7a446 100644 --- a/src/components/course/course-header/RedemptionStatusText.jsx +++ b/src/components/course/course-header/RedemptionStatusText.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { useIntl, defineMessages } from '@edx/frontend-platform/i18n'; diff --git a/src/components/course/course-header/course-run-actions/BasicNavigateToCourseware.jsx b/src/components/course/course-header/course-run-actions/BasicNavigateToCourseware.jsx index 68e228098f..d9f3e07ab5 100644 --- a/src/components/course/course-header/course-run-actions/BasicNavigateToCourseware.jsx +++ b/src/components/course/course-header/course-run-actions/BasicNavigateToCourseware.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { useIntl } from '@edx/frontend-platform/i18n'; import { Button } from '@openedx/paragon'; diff --git a/src/components/course/course-header/course-run-actions/NavigateToCourseware.jsx b/src/components/course/course-header/course-run-actions/NavigateToCourseware.jsx index db294b972f..ddfc44106f 100644 --- a/src/components/course/course-header/course-run-actions/NavigateToCourseware.jsx +++ b/src/components/course/course-header/course-run-actions/NavigateToCourseware.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import BasicNavigateToCourseware from './BasicNavigateToCourseware'; diff --git a/src/components/course/course-header/course-run-actions/UpgradeAndNavigateToCourseware.jsx b/src/components/course/course-header/course-run-actions/UpgradeAndNavigateToCourseware.jsx index e3d7b44d1e..11ea7c39ea 100644 --- a/src/components/course/course-header/course-run-actions/UpgradeAndNavigateToCourseware.jsx +++ b/src/components/course/course-header/course-run-actions/UpgradeAndNavigateToCourseware.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { useIntl } from '@edx/frontend-platform/i18n'; diff --git a/src/components/course/course-header/tests/CourseHeader.test.jsx b/src/components/course/course-header/tests/CourseHeader.test.jsx index e53ecbc218..c8b39fb885 100644 --- a/src/components/course/course-header/tests/CourseHeader.test.jsx +++ b/src/components/course/course-header/tests/CourseHeader.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/course/course-header/tests/CoursePreview.test.jsx b/src/components/course/course-header/tests/CoursePreview.test.jsx index 1af56022a0..26d204725c 100644 --- a/src/components/course/course-header/tests/CoursePreview.test.jsx +++ b/src/components/course/course-header/tests/CoursePreview.test.jsx @@ -1,5 +1,3 @@ -import React from 'react'; - import '@testing-library/jest-dom/extend-expect'; import { screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; diff --git a/src/components/course/course-header/tests/CourseRunCard.test.jsx b/src/components/course/course-header/tests/CourseRunCard.test.jsx index 14753e4267..5a648b203c 100644 --- a/src/components/course/course-header/tests/CourseRunCard.test.jsx +++ b/src/components/course/course-header/tests/CourseRunCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/course/course-header/tests/CourseRunCardStatus.test.jsx b/src/components/course/course-header/tests/CourseRunCardStatus.test.jsx index 544ac87591..e1a00ba24d 100644 --- a/src/components/course/course-header/tests/CourseRunCardStatus.test.jsx +++ b/src/components/course/course-header/tests/CourseRunCardStatus.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/course/course-header/tests/DeprecatedCourseRunCard.test.jsx b/src/components/course/course-header/tests/DeprecatedCourseRunCard.test.jsx index 749f3c3cda..04839f18c9 100644 --- a/src/components/course/course-header/tests/DeprecatedCourseRunCard.test.jsx +++ b/src/components/course/course-header/tests/DeprecatedCourseRunCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import dayjs from 'dayjs'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/course/data/utils.jsx b/src/components/course/data/utils.jsx index 678381a818..929bf184f3 100644 --- a/src/components/course/data/utils.jsx +++ b/src/components/course/data/utils.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { ensureConfig, getConfig } from '@edx/frontend-platform'; import { hasFeatureFlagEnabled } from '@edx/frontend-enterprise-utils'; import { Button, Hyperlink, MailtoLink } from '@openedx/paragon'; diff --git a/src/components/course/enrollment/EnrollAction.jsx b/src/components/course/enrollment/EnrollAction.jsx index 4cdaa29554..9b5922c2ab 100644 --- a/src/components/course/enrollment/EnrollAction.jsx +++ b/src/components/course/enrollment/EnrollAction.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import ToCoursewarePage from './components/ToCoursewarePage'; diff --git a/src/components/course/enrollment/common.jsx b/src/components/course/enrollment/common.jsx index e9d213ad3d..5dc1507d7f 100644 --- a/src/components/course/enrollment/common.jsx +++ b/src/components/course/enrollment/common.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Button } from '@openedx/paragon'; diff --git a/src/components/course/enrollment/components/DisabledEnroll.jsx b/src/components/course/enrollment/components/DisabledEnroll.jsx index a779bd546b..7040515062 100644 --- a/src/components/course/enrollment/components/DisabledEnroll.jsx +++ b/src/components/course/enrollment/components/DisabledEnroll.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { EnrollButtonCta } from '../common'; diff --git a/src/components/course/enrollment/components/ToCoursewarePage.jsx b/src/components/course/enrollment/components/ToCoursewarePage.jsx index d9fdc1fe6d..0cd44ee20a 100644 --- a/src/components/course/enrollment/components/ToCoursewarePage.jsx +++ b/src/components/course/enrollment/components/ToCoursewarePage.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { EnrollButtonCta } from '../common'; diff --git a/src/components/course/enrollment/components/ToExecutiveEducation2UEnrollment.jsx b/src/components/course/enrollment/components/ToExecutiveEducation2UEnrollment.jsx index 184c37d02d..76103fc204 100644 --- a/src/components/course/enrollment/components/ToExecutiveEducation2UEnrollment.jsx +++ b/src/components/course/enrollment/components/ToExecutiveEducation2UEnrollment.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Button } from '@openedx/paragon'; import { Link } from 'react-router-dom'; diff --git a/src/components/course/enrollment/tests/EnrollAction.test.jsx b/src/components/course/enrollment/tests/EnrollAction.test.jsx index be1b3fa26d..b5992b848c 100644 --- a/src/components/course/enrollment/tests/EnrollAction.test.jsx +++ b/src/components/course/enrollment/tests/EnrollAction.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/course/enrollment/tests/ToEcomBasketPage.test.jsx b/src/components/course/enrollment/tests/ToEcomBasketPage.test.jsx index 1f81edcd15..3d63b17c44 100644 --- a/src/components/course/enrollment/tests/ToEcomBasketPage.test.jsx +++ b/src/components/course/enrollment/tests/ToEcomBasketPage.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/course/tests/CourseAssociatedPrograms.test.jsx b/src/components/course/tests/CourseAssociatedPrograms.test.jsx index 797379651d..f3f007401d 100644 --- a/src/components/course/tests/CourseAssociatedPrograms.test.jsx +++ b/src/components/course/tests/CourseAssociatedPrograms.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/course/tests/CourseEnrollmentFailedAlert.test.jsx b/src/components/course/tests/CourseEnrollmentFailedAlert.test.jsx index 281e3f707e..f1d4817c57 100644 --- a/src/components/course/tests/CourseEnrollmentFailedAlert.test.jsx +++ b/src/components/course/tests/CourseEnrollmentFailedAlert.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { useLocation } from 'react-router-dom'; import { screen, render, diff --git a/src/components/course/tests/CoursePage.test.jsx b/src/components/course/tests/CoursePage.test.jsx index b821ec1192..a0ec5e6a64 100644 --- a/src/components/course/tests/CoursePage.test.jsx +++ b/src/components/course/tests/CoursePage.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/course/tests/CourseRecommendationCard.test.jsx b/src/components/course/tests/CourseRecommendationCard.test.jsx index 53e0e76f5c..1b4dbd359c 100644 --- a/src/components/course/tests/CourseRecommendationCard.test.jsx +++ b/src/components/course/tests/CourseRecommendationCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/course/tests/CourseRecommendations.test.jsx b/src/components/course/tests/CourseRecommendations.test.jsx index c65817c53f..d2578c42c5 100644 --- a/src/components/course/tests/CourseRecommendations.test.jsx +++ b/src/components/course/tests/CourseRecommendations.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/course/tests/CourseSidebarListItem.test.jsx b/src/components/course/tests/CourseSidebarListItem.test.jsx index 4c41fc1073..deb6e720fc 100644 --- a/src/components/course/tests/CourseSidebarListItem.test.jsx +++ b/src/components/course/tests/CourseSidebarListItem.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import renderer from 'react-test-renderer'; import '@testing-library/jest-dom/extend-expect'; import { Person } from '@openedx/paragon/icons'; diff --git a/src/components/course/tests/CourseSidebarPrice.test.jsx b/src/components/course/tests/CourseSidebarPrice.test.jsx index b99bc77573..581b697838 100644 --- a/src/components/course/tests/CourseSidebarPrice.test.jsx +++ b/src/components/course/tests/CourseSidebarPrice.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/course/tests/CourseSkills.test.jsx b/src/components/course/tests/CourseSkills.test.jsx index 596c719dc4..104152cb4d 100644 --- a/src/components/course/tests/CourseSkills.test.jsx +++ b/src/components/course/tests/CourseSkills.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/course/tests/CreatedBy.test.jsx b/src/components/course/tests/CreatedBy.test.jsx index e8bf52b543..59a3001f49 100644 --- a/src/components/course/tests/CreatedBy.test.jsx +++ b/src/components/course/tests/CreatedBy.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/course/tests/EnrollModal.test.jsx b/src/components/course/tests/EnrollModal.test.jsx index b93be3bce4..9a07afbbce 100644 --- a/src/components/course/tests/EnrollModal.test.jsx +++ b/src/components/course/tests/EnrollModal.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import '@testing-library/jest-dom/extend-expect'; import { screen, render } from '@testing-library/react'; diff --git a/src/components/course/tests/SubsidyRequestButton.test.jsx b/src/components/course/tests/SubsidyRequestButton.test.jsx index 92a73db2ea..e155400bdc 100644 --- a/src/components/course/tests/SubsidyRequestButton.test.jsx +++ b/src/components/course/tests/SubsidyRequestButton.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, render, waitFor } from '@testing-library/react'; import { useQueryClient } from '@tanstack/react-query'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/course/tests/VerifiedCertPitch.test.jsx b/src/components/course/tests/VerifiedCertPitch.test.jsx index 836344938d..9ff46fd9c9 100644 --- a/src/components/course/tests/VerifiedCertPitch.test.jsx +++ b/src/components/course/tests/VerifiedCertPitch.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import renderer from 'react-test-renderer'; import '@testing-library/jest-dom/extend-expect'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/dashboard/DashboardPage.jsx b/src/components/dashboard/DashboardPage.jsx index ab00599207..83b7140ade 100644 --- a/src/components/dashboard/DashboardPage.jsx +++ b/src/components/dashboard/DashboardPage.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { cloneElement, useContext } from 'react'; import { Helmet } from 'react-helmet'; import { Alert, Container, Tabs, useToggle, @@ -83,7 +83,7 @@ const DashboardPage = () => { activeKey={activeTab} onSelect={onSelectHandler} > - {tabs.map((tab) => React.cloneElement(tab, { key: tab.props.eventKey }))} + {tabs.map((tab) => cloneElement(tab, { key: tab.props.eventKey }))} {/* ExpiredSubscriptionModal is specifically tailored for learners with an expired license and is diff --git a/src/components/dashboard/SubscriptionExpirationModal.jsx b/src/components/dashboard/SubscriptionExpirationModal.jsx index 4e627f1767..3450180083 100644 --- a/src/components/dashboard/SubscriptionExpirationModal.jsx +++ b/src/components/dashboard/SubscriptionExpirationModal.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import { ActionRow, AlertModal, Button, MailtoLink, useToggle, } from '@openedx/paragon'; diff --git a/src/components/dashboard/data/dashboardLoader.ts b/src/components/dashboard/data/dashboardLoader.ts index a2bacc3a1d..469bf0e1ce 100644 --- a/src/components/dashboard/data/dashboardLoader.ts +++ b/src/components/dashboard/data/dashboardLoader.ts @@ -37,7 +37,13 @@ const makeDashboardLoader: Types.MakeRouteLoaderFunctionWithQueryClient = functi enterpriseSlug, }); - const dashboardBFFQuery = resolveBFFQuery(requestUrl.pathname, { enterpriseCustomerUuid: enterpriseCustomer.uuid }); + const dashboardBFFQuery = resolveBFFQuery( + requestUrl.pathname, + { + enterpriseCustomerUuid: enterpriseCustomer.uuid, + enterpriseFeatures: enterpriseCustomer.enterpriseFeatures, + }, + ); const loadEnrollmentsPoliciesAndRedirectForNewUsers = Promise.all([ queryClient.ensureQueryData( dashboardBFFQuery diff --git a/src/components/dashboard/main-content/CoursesTabComponent.jsx b/src/components/dashboard/main-content/CoursesTabComponent.jsx index 345e998187..9627d1d337 100644 --- a/src/components/dashboard/main-content/CoursesTabComponent.jsx +++ b/src/components/dashboard/main-content/CoursesTabComponent.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { Row, MediaQuery, diff --git a/src/components/dashboard/main-content/course-enrollments/CourseEnrollments.jsx b/src/components/dashboard/main-content/course-enrollments/CourseEnrollments.jsx index 5724533724..4c21763065 100644 --- a/src/components/dashboard/main-content/course-enrollments/CourseEnrollments.jsx +++ b/src/components/dashboard/main-content/course-enrollments/CourseEnrollments.jsx @@ -62,7 +62,7 @@ const CourseEnrollments = ({ children }) => { }, } = useEnterpriseCourseEnrollments(); - const { data: enterpriseFeatures } = useEnterpriseFeatures(); + const enterpriseFeatures = useEnterpriseFeatures(); const { hasCourseEnrollments, currentCourseEnrollments, diff --git a/src/components/dashboard/main-content/course-enrollments/CourseEnrollmentsEmptyState.jsx b/src/components/dashboard/main-content/course-enrollments/CourseEnrollmentsEmptyState.jsx index bd67a5a0e4..bcc55f62cd 100644 --- a/src/components/dashboard/main-content/course-enrollments/CourseEnrollmentsEmptyState.jsx +++ b/src/components/dashboard/main-content/course-enrollments/CourseEnrollmentsEmptyState.jsx @@ -11,7 +11,7 @@ import NewGroupAssignmentAlert from './NewGroupAssignmentAlert'; const CourseEnrollmentsEmptyState = () => { const { data: canOnlyViewHighlightSets } = useCanOnlyViewHighlights(); const { data: academies } = useAcademies(); - const { data: enterpriseFeatures } = useEnterpriseFeatures(); + const enterpriseFeatures = useEnterpriseFeatures(); const { showNewGroupAssociationAlert, dismissGroupAssociationAlert, diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/CompletedCourseCard.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/CompletedCourseCard.jsx index 8bd4464f56..790e46e497 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/CompletedCourseCard.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/CompletedCourseCard.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import PropTypes from 'prop-types'; import { AppContext } from '@edx/frontend-platform/react'; import { getConfig } from '@edx/frontend-platform/config'; diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/Notification.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/Notification.jsx index 17fb938f81..9887b4929a 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/Notification.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/Notification.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils'; diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/RequestedCourseCard.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/RequestedCourseCard.jsx index 5ac730809f..32625858ea 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/RequestedCourseCard.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/RequestedCourseCard.jsx @@ -1,8 +1,6 @@ -import React from 'react'; import PropTypes from 'prop-types'; import BaseCourseCard from './BaseCourseCard'; - import { COURSE_STATUSES } from '../data/constants'; const RequestedCourseCard = (props) => ( diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/SavedForLaterCourseCard.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/SavedForLaterCourseCard.jsx index df80ee9eae..0298d832f6 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/SavedForLaterCourseCard.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/SavedForLaterCourseCard.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import { useState } from 'react'; import PropTypes from 'prop-types'; import { useNavigate } from 'react-router-dom'; import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils'; diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/email-settings/EmailSettingsModal.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/email-settings/EmailSettingsModal.jsx index 0b23b63ef9..43e5da6dda 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/email-settings/EmailSettingsModal.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/email-settings/EmailSettingsModal.jsx @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import { Component } from 'react'; import PropTypes from 'prop-types'; import { Form, Alert, StatefulButton, ActionRow, Button, StandardModal, diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/email-settings/tests/EmailSettingsModal.test.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/email-settings/tests/EmailSettingsModal.test.jsx index 459c56d25d..2f072ccdbb 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/email-settings/tests/EmailSettingsModal.test.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/email-settings/tests/EmailSettingsModal.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { mount } from 'enzyme'; import { StatefulButton } from '@openedx/paragon'; diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/MarkCompleteModal.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/MarkCompleteModal.jsx index 15bcd617b5..d77dace05f 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/MarkCompleteModal.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/MarkCompleteModal.jsx @@ -1,4 +1,4 @@ -import React, { useState, useMemo } from 'react'; +import { useState, useMemo } from 'react'; import PropTypes from 'prop-types'; import { ActionRow, Button, StandardModal, StatefulButton, diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/ModalBody.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/ModalBody.jsx index 7efbde7724..585c5e03f1 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/ModalBody.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/ModalBody.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import ModalError from './ModalError'; import MarkCompleteModalContext from './MarkCompleteModalContext'; diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/ModalError.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/ModalError.jsx index 024de5a82b..5efbf06812 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/ModalError.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/ModalError.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import { Alert } from '@openedx/paragon'; import { Error } from '@openedx/paragon/icons'; diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/tests/MarkCompleteModal.test.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/tests/MarkCompleteModal.test.jsx index 19df155ed5..27edeee275 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/tests/MarkCompleteModal.test.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/mark-complete-modal/tests/MarkCompleteModal.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { mount } from 'enzyme'; import { act } from 'react-dom/test-utils'; diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/move-to-in-progress-modal/ModalBody.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/move-to-in-progress-modal/ModalBody.jsx index 9c2227e2f8..6aabe72978 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/move-to-in-progress-modal/ModalBody.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/move-to-in-progress-modal/ModalBody.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import ModalError from './ModalError'; import MoveToInProgressModalContext from './MoveToInProgressModalContext'; diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/move-to-in-progress-modal/ModalError.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/move-to-in-progress-modal/ModalError.jsx index 8d5a3a92e3..63689db7f2 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/move-to-in-progress-modal/ModalError.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/move-to-in-progress-modal/ModalError.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import { Alert } from '@openedx/paragon'; import { Error } from '@openedx/paragon/icons'; diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/move-to-in-progress-modal/MoveToInProgressModal.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/move-to-in-progress-modal/MoveToInProgressModal.jsx index f91cab4734..304f60ad93 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/move-to-in-progress-modal/MoveToInProgressModal.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/move-to-in-progress-modal/MoveToInProgressModal.jsx @@ -1,4 +1,4 @@ -import React, { useState, useMemo } from 'react'; +import { useState, useMemo } from 'react'; import PropTypes from 'prop-types'; import { ActionRow, Button, StandardModal, StatefulButton, diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/tests/AssignedCourseCard.test.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/tests/AssignedCourseCard.test.jsx index 488b957326..d973f3ebcf 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/tests/AssignedCourseCard.test.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/tests/AssignedCourseCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/tests/BaseCourseCard.test.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/tests/BaseCourseCard.test.jsx index a0a1e55e0a..ccd2d77421 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/tests/BaseCourseCard.test.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/tests/BaseCourseCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { renderWithRouter } from '@edx/frontend-enterprise-utils'; import { IntlProvider } from '@edx/frontend-platform/i18n'; @@ -11,7 +10,7 @@ import { QueryClientProvider } from '@tanstack/react-query'; import dayjs from '../../../../../../utils/dayjs'; import BaseCourseCard from '../BaseCourseCard'; import { ToastsContext } from '../../../../../Toasts'; -import { useEnterpriseCustomer } from '../../../../../app/data'; +import { useEnterpriseCustomer, useIsBFFEnabled } from '../../../../../app/data'; import { queryClient } from '../../../../../../utils/tests'; import { @@ -30,6 +29,7 @@ jest.mock('@edx/frontend-enterprise-utils', () => ({ jest.mock('../../../../../app/data', () => ({ ...jest.requireActual('../../../../../app/data'), useEnterpriseCustomer: jest.fn(), + useIsBFFEnabled: jest.fn(), })); const mockAddToast = jest.fn(); @@ -53,6 +53,7 @@ describe('', () => { beforeEach(() => { jest.clearAllMocks(); useEnterpriseCustomer.mockReturnValue({ data: mockEnterpriseCustomer }); + useIsBFFEnabled.mockReturnValue(false); }); afterEach(() => { diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/tests/InProgressCourseCard.test.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/tests/InProgressCourseCard.test.jsx index d5682bb8c0..38889cf971 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/tests/InProgressCourseCard.test.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/tests/InProgressCourseCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { act, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import '@testing-library/jest-dom/extend-expect'; @@ -15,6 +14,7 @@ import { LICENSE_SUBSIDY_TYPE, useCouponCodes, useEnterpriseCustomer, + useIsBFFEnabled, } from '../../../../../app/data'; import { queryClient } from '../../../../../../utils/tests'; import { authenticatedUserFactory, enterpriseCustomerFactory } from '../../../../../app/data/services/data/__factories__'; @@ -49,6 +49,7 @@ jest.mock('../../../../../app/data', () => ({ ...jest.requireActual('../../../../../app/data'), useEnterpriseCustomer: jest.fn(), useCouponCodes: jest.fn(), + useIsBFFEnabled: jest.fn(), })); const InProgressCourseCardWrapper = ({ @@ -78,6 +79,7 @@ describe('', () => { beforeEach(() => { jest.clearAllMocks(); + useIsBFFEnabled.mockReturnValue(false); useEnterpriseCustomer.mockReturnValue({ data: mockEnterpriseCustomer }); useCourseUpgradeData.mockReturnValue({ subsidyForCourse: null, diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/unenroll/UnenrollModal.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/unenroll/UnenrollModal.jsx index 87293009d0..3c6676fd1a 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/unenroll/UnenrollModal.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/unenroll/UnenrollModal.jsx @@ -9,10 +9,10 @@ import { logError, logInfo } from '@edx/frontend-platform/logging'; import { ToastsContext } from '../../../../../Toasts'; import { unenrollFromCourse } from './data'; import { - isBFFEnabledForEnterpriseCustomer, queryEnterpriseCourseEnrollments, queryEnterpriseLearnerDashboardBFF, useEnterpriseCustomer, + useIsBFFEnabled, } from '../../../../../app/data'; const btnLabels = { @@ -32,6 +32,8 @@ const UnenrollModal = ({ const [btnState, setBtnState] = useState('default'); const [error, setError] = useState(null); + const isBFFEnabled = useIsBFFEnabled(); + const handleClose = () => { setBtnState('default'); setError(null); @@ -41,7 +43,6 @@ const UnenrollModal = ({ const updateQueriesAfterUnenrollment = () => { const enrollmentForCourseFilter = (enrollment) => enrollment.courseRunId !== courseRunId; - const isBFFEnabled = isBFFEnabledForEnterpriseCustomer(enterpriseCustomer.uuid); if (isBFFEnabled) { // Determine which BFF queries need to be updated after unenrolling. const dashboardBFFQueryKey = queryEnterpriseLearnerDashboardBFF({ diff --git a/src/components/dashboard/main-content/course-enrollments/course-cards/unenroll/UnenrollModal.test.jsx b/src/components/dashboard/main-content/course-enrollments/course-cards/unenroll/UnenrollModal.test.jsx index 698691d9cf..5369687c8a 100644 --- a/src/components/dashboard/main-content/course-enrollments/course-cards/unenroll/UnenrollModal.test.jsx +++ b/src/components/dashboard/main-content/course-enrollments/course-cards/unenroll/UnenrollModal.test.jsx @@ -8,11 +8,11 @@ import { unenrollFromCourse } from './data'; import UnenrollModal from './UnenrollModal'; import { ToastsContext } from '../../../../../Toasts'; import { - isBFFEnabledForEnterpriseCustomer, learnerDashboardBFFResponse, queryEnterpriseCourseEnrollments, queryEnterpriseLearnerDashboardBFF, useEnterpriseCustomer, + useIsBFFEnabled, } from '../../../../../app/data'; import { queryClient } from '../../../../../../utils/tests'; import { @@ -31,7 +31,7 @@ jest.mock('@edx/frontend-platform/logging', () => ({ jest.mock('../../../../../app/data', () => ({ ...jest.requireActual('../../../../../app/data'), useEnterpriseCustomer: jest.fn(), - isBFFEnabledForEnterpriseCustomer: jest.fn(), + useIsBFFEnabled: jest.fn(), fetchEnterpriseLearnerDashboard: jest.fn(), })); @@ -92,7 +92,7 @@ describe('', () => { beforeEach(() => { jest.clearAllMocks(); useEnterpriseCustomer.mockReturnValue({ data: mockEnterpriseCustomer }); - isBFFEnabledForEnterpriseCustomer.mockReturnValue(false); + useIsBFFEnabled.mockReturnValue(false); }); test('should remain closed when `isOpen` is false', () => { @@ -173,7 +173,7 @@ describe('', () => { existingBFFDashboardQueryData, existingEnrollmentsQueryData, }) => { - isBFFEnabledForEnterpriseCustomer.mockReturnValue(isBFFEnabled); + useIsBFFEnabled.mockReturnValue(isBFFEnabled); unenrollFromCourse.mockResolvedValueOnce(); const props = { ...baseUnenrollModalProps, 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 76ac6483e4..7e6e3fdc3a 100644 --- a/src/components/dashboard/main-content/course-enrollments/data/hooks.js +++ b/src/components/dashboard/main-content/course-enrollments/data/hooks.js @@ -24,7 +24,6 @@ import { COUPON_CODE_SUBSIDY_TYPE, getSubsidyToApplyForCourse, groupCourseEnrollmentsByStatus, - isBFFEnabledForEnterpriseCustomer, isEnrollmentUpgradeable, LEARNER_CREDIT_SUBSIDY_TYPE, LICENSE_SUBSIDY_TYPE, @@ -40,6 +39,7 @@ import { useEnterpriseCustomerContainsContent, useRedeemablePolicies, useSubscriptions, + useIsBFFEnabled, } from '../../../../app/data'; import { sortAssignmentsByAssignmentStatus, sortedEnrollmentsByEnrollmentDate } from './utils'; import { ASSIGNMENTS_EXPIRING_WARNING_LOCALSTORAGE_KEY } from '../../../data/constants'; @@ -546,6 +546,9 @@ export function useCourseEnrollmentsBySection(courseEnrollmentsByStatus) { export function useUpdateCourseEnrollmentStatus() { const queryClient = useQueryClient(); const { data: enterpriseCustomer } = useEnterpriseCustomer(); + + const isBFFEnabled = useIsBFFEnabled(); + return useCallback(({ courseRunId, newStatus }) => { // Transformation to update the course enrollment status. const transformUpdatedEnrollment = (enrollment) => { @@ -558,7 +561,6 @@ export function useUpdateCourseEnrollmentStatus() { }; }; - const isBFFEnabled = isBFFEnabledForEnterpriseCustomer(enterpriseCustomer.uuid); if (isBFFEnabled) { // Determine which BFF queries need to be updated after updating enrollment status. const dashboardBFFQueryKey = queryEnterpriseLearnerDashboardBFF({ @@ -590,7 +592,7 @@ export function useUpdateCourseEnrollmentStatus() { } const updatedCourseEnrollmentsData = existingCourseEnrollmentsData.map(transformUpdatedEnrollment); queryClient.setQueryData(enterpriseCourseEnrollmentsQueryKey, updatedCourseEnrollmentsData); - }, [queryClient, enterpriseCustomer]); + }, [queryClient, enterpriseCustomer, isBFFEnabled]); } /** diff --git a/src/components/dashboard/main-content/course-enrollments/data/tests/hooks.test.jsx b/src/components/dashboard/main-content/course-enrollments/data/tests/hooks.test.jsx index 5be4e23700..ee526f1fe1 100644 --- a/src/components/dashboard/main-content/course-enrollments/data/tests/hooks.test.jsx +++ b/src/components/dashboard/main-content/course-enrollments/data/tests/hooks.test.jsx @@ -30,7 +30,6 @@ import { COURSE_MODES_MAP, emptyRedeemableLearnerCreditPolicies, ENROLL_BY_DATE_WARNING_THRESHOLD_DAYS, - isBFFEnabledForEnterpriseCustomer, learnerDashboardBFFResponse, queryEnterpriseCourseEnrollments, queryEnterpriseLearnerDashboardBFF, @@ -42,6 +41,7 @@ import { useEnterpriseCourseEnrollments, useEnterpriseCustomer, useEnterpriseCustomerContainsContent, + useIsBFFEnabled, useRedeemablePolicies, useSubscriptions, } from '../../../../../app/data'; @@ -77,7 +77,7 @@ jest.mock('../../../../../app/data', () => ({ useCanUpgradeWithLearnerCredit: jest.fn(), useEnterpriseCustomerContainsContent: jest.fn(), useCourseRunMetadata: jest.fn(), - isBFFEnabledForEnterpriseCustomer: jest.fn(), + useIsBFFEnabled: jest.fn(), })); jest.mock('../../../../../course/data/hooks', () => ({ ...jest.requireActual('../../../../../course/data/hooks'), @@ -1213,7 +1213,7 @@ describe('useUpdateCourseEnrollmentStatus', () => { existingBFFDashboardQueryData, existingEnrollmentsQueryData, }) => { - isBFFEnabledForEnterpriseCustomer.mockReturnValue(isBFFEnabled); + useIsBFFEnabled.mockReturnValue(isBFFEnabled); const mockCorrectCourseRunId = mockEnterpriseCourseEnrollment.courseRunId; const mockIncorrectCourseRunId = 'course-v1:edX+DemoY+Demo'; const mockCourseRunId = doesCourseRunIdMatch ? mockCorrectCourseRunId : mockIncorrectCourseRunId; diff --git a/src/components/dashboard/main-content/course-enrollments/tests/CourseEnrollments.test.jsx b/src/components/dashboard/main-content/course-enrollments/tests/CourseEnrollments.test.jsx index 88f27e3121..33118e1128 100644 --- a/src/components/dashboard/main-content/course-enrollments/tests/CourseEnrollments.test.jsx +++ b/src/components/dashboard/main-content/course-enrollments/tests/CourseEnrollments.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, waitFor, within } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { IntlProvider } from '@edx/frontend-platform/i18n'; @@ -25,6 +24,7 @@ import { useEnterpriseCourseEnrollments, useEnterpriseCustomer, useEnterpriseFeatures, + useIsBFFEnabled, } from '../../../../app/data'; import { sortAssignmentsByAssignmentStatus } from '../data/utils'; import { authenticatedUserFactory, enterpriseCustomerFactory } from '../../../../app/data/services/data/__factories__'; @@ -60,11 +60,17 @@ jest.mock('../../../../../config', () => ({ FEATURE_ENABLE_TOP_DOWN_ASSIGNMENT: true, }, })); - jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), useLocation: jest.fn(), })); +jest.mock('../../../../app/data', () => ({ + ...jest.requireActual('../../../../app/data'), + useEnterpriseCourseEnrollments: jest.fn(), + useEnterpriseCustomer: jest.fn(), + useEnterpriseFeatures: jest.fn(), + useIsBFFEnabled: jest.fn(), +})); const inProgCourseRun = createCourseEnrollmentWithStatus({ status: COURSE_STATUSES.inProgress }); const upcomingCourseRun = createCourseEnrollmentWithStatus({ status: COURSE_STATUSES.upcoming }); @@ -103,13 +109,6 @@ const assignmentData = { state: 'cancelled', }; -jest.mock('../../../../app/data', () => ({ - ...jest.requireActual('../../../../app/data'), - useEnterpriseCourseEnrollments: jest.fn(), - useEnterpriseCustomer: jest.fn(), - useEnterpriseFeatures: jest.fn(), -})); - const mockAuthenticatedUser = authenticatedUserFactory(); const mockEnterpriseCustomer = enterpriseCustomerFactory(); @@ -136,6 +135,7 @@ describe('Course enrollments', () => { beforeEach(() => { jest.clearAllMocks(); useLocation.mockReturnValue({}); + useIsBFFEnabled.mockReturnValue(false); useEnterpriseCustomer.mockReturnValue({ data: mockEnterpriseCustomer }); useEnterpriseCourseEnrollments.mockReturnValue({ data: { @@ -152,7 +152,7 @@ describe('Course enrollments', () => { updateCourseCompleteStatusRequest.mockImplementation(() => ({ data: {} })); sortAssignmentsByAssignmentStatus.mockReturnValue([assignmentData]); - useEnterpriseFeatures.mockReturnValue({ data: { enterpriseGroupsV1: false } }); + useEnterpriseFeatures.mockReturnValue({ enterpriseGroupsV1: false }); useGroupAssociationsAlert.mockReturnValue({ showNewGroupAssociationAlert: true, dismissGroupAssociationAlert: mockDismissGroupAssociationAlert, @@ -277,7 +277,7 @@ describe('Course enrollments', () => { it( 'renders NewGroupAssignmentAlert when showNewGroupAssociationAlert is true', async () => { - useEnterpriseFeatures.mockReturnValue({ data: { enterpriseGroupsV1: true } }); + useEnterpriseFeatures.mockReturnValue({ enterpriseGroupsV1: true }); useGroupAssociationsAlert.mockReturnValue({ showNewGroupAssociationAlert: true, dismissGroupAssociationAlert: mockDismissGroupAssociationAlert, diff --git a/src/components/dashboard/sidebar/CouponCodesSummaryCard.jsx b/src/components/dashboard/sidebar/CouponCodesSummaryCard.jsx index a066860439..e4834153f4 100644 --- a/src/components/dashboard/sidebar/CouponCodesSummaryCard.jsx +++ b/src/components/dashboard/sidebar/CouponCodesSummaryCard.jsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; import PropTypes from 'prop-types'; import { Badge, Card, Stack, useToggle, diff --git a/src/components/dashboard/sidebar/DashboardSidebar.jsx b/src/components/dashboard/sidebar/DashboardSidebar.jsx index 0eb296162e..95505a6287 100644 --- a/src/components/dashboard/sidebar/DashboardSidebar.jsx +++ b/src/components/dashboard/sidebar/DashboardSidebar.jsx @@ -1,6 +1,5 @@ -import React from 'react'; - import { Card } from '@openedx/paragon'; + import SupportInformation from './SupportInformation'; import SubsidiesSummary from './SubsidiesSummary'; diff --git a/src/components/dashboard/sidebar/LearnerCreditSummaryCard.jsx b/src/components/dashboard/sidebar/LearnerCreditSummaryCard.jsx index 6bd3f74d5d..5999013318 100644 --- a/src/components/dashboard/sidebar/LearnerCreditSummaryCard.jsx +++ b/src/components/dashboard/sidebar/LearnerCreditSummaryCard.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Badge, Card, Stack } from '@openedx/paragon'; import dayjs from 'dayjs'; diff --git a/src/components/dashboard/sidebar/SubscriptionSummaryCard.jsx b/src/components/dashboard/sidebar/SubscriptionSummaryCard.jsx index a09489e557..c735a86a2b 100644 --- a/src/components/dashboard/sidebar/SubscriptionSummaryCard.jsx +++ b/src/components/dashboard/sidebar/SubscriptionSummaryCard.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Badge, Card, Stack } from '@openedx/paragon'; import { defineMessages, FormattedMessage } from '@edx/frontend-platform/i18n'; diff --git a/src/components/dashboard/sidebar/data/hooks/useSubscriptionSummaryCard.jsx b/src/components/dashboard/sidebar/data/hooks/useSubscriptionSummaryCard.jsx index ea9de759bb..09d5aeec1c 100644 --- a/src/components/dashboard/sidebar/data/hooks/useSubscriptionSummaryCard.jsx +++ b/src/components/dashboard/sidebar/data/hooks/useSubscriptionSummaryCard.jsx @@ -1,5 +1,4 @@ import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n'; -import React from 'react'; import { Card, useToggle } from '@openedx/paragon'; import { WarningFilled } from '@openedx/paragon/icons'; import { useBrowseAndRequest, useSubscriptions } from '../../../../app/data'; diff --git a/src/components/dashboard/sidebar/tests/CouponCodesSummaryCard.test.jsx b/src/components/dashboard/sidebar/tests/CouponCodesSummaryCard.test.jsx index 3baf1ff9a9..28043aa0df 100644 --- a/src/components/dashboard/sidebar/tests/CouponCodesSummaryCard.test.jsx +++ b/src/components/dashboard/sidebar/tests/CouponCodesSummaryCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { screen, render } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/dashboard/sidebar/tests/DashboardSidebar.test.jsx b/src/components/dashboard/sidebar/tests/DashboardSidebar.test.jsx index 726a52932f..6c7637268d 100644 --- a/src/components/dashboard/sidebar/tests/DashboardSidebar.test.jsx +++ b/src/components/dashboard/sidebar/tests/DashboardSidebar.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import dayjs from 'dayjs'; import '@testing-library/jest-dom/extend-expect'; import { screen } from '@testing-library/react'; diff --git a/src/components/dashboard/sidebar/tests/LearnerCreditSummaryCard.test.jsx b/src/components/dashboard/sidebar/tests/LearnerCreditSummaryCard.test.jsx index 43c4c7862a..db772a18f8 100644 --- a/src/components/dashboard/sidebar/tests/LearnerCreditSummaryCard.test.jsx +++ b/src/components/dashboard/sidebar/tests/LearnerCreditSummaryCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { render, screen } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/dashboard/sidebar/tests/SubscriptionSummaryCard.test.jsx b/src/components/dashboard/sidebar/tests/SubscriptionSummaryCard.test.jsx index 376ba46e8f..c57ed0992f 100644 --- a/src/components/dashboard/sidebar/tests/SubscriptionSummaryCard.test.jsx +++ b/src/components/dashboard/sidebar/tests/SubscriptionSummaryCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { screen } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/dashboard/tests/CourseRecommendations.test.jsx b/src/components/dashboard/tests/CourseRecommendations.test.jsx index 0ac8a99916..c137462343 100644 --- a/src/components/dashboard/tests/CourseRecommendations.test.jsx +++ b/src/components/dashboard/tests/CourseRecommendations.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { screen } from '@testing-library/react'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/dashboard/tests/DashboardPage.test.jsx b/src/components/dashboard/tests/DashboardPage.test.jsx index e0d1e76165..982b768c00 100644 --- a/src/components/dashboard/tests/DashboardPage.test.jsx +++ b/src/components/dashboard/tests/DashboardPage.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { screen, waitFor } from '@testing-library/react'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/enterprise-banner/tests/EnterpriseBanner.test.jsx b/src/components/enterprise-banner/tests/EnterpriseBanner.test.jsx index 53612c34ad..4ca17cd05f 100644 --- a/src/components/enterprise-banner/tests/EnterpriseBanner.test.jsx +++ b/src/components/enterprise-banner/tests/EnterpriseBanner.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { screen } from '@testing-library/react'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/enterprise-page/EnterprisePage.jsx b/src/components/enterprise-page/EnterprisePage.jsx index b4024a549f..963f4b8c2e 100644 --- a/src/components/enterprise-page/EnterprisePage.jsx +++ b/src/components/enterprise-page/EnterprisePage.jsx @@ -1,4 +1,4 @@ -import React, { useContext, useEffect, useMemo } from 'react'; +import { useContext, useEffect, useMemo } from 'react'; import PropTypes from 'prop-types'; import { AppContext } from '@edx/frontend-platform/react'; import { getConfig } from '@edx/frontend-platform/config'; @@ -7,7 +7,7 @@ import { getLoggingService } from '@edx/frontend-platform/logging'; import { isDefinedAndNotNull } from '../../utils/common'; import { useAlgoliaSearch } from '../../utils/hooks'; import { pushUserCustomerAttributes } from '../../utils/optimizely'; -import { isBFFEnabledForEnterpriseCustomer, useEnterpriseCustomer } from '../app/data'; +import { useEnterpriseCustomer, useIsBFFEnabled } from '../app/data'; /** * Custom hook to set custom attributes for logging service: @@ -16,6 +16,8 @@ import { isBFFEnabledForEnterpriseCustomer, useEnterpriseCustomer } from '../app */ function useLoggingCustomAttributes() { const { data: enterpriseCustomer } = useEnterpriseCustomer(); + const isBFFEnabled = useIsBFFEnabled(); + useEffect(() => { if (isDefinedAndNotNull(enterpriseCustomer)) { pushUserCustomerAttributes(enterpriseCustomer); @@ -23,12 +25,9 @@ function useLoggingCustomAttributes() { // Set custom attributes via logging service const loggingService = getLoggingService(); loggingService.setCustomAttribute('enterprise_customer_uuid', enterpriseCustomer.uuid); - loggingService.setCustomAttribute( - 'is_bff_enabled', - isBFFEnabledForEnterpriseCustomer(enterpriseCustomer.uuid), - ); + loggingService.setCustomAttribute('is_bff_enabled', isBFFEnabled); } - }, [enterpriseCustomer]); + }, [enterpriseCustomer, isBFFEnabled]); } const EnterprisePage = ({ children }) => { diff --git a/src/components/enterprise-page/EnterprisePage.test.jsx b/src/components/enterprise-page/EnterprisePage.test.jsx index 29de7aa7a9..c116fbd4f1 100644 --- a/src/components/enterprise-page/EnterprisePage.test.jsx +++ b/src/components/enterprise-page/EnterprisePage.test.jsx @@ -4,13 +4,13 @@ import { AppContext } from '@edx/frontend-platform/react'; import { getLoggingService } from '@edx/frontend-platform/logging'; import EnterprisePage from './EnterprisePage'; -import { isBFFEnabledForEnterpriseCustomer, useEnterpriseCustomer } from '../app/data'; +import { useEnterpriseCustomer, useIsBFFEnabled } from '../app/data'; import { authenticatedUserFactory, enterpriseCustomerFactory } from '../app/data/services/data/__factories__'; jest.mock('../app/data', () => ({ ...jest.requireActual('../app/data'), useEnterpriseCustomer: jest.fn(), - isBFFEnabledForEnterpriseCustomer: jest.fn().mockReturnValue(false), + useIsBFFEnabled: jest.fn().mockReturnValue(false), })); const mockEnterpriseCustomer = enterpriseCustomerFactory(); @@ -82,7 +82,7 @@ describe('', () => { { isBFFEnabled: true }, ])('sets custom attributes via logging service (%s)', ({ isBFFEnabled }) => { // Mock the BFF feature flag - isBFFEnabledForEnterpriseCustomer.mockReturnValue(isBFFEnabled); + useIsBFFEnabled.mockReturnValue(isBFFEnabled); // Mount the component const wrapper = mount( diff --git a/src/components/enterprise-user-subsidy/enterprise-offers/EnterpriseOffersBalanceAlert.jsx b/src/components/enterprise-user-subsidy/enterprise-offers/EnterpriseOffersBalanceAlert.jsx index 94c8bf392d..4792f6a58c 100644 --- a/src/components/enterprise-user-subsidy/enterprise-offers/EnterpriseOffersBalanceAlert.jsx +++ b/src/components/enterprise-user-subsidy/enterprise-offers/EnterpriseOffersBalanceAlert.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import classNames from 'classnames'; import PropTypes from 'prop-types'; diff --git a/src/components/enterprise-user-subsidy/enterprise-offers/tests/EnterpriseOffersBalanceAlert.test.jsx b/src/components/enterprise-user-subsidy/enterprise-offers/tests/EnterpriseOffersBalanceAlert.test.jsx index 683e811468..94b9af18c0 100644 --- a/src/components/enterprise-user-subsidy/enterprise-offers/tests/EnterpriseOffersBalanceAlert.test.jsx +++ b/src/components/enterprise-user-subsidy/enterprise-offers/tests/EnterpriseOffersBalanceAlert.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/error-page/ErrorPage.test.jsx b/src/components/error-page/ErrorPage.test.jsx index e1a2b10da8..ca4b6c67f6 100644 --- a/src/components/error-page/ErrorPage.test.jsx +++ b/src/components/error-page/ErrorPage.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import renderer from 'react-test-renderer'; import { AppContext } from '@edx/frontend-platform/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/error-page/ErrorPageContent.jsx b/src/components/error-page/ErrorPageContent.jsx index d0bfb24994..ee885dceaf 100644 --- a/src/components/error-page/ErrorPageContent.jsx +++ b/src/components/error-page/ErrorPageContent.jsx @@ -1,8 +1,5 @@ -import React from 'react'; import PropTypes from 'prop-types'; -import { - Container, -} from '@openedx/paragon'; +import { Container } from '@openedx/paragon'; import classNames from 'classnames'; /** diff --git a/src/components/error-page/ErrorPageHeader.jsx b/src/components/error-page/ErrorPageHeader.jsx index b533c3213d..290cd55abe 100644 --- a/src/components/error-page/ErrorPageHeader.jsx +++ b/src/components/error-page/ErrorPageHeader.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import { AvatarButton, Container, diff --git a/src/components/executive-education-2u/EnrollmentCompletedSummaryCard.test.jsx b/src/components/executive-education-2u/EnrollmentCompletedSummaryCard.test.jsx index 8e07477f60..13afc806f0 100644 --- a/src/components/executive-education-2u/EnrollmentCompletedSummaryCard.test.jsx +++ b/src/components/executive-education-2u/EnrollmentCompletedSummaryCard.test.jsx @@ -1,7 +1,6 @@ import { screen } from '@testing-library/react'; import '@testing-library/jest-dom'; import { IntlProvider } from '@edx/frontend-platform/i18n'; -import React from 'react'; import EnrollmentCompletedSummaryCard from './components/EnrollmentCompletedSummaryCard'; import { renderWithRouterProvider } from '../../utils/tests'; diff --git a/src/components/executive-education-2u/ExecutiveEducation2UError.jsx b/src/components/executive-education-2u/ExecutiveEducation2UError.jsx index 9c71e13485..205b32e4fa 100644 --- a/src/components/executive-education-2u/ExecutiveEducation2UError.jsx +++ b/src/components/executive-education-2u/ExecutiveEducation2UError.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { defineMessages, useIntl } from '@edx/frontend-platform/i18n'; diff --git a/src/components/executive-education-2u/UserEnrollmentForm.jsx b/src/components/executive-education-2u/UserEnrollmentForm.jsx index ba26fc81a5..d1fac9a944 100644 --- a/src/components/executive-education-2u/UserEnrollmentForm.jsx +++ b/src/components/executive-education-2u/UserEnrollmentForm.jsx @@ -1,4 +1,4 @@ -import React, { useContext, useState } from 'react'; +import { useContext, useState } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import PropTypes from 'prop-types'; import { @@ -20,7 +20,6 @@ import { checkoutExecutiveEducation2U, isDuplicateExternalCourseOrder, toISOStri import { useStatefulEnroll } from '../stateful-enroll/data'; import { CourseContext } from '../course/CourseContextProvider'; import { - isBFFEnabledForEnterpriseCustomer, LEARNER_CREDIT_SUBSIDY_TYPE, queryCanRedeemContextQueryKey, queryEnterpriseCourseEnrollments, @@ -29,6 +28,7 @@ import { useCourseMetadata, useEnterpriseCourseEnrollments, useEnterpriseCustomer, + useIsBFFEnabled, } from '../app/data'; import { useUserSubsidyApplicableToCourse } from '../course/data'; @@ -49,13 +49,14 @@ const UserEnrollmentForm = ({ className }) => { setExternalCourseFormSubmissionError, } = useContext(CourseContext); + const isBFFEnabled = useIsBFFEnabled(); + const { data: { courseEntitlementProductSku } } = useCourseMetadata(); const [isFormSubmitted, setIsFormSubmitted] = useState(false); const [enrollButtonState, setEnrollButtonState] = useState('default'); const handleQueryInvalidationForEnrollSuccess = () => { - const isBFFEnabled = isBFFEnabledForEnterpriseCustomer(enterpriseCustomer.uuid); const canRedeemQueryKey = queryCanRedeemContextQueryKey(enterpriseCustomer.uuid, courseKey); const redeemablePoliciesQueryKey = queryRedeemablePolicies({ enterpriseUuid: enterpriseCustomer.uuid, diff --git a/src/components/executive-education-2u/UserEnrollmentForm.test.jsx b/src/components/executive-education-2u/UserEnrollmentForm.test.jsx index 9c7b9bef54..df08f272f3 100644 --- a/src/components/executive-education-2u/UserEnrollmentForm.test.jsx +++ b/src/components/executive-education-2u/UserEnrollmentForm.test.jsx @@ -21,8 +21,8 @@ import { useCourseMetadata, useEnterpriseCourseEnrollments, useEnterpriseCustomer, - isBFFEnabledForEnterpriseCustomer, queryEnterpriseLearnerDashboardBFF, + useIsBFFEnabled, } from '../app/data'; import { authenticatedUserFactory, enterpriseCustomerFactory } from '../app/data/services/data/__factories__'; import { queryClient, renderWithRouter, renderWithRouterProvider } from '../../utils/tests'; @@ -61,7 +61,7 @@ jest.mock('../app/data', () => ({ useEnterpriseCustomer: jest.fn(), useEnterpriseCourseEnrollments: jest.fn(), useCourseMetadata: jest.fn(), - isBFFEnabledForEnterpriseCustomer: jest.fn(), + useIsBFFEnabled: jest.fn(), })); jest.mock('../course/data', () => ({ @@ -135,7 +135,7 @@ describe('UserEnrollmentForm', () => { missingUserSubsidyReason: undefined, }); useCourseMetadata.mockReturnValue({ data: {} }); - isBFFEnabledForEnterpriseCustomer.mockReturnValue(false); + useIsBFFEnabled.mockReturnValue(false); }); afterEach(() => { @@ -253,7 +253,7 @@ describe('UserEnrollmentForm', () => { }) => { const mockTermsAcceptedAt = '2022-09-28T13:35:06Z'; MockDate.set(mockTermsAcceptedAt); - isBFFEnabledForEnterpriseCustomer.mockReturnValue(isBFFEnabled); + useIsBFFEnabled.mockReturnValue(isBFFEnabled); useUserSubsidyApplicableToCourse.mockReturnValue({ userSubsidyApplicableToCourse: { subsidyType: LEARNER_CREDIT_SUBSIDY_TYPE, diff --git a/src/components/executive-education-2u/components/RegistrationSummaryCard.jsx b/src/components/executive-education-2u/components/RegistrationSummaryCard.jsx index 077ff43373..a5c7c1cf82 100644 --- a/src/components/executive-education-2u/components/RegistrationSummaryCard.jsx +++ b/src/components/executive-education-2u/components/RegistrationSummaryCard.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Card, Col, Row } from '@openedx/paragon'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; diff --git a/src/components/integration-warning-modal/IntegrationWarningModal.jsx b/src/components/integration-warning-modal/IntegrationWarningModal.jsx index 27c97b2bc2..76a8e5db81 100644 --- a/src/components/integration-warning-modal/IntegrationWarningModal.jsx +++ b/src/components/integration-warning-modal/IntegrationWarningModal.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import { useState } from 'react'; import PropTypes from 'prop-types'; import Cookies from 'universal-cookie'; import { Button, AlertModal } from '@openedx/paragon'; diff --git a/src/components/integration-warning-modal/ModalBody.jsx b/src/components/integration-warning-modal/ModalBody.jsx index bc0e98fed8..79dcb698e3 100644 --- a/src/components/integration-warning-modal/ModalBody.jsx +++ b/src/components/integration-warning-modal/ModalBody.jsx @@ -1,5 +1,3 @@ -import React from 'react'; - const ModalBody = () => (

diff --git a/src/components/layout/MainContent.jsx b/src/components/layout/MainContent.jsx index cfb3e94231..28308ea1c7 100644 --- a/src/components/layout/MainContent.jsx +++ b/src/components/layout/MainContent.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; const MainContent = props => ( diff --git a/src/components/layout/Sidebar.jsx b/src/components/layout/Sidebar.jsx index ae803f6cfd..07053a9dbd 100644 --- a/src/components/layout/Sidebar.jsx +++ b/src/components/layout/Sidebar.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; const Sidebar = props => ( diff --git a/src/components/layout/SidebarBlock.jsx b/src/components/layout/SidebarBlock.jsx index 91a5da9432..d998adc70e 100644 --- a/src/components/layout/SidebarBlock.jsx +++ b/src/components/layout/SidebarBlock.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; diff --git a/src/components/loading-spinner/LoadingSpinner.jsx b/src/components/loading-spinner/LoadingSpinner.jsx index 58954d52c2..75a1627a16 100644 --- a/src/components/loading-spinner/LoadingSpinner.jsx +++ b/src/components/loading-spinner/LoadingSpinner.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import './styles/LoadingSpinner.scss'; diff --git a/src/components/microlearning/VideoCourseReview.jsx b/src/components/microlearning/VideoCourseReview.jsx index d214446598..c6a3345467 100644 --- a/src/components/microlearning/VideoCourseReview.jsx +++ b/src/components/microlearning/VideoCourseReview.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { Icon, OverlayTrigger, Tooltip } from '@openedx/paragon'; import { StarFilled, StarOutline } from '@openedx/paragon/icons'; import PropTypes from 'prop-types'; diff --git a/src/components/microlearning/VideoDetailPage.jsx b/src/components/microlearning/VideoDetailPage.jsx index 6194e6f8b4..11399ef675 100644 --- a/src/components/microlearning/VideoDetailPage.jsx +++ b/src/components/microlearning/VideoDetailPage.jsx @@ -1,5 +1,5 @@ /* eslint-disable max-len */ -import React, { useContext, useEffect } from 'react'; +import { useContext, useEffect, useRef } from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils'; import { @@ -39,7 +39,7 @@ const VideoDetailPage = () => { const coursePrice = getCoursePrice(courseMetadata); const [pacingType, pacingTypeContent] = useCoursePacingType(courseMetadata?.activeCourseRun); const { data: { subscriptionLicense } } = useSubscriptions(); - const playerRef = React.useRef(null); + const playerRef = useRef(null); const intl = useIntl(); const customOptions = { diff --git a/src/components/microlearning/VideoFeedbackCard.jsx b/src/components/microlearning/VideoFeedbackCard.jsx index ff414b4f3c..cfeecf88ec 100644 --- a/src/components/microlearning/VideoFeedbackCard.jsx +++ b/src/components/microlearning/VideoFeedbackCard.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import { Card, Icon, IconButton, ActionRow, Form, Input, Button, diff --git a/src/components/microlearning/__mocks__/@loadable/component.jsx b/src/components/microlearning/__mocks__/@loadable/component.jsx index dc7d4fb3fe..eb4c6172ee 100644 --- a/src/components/microlearning/__mocks__/@loadable/component.jsx +++ b/src/components/microlearning/__mocks__/@loadable/component.jsx @@ -1,5 +1,3 @@ -import React from 'react'; - // mock the loadable function to load the module eagarly and expose a preload() function function loadable(load) { let Component; diff --git a/src/components/my-career/CategoryCard.jsx b/src/components/my-career/CategoryCard.jsx index aa51240f07..dea4a482f3 100644 --- a/src/components/my-career/CategoryCard.jsx +++ b/src/components/my-career/CategoryCard.jsx @@ -1,4 +1,4 @@ -import React, { +import { useEffect, useMemo, useState, } from 'react'; import PropTypes from 'prop-types'; diff --git a/src/components/my-career/LevelBars.jsx b/src/components/my-career/LevelBars.jsx index 8345b08cfc..00239815ac 100644 --- a/src/components/my-career/LevelBars.jsx +++ b/src/components/my-career/LevelBars.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Chip } from '@openedx/paragon'; diff --git a/src/components/my-career/MyCareerTabSkeleton.jsx b/src/components/my-career/MyCareerTabSkeleton.jsx index 59910a60fb..1d3435a8c0 100644 --- a/src/components/my-career/MyCareerTabSkeleton.jsx +++ b/src/components/my-career/MyCareerTabSkeleton.jsx @@ -4,7 +4,6 @@ import { Row, Skeleton, } from '@openedx/paragon'; -import React from 'react'; const MyCareerTabSkeleton = () => (

diff --git a/src/components/my-career/SearchJobRole.jsx b/src/components/my-career/SearchJobRole.jsx index 50e7587849..027244989f 100644 --- a/src/components/my-career/SearchJobRole.jsx +++ b/src/components/my-career/SearchJobRole.jsx @@ -1,4 +1,4 @@ -import React, { useContext, useState } from 'react'; +import { useContext, useState } from 'react'; import PropTypes from 'prop-types'; import { getConfig } from '@edx/frontend-platform/config'; import { logError } from '@edx/frontend-platform/logging'; diff --git a/src/components/my-career/SkillsRecommendationCourses.jsx b/src/components/my-career/SkillsRecommendationCourses.jsx index 7093a9bfc7..d62e4d0f6e 100644 --- a/src/components/my-career/SkillsRecommendationCourses.jsx +++ b/src/components/my-career/SkillsRecommendationCourses.jsx @@ -1,4 +1,4 @@ -import React, { +import { useMemo, useState, useEffect, } from 'react'; import { Link } from 'react-router-dom'; diff --git a/src/components/my-career/VisualizeCareer.jsx b/src/components/my-career/VisualizeCareer.jsx index 1849a5b6f6..fd680e177a 100644 --- a/src/components/my-career/VisualizeCareer.jsx +++ b/src/components/my-career/VisualizeCareer.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import { useState } from 'react'; import PropTypes from 'prop-types'; import { ActionRow, Button, Icon, Row, TransitionReplace, useToggle, diff --git a/src/components/my-career/tests/AddJobRole.test.jsx b/src/components/my-career/tests/AddJobRole.test.jsx index 8faedee098..9e5917994c 100644 --- a/src/components/my-career/tests/AddJobRole.test.jsx +++ b/src/components/my-career/tests/AddJobRole.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { AppContext } from '@edx/frontend-platform/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/my-career/tests/CategoryCard.test.jsx b/src/components/my-career/tests/CategoryCard.test.jsx index 4510743e57..d8561d3952 100644 --- a/src/components/my-career/tests/CategoryCard.test.jsx +++ b/src/components/my-career/tests/CategoryCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/my-career/tests/LevelBars.test.jsx b/src/components/my-career/tests/LevelBars.test.jsx index 43c88bf773..c7065322f6 100644 --- a/src/components/my-career/tests/LevelBars.test.jsx +++ b/src/components/my-career/tests/LevelBars.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/my-career/tests/SearchJobRole.test.jsx b/src/components/my-career/tests/SearchJobRole.test.jsx index 75bdc0b3a7..c075eca017 100644 --- a/src/components/my-career/tests/SearchJobRole.test.jsx +++ b/src/components/my-career/tests/SearchJobRole.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { mount } from 'enzyme'; diff --git a/src/components/my-career/tests/SkillsRecommendationCourses.test.jsx b/src/components/my-career/tests/SkillsRecommendationCourses.test.jsx index 2f13f5e027..b22d629646 100644 --- a/src/components/my-career/tests/SkillsRecommendationCourses.test.jsx +++ b/src/components/my-career/tests/SkillsRecommendationCourses.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { SearchContext } from '@edx/frontend-enterprise-catalog-search'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/my-career/tests/SpiderChart.test.jsx b/src/components/my-career/tests/SpiderChart.test.jsx index 1ced319b91..728e1ba685 100644 --- a/src/components/my-career/tests/SpiderChart.test.jsx +++ b/src/components/my-career/tests/SpiderChart.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/my-career/tests/VisualizeCareer.test.jsx b/src/components/my-career/tests/VisualizeCareer.test.jsx index 36a9eabfcd..af493d8b57 100644 --- a/src/components/my-career/tests/VisualizeCareer.test.jsx +++ b/src/components/my-career/tests/VisualizeCareer.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/pathway-progress/PathwayNode.jsx b/src/components/pathway-progress/PathwayNode.jsx index 973a44f8bc..58e4ba12e5 100644 --- a/src/components/pathway-progress/PathwayNode.jsx +++ b/src/components/pathway-progress/PathwayNode.jsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; import PropTypes from 'prop-types'; import { Badge, Card } from '@openedx/paragon'; import { useParams } from 'react-router-dom'; diff --git a/src/components/pathway-progress/PathwayStep.jsx b/src/components/pathway-progress/PathwayStep.jsx index 9be616bd3d..10244b8d5d 100644 --- a/src/components/pathway-progress/PathwayStep.jsx +++ b/src/components/pathway-progress/PathwayStep.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import { useState } from 'react'; import PropTypes from 'prop-types'; import { v4 as uuidv4 } from 'uuid'; import { Collapsible, Icon } from '@openedx/paragon'; diff --git a/src/components/pathway-progress/tests/PathwayNode.test.jsx b/src/components/pathway-progress/tests/PathwayNode.test.jsx index 865401a91c..615eb8d961 100644 --- a/src/components/pathway-progress/tests/PathwayNode.test.jsx +++ b/src/components/pathway-progress/tests/PathwayNode.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/pathway-progress/tests/PathwayProgressListingCard.test.jsx b/src/components/pathway-progress/tests/PathwayProgressListingCard.test.jsx index 11aa1e286b..371ae61aaf 100644 --- a/src/components/pathway-progress/tests/PathwayProgressListingCard.test.jsx +++ b/src/components/pathway-progress/tests/PathwayProgressListingCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/pathway-progress/tests/PathwayProgressListingPage.test.jsx b/src/components/pathway-progress/tests/PathwayProgressListingPage.test.jsx index 21a398c060..560a254723 100644 --- a/src/components/pathway-progress/tests/PathwayProgressListingPage.test.jsx +++ b/src/components/pathway-progress/tests/PathwayProgressListingPage.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { screen } from '@testing-library/react'; diff --git a/src/components/pathway-progress/tests/PathwayRequirements.test.jsx b/src/components/pathway-progress/tests/PathwayRequirements.test.jsx index 6a3468870b..120e61c531 100644 --- a/src/components/pathway-progress/tests/PathwayRequirements.test.jsx +++ b/src/components/pathway-progress/tests/PathwayRequirements.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { render, screen } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import PathwayRequirements from '../PathwayRequirements'; diff --git a/src/components/pathway-progress/tests/PathwayStep.test.jsx b/src/components/pathway-progress/tests/PathwayStep.test.jsx index c837470d73..51847b85ec 100644 --- a/src/components/pathway-progress/tests/PathwayStep.test.jsx +++ b/src/components/pathway-progress/tests/PathwayStep.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { render, screen } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import PathwayStep from '../PathwayStep'; diff --git a/src/components/pathway-progress/tests/SubscriptionStatusCard.test.jsx b/src/components/pathway-progress/tests/SubscriptionStatusCard.test.jsx index 89148e2338..df6615363c 100644 --- a/src/components/pathway-progress/tests/SubscriptionStatusCard.test.jsx +++ b/src/components/pathway-progress/tests/SubscriptionStatusCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/pathway/PathwayModal.jsx b/src/components/pathway/PathwayModal.jsx index 502b44f6d9..682c4d1ccb 100644 --- a/src/components/pathway/PathwayModal.jsx +++ b/src/components/pathway/PathwayModal.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n'; diff --git a/src/components/pathway/SearchPathwayCard.jsx b/src/components/pathway/SearchPathwayCard.jsx index 4b3d285b21..3c2d2c3730 100644 --- a/src/components/pathway/SearchPathwayCard.jsx +++ b/src/components/pathway/SearchPathwayCard.jsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; import PropTypes from 'prop-types'; import cardFallbackImg from '@edx/brand/paragon/images/card-imagecap-fallback.png'; import { Link } from 'react-router-dom'; diff --git a/src/components/pathway/tests/PathwayModal.test.jsx b/src/components/pathway/tests/PathwayModal.test.jsx index 756eba974e..cfe7461b56 100644 --- a/src/components/pathway/tests/PathwayModal.test.jsx +++ b/src/components/pathway/tests/PathwayModal.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import { AppContext } from '@edx/frontend-platform/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/pathway/tests/SearchPathwayCard.test.jsx b/src/components/pathway/tests/SearchPathwayCard.test.jsx index 942022f32a..f457d9ba27 100644 --- a/src/components/pathway/tests/SearchPathwayCard.test.jsx +++ b/src/components/pathway/tests/SearchPathwayCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/preview-expand/PreviewExpand.jsx b/src/components/preview-expand/PreviewExpand.jsx index 7489fb8247..134fc9126c 100644 --- a/src/components/preview-expand/PreviewExpand.jsx +++ b/src/components/preview-expand/PreviewExpand.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import { useState } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { Button, Icon } from '@openedx/paragon'; diff --git a/src/components/program-progress/tests/ProgramListingCard.test.jsx b/src/components/program-progress/tests/ProgramListingCard.test.jsx index 538dcc0ba9..d1dcb94eb8 100644 --- a/src/components/program-progress/tests/ProgramListingCard.test.jsx +++ b/src/components/program-progress/tests/ProgramListingCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { screen } from '@testing-library/react'; import { renderWithRouter } from '@edx/frontend-enterprise-utils'; diff --git a/src/components/program-progress/tests/ProgramListingPage.test.jsx b/src/components/program-progress/tests/ProgramListingPage.test.jsx index c0f4409c34..4bc9452765 100644 --- a/src/components/program-progress/tests/ProgramListingPage.test.jsx +++ b/src/components/program-progress/tests/ProgramListingPage.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { screen, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/program-progress/tests/ProgramPathwayOpportunity.test.jsx b/src/components/program-progress/tests/ProgramPathwayOpportunity.test.jsx index b4285dfaf3..8419a63418 100644 --- a/src/components/program-progress/tests/ProgramPathwayOpportunity.test.jsx +++ b/src/components/program-progress/tests/ProgramPathwayOpportunity.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { FormattedMessage, IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/program-progress/tests/ProgramProgressCircle.test.jsx b/src/components/program-progress/tests/ProgramProgressCircle.test.jsx index 627336b758..11f395c1eb 100644 --- a/src/components/program-progress/tests/ProgramProgressCircle.test.jsx +++ b/src/components/program-progress/tests/ProgramProgressCircle.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/program-progress/tests/ProgramProgressCourses.test.jsx b/src/components/program-progress/tests/ProgramProgressCourses.test.jsx index 875e6f6ac5..96512e0ae5 100644 --- a/src/components/program-progress/tests/ProgramProgressCourses.test.jsx +++ b/src/components/program-progress/tests/ProgramProgressCourses.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { screen, render } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/program-progress/tests/ProgramProgressHeader.test.jsx b/src/components/program-progress/tests/ProgramProgressHeader.test.jsx index de142e289f..6c7dc41ca5 100644 --- a/src/components/program-progress/tests/ProgramProgressHeader.test.jsx +++ b/src/components/program-progress/tests/ProgramProgressHeader.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/program-progress/tests/ProgramProgressPage.test.jsx b/src/components/program-progress/tests/ProgramProgressPage.test.jsx index 13448a132c..0e1dc825bd 100644 --- a/src/components/program-progress/tests/ProgramProgressPage.test.jsx +++ b/src/components/program-progress/tests/ProgramProgressPage.test.jsx @@ -2,7 +2,6 @@ import { IntlProvider } from '@edx/frontend-platform/i18n'; import { AppContext } from '@edx/frontend-platform/react'; import { renderWithRouter } from '@edx/frontend-enterprise-utils'; import { screen } from '@testing-library/react'; -import React from 'react'; import { ProgramProgressPage } from '../index'; import { authenticatedUserFactory, enterpriseCustomerFactory, academiesFactory } from '../../app/data/services/data/__factories__'; import { diff --git a/src/components/program-progress/tests/ProgramProgressSidebar.test.jsx b/src/components/program-progress/tests/ProgramProgressSidebar.test.jsx index 49d7d3d463..9c777730e7 100644 --- a/src/components/program-progress/tests/ProgramProgressSidebar.test.jsx +++ b/src/components/program-progress/tests/ProgramProgressSidebar.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/program/tests/ProgramCTA.test.jsx b/src/components/program/tests/ProgramCTA.test.jsx index d7ac669d92..1345d7f6db 100644 --- a/src/components/program/tests/ProgramCTA.test.jsx +++ b/src/components/program/tests/ProgramCTA.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { screen, render, fireEvent } from '@testing-library/react'; diff --git a/src/components/program/tests/ProgramCourses.test.jsx b/src/components/program/tests/ProgramCourses.test.jsx index 730cc728ad..1cff8fd358 100644 --- a/src/components/program/tests/ProgramCourses.test.jsx +++ b/src/components/program/tests/ProgramCourses.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { screen, render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/program/tests/ProgramDataBar.test.jsx b/src/components/program/tests/ProgramDataBar.test.jsx index d7c4a4e1c3..3513558f70 100644 --- a/src/components/program/tests/ProgramDataBar.test.jsx +++ b/src/components/program/tests/ProgramDataBar.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { screen, render, fireEvent, diff --git a/src/components/program/tests/ProgramEndorsements.test.jsx b/src/components/program/tests/ProgramEndorsements.test.jsx index 70b49ef8b3..3f79259f10 100644 --- a/src/components/program/tests/ProgramEndorsements.test.jsx +++ b/src/components/program/tests/ProgramEndorsements.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { screen, render, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/program/tests/ProgramFAQ.test.jsx b/src/components/program/tests/ProgramFAQ.test.jsx index 897b0447ba..66bd5e7cd9 100644 --- a/src/components/program/tests/ProgramFAQ.test.jsx +++ b/src/components/program/tests/ProgramFAQ.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { screen, render, waitFor, diff --git a/src/components/program/tests/ProgramHeader.test.jsx b/src/components/program/tests/ProgramHeader.test.jsx index e924de57fc..f7a6c5d7fe 100644 --- a/src/components/program/tests/ProgramHeader.test.jsx +++ b/src/components/program/tests/ProgramHeader.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { screen, render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/program/tests/ProgramSidebar.test.jsx b/src/components/program/tests/ProgramSidebar.test.jsx index 5f249864fd..e50b8999b1 100644 --- a/src/components/program/tests/ProgramSidebar.test.jsx +++ b/src/components/program/tests/ProgramSidebar.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { screen, render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/progress-category-bubbles/ProgressCategoryBubbles.jsx b/src/components/progress-category-bubbles/ProgressCategoryBubbles.jsx index 81a75ad16f..e444a45e2e 100644 --- a/src/components/progress-category-bubbles/ProgressCategoryBubbles.jsx +++ b/src/components/progress-category-bubbles/ProgressCategoryBubbles.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { Bubble, Stack } from '@openedx/paragon'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; import PropTypes from 'prop-types'; diff --git a/src/components/search/ContentTypeSearchResultsContainer.jsx b/src/components/search/ContentTypeSearchResultsContainer.jsx index a2bb9e39d5..8952a860a0 100644 --- a/src/components/search/ContentTypeSearchResultsContainer.jsx +++ b/src/components/search/ContentTypeSearchResultsContainer.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { useIntl } from '@edx/frontend-platform/i18n'; import PropTypes from 'prop-types'; import { diff --git a/src/components/search/SearchCourse.jsx b/src/components/search/SearchCourse.jsx index fe1f7355ad..99611b2fa9 100644 --- a/src/components/search/SearchCourse.jsx +++ b/src/components/search/SearchCourse.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Configure, Index } from 'react-instantsearch-dom'; import { getConfig } from '@edx/frontend-platform/config'; diff --git a/src/components/search/SearchCourseCard.jsx b/src/components/search/SearchCourseCard.jsx index 8c7df75329..b06f6485db 100644 --- a/src/components/search/SearchCourseCard.jsx +++ b/src/components/search/SearchCourseCard.jsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; import PropTypes from 'prop-types'; import cardFallbackImg from '@edx/brand/paragon/images/card-imagecap-fallback.png'; import { Link } from 'react-router-dom'; diff --git a/src/components/search/SearchError.jsx b/src/components/search/SearchError.jsx index 69b409ca83..3efc0ceffe 100644 --- a/src/components/search/SearchError.jsx +++ b/src/components/search/SearchError.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Alert } from '@openedx/paragon'; import { Warning } from '@openedx/paragon/icons'; diff --git a/src/components/search/SearchNoResults.jsx b/src/components/search/SearchNoResults.jsx index 69736520e7..9894bd78bf 100644 --- a/src/components/search/SearchNoResults.jsx +++ b/src/components/search/SearchNoResults.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Alert } from '@openedx/paragon'; import { ZoomOut } from '@openedx/paragon/icons'; diff --git a/src/components/search/SearchPage.jsx b/src/components/search/SearchPage.jsx index 13c384bf7c..2f7b58bf44 100644 --- a/src/components/search/SearchPage.jsx +++ b/src/components/search/SearchPage.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { SearchData } from '@edx/frontend-enterprise-catalog-search'; import { useIntl } from '@edx/frontend-platform/i18n'; diff --git a/src/components/search/SearchPathway.jsx b/src/components/search/SearchPathway.jsx index c91225dad6..ec2e652bfc 100644 --- a/src/components/search/SearchPathway.jsx +++ b/src/components/search/SearchPathway.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Configure, Index } from 'react-instantsearch-dom'; import { getConfig } from '@edx/frontend-platform/config'; diff --git a/src/components/search/SearchProgram.jsx b/src/components/search/SearchProgram.jsx index a6f1c0af53..3f8160d5a9 100644 --- a/src/components/search/SearchProgram.jsx +++ b/src/components/search/SearchProgram.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Configure, Index } from 'react-instantsearch-dom'; import { getConfig } from '@edx/frontend-platform/config'; diff --git a/src/components/search/SearchProgramCard.jsx b/src/components/search/SearchProgramCard.jsx index aea137c90e..94f75aa13b 100644 --- a/src/components/search/SearchProgramCard.jsx +++ b/src/components/search/SearchProgramCard.jsx @@ -1,4 +1,4 @@ -import React, { useContext, useMemo } from 'react'; +import { useContext, useMemo } from 'react'; import PropTypes from 'prop-types'; import cardFallbackImg from '@edx/brand/paragon/images/card-imagecap-fallback.png'; import { Link } from 'react-router-dom'; diff --git a/src/components/search/SearchResults.jsx b/src/components/search/SearchResults.jsx index 1a6722313c..fd3f4ef80d 100644 --- a/src/components/search/SearchResults.jsx +++ b/src/components/search/SearchResults.jsx @@ -1,4 +1,4 @@ -import React, { useContext, useMemo } from 'react'; +import { useContext, useMemo } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { connectStateResults } from 'react-instantsearch-dom'; diff --git a/src/components/search/SearchVideo.jsx b/src/components/search/SearchVideo.jsx index 849de7f819..f91c5bb1ec 100644 --- a/src/components/search/SearchVideo.jsx +++ b/src/components/search/SearchVideo.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Configure, Index } from 'react-instantsearch-dom'; import { getConfig } from '@edx/frontend-platform/config'; diff --git a/src/components/search/SearchVideoCard.jsx b/src/components/search/SearchVideoCard.jsx index 789f3be2c5..b83f742956 100644 --- a/src/components/search/SearchVideoCard.jsx +++ b/src/components/search/SearchVideoCard.jsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; import PropTypes from 'prop-types'; import cardFallbackImg from '@edx/brand/paragon/images/card-imagecap-fallback.png'; import { Link } from 'react-router-dom'; diff --git a/src/components/search/content-highlights/ContentHighlights.jsx b/src/components/search/content-highlights/ContentHighlights.jsx index 9cb32af832..fd0ad4e31a 100644 --- a/src/components/search/content-highlights/ContentHighlights.jsx +++ b/src/components/search/content-highlights/ContentHighlights.jsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; import PropTypes from 'prop-types'; import { Container, Stack } from '@openedx/paragon'; import { v4 as uuidv4 } from 'uuid'; diff --git a/src/components/search/content-highlights/HighlightedContentCard.jsx b/src/components/search/content-highlights/HighlightedContentCard.jsx index e93944899c..515a75b351 100644 --- a/src/components/search/content-highlights/HighlightedContentCard.jsx +++ b/src/components/search/content-highlights/HighlightedContentCard.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; import { Card, Icon, Truncate } from '@openedx/paragon'; diff --git a/src/components/search/popular-results/PopularResults.jsx b/src/components/search/popular-results/PopularResults.jsx index b04c2e78bb..55501bf090 100644 --- a/src/components/search/popular-results/PopularResults.jsx +++ b/src/components/search/popular-results/PopularResults.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { connectStateResults } from 'react-instantsearch-dom'; import { useNbHitsFromSearchResults } from '@edx/frontend-enterprise-catalog-search'; diff --git a/src/components/search/popular-results/PopularResultsIndex.jsx b/src/components/search/popular-results/PopularResultsIndex.jsx index 6a91b09513..12758db548 100644 --- a/src/components/search/popular-results/PopularResultsIndex.jsx +++ b/src/components/search/popular-results/PopularResultsIndex.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { Index, Configure } from 'react-instantsearch-dom'; import { getConfig } from '@edx/frontend-platform/'; diff --git a/src/components/search/tests/Search.test.jsx b/src/components/search/tests/Search.test.jsx index 7a4e7a4cb3..094b7996ab 100644 --- a/src/components/search/tests/Search.test.jsx +++ b/src/components/search/tests/Search.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { SearchContext } from '@edx/frontend-enterprise-catalog-search'; diff --git a/src/components/search/tests/SearchCourseCard.test.jsx b/src/components/search/tests/SearchCourseCard.test.jsx index 5e7b48c24d..453b1fe0da 100644 --- a/src/components/search/tests/SearchCourseCard.test.jsx +++ b/src/components/search/tests/SearchCourseCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/search/tests/SearchPage.test.jsx b/src/components/search/tests/SearchPage.test.jsx index 90247e8a2a..d2e2336d79 100644 --- a/src/components/search/tests/SearchPage.test.jsx +++ b/src/components/search/tests/SearchPage.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/search/tests/SearchProgramCard.test.jsx b/src/components/search/tests/SearchProgramCard.test.jsx index 00c080fc7b..f2fd04f116 100644 --- a/src/components/search/tests/SearchProgramCard.test.jsx +++ b/src/components/search/tests/SearchProgramCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/search/tests/SearchResults.test.jsx b/src/components/search/tests/SearchResults.test.jsx index 82129f41eb..98e1bf65d7 100644 --- a/src/components/search/tests/SearchResults.test.jsx +++ b/src/components/search/tests/SearchResults.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/search/tests/SearchSections.test.jsx b/src/components/search/tests/SearchSections.test.jsx index 2e4fd6f709..6e060b37ab 100644 --- a/src/components/search/tests/SearchSections.test.jsx +++ b/src/components/search/tests/SearchSections.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { SearchContext } from '@edx/frontend-enterprise-catalog-search'; diff --git a/src/components/search/tests/SearchVideoCard.test.jsx b/src/components/search/tests/SearchVideoCard.test.jsx index a7c5952ad6..02bbc0d1a3 100644 --- a/src/components/search/tests/SearchVideoCard.test.jsx +++ b/src/components/search/tests/SearchVideoCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/site-header/AvatarDropdown.jsx b/src/components/site-header/AvatarDropdown.jsx index 9850f9ac4b..19fffd9c6e 100644 --- a/src/components/site-header/AvatarDropdown.jsx +++ b/src/components/site-header/AvatarDropdown.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import PropTypes from 'prop-types'; import { NavLink, generatePath, useLocation } from 'react-router-dom'; import { getConfig } from '@edx/frontend-platform/config'; diff --git a/src/components/site-header/SiteHeaderLogos.jsx b/src/components/site-header/SiteHeaderLogos.jsx index a34032d7c4..c295ac5300 100644 --- a/src/components/site-header/SiteHeaderLogos.jsx +++ b/src/components/site-header/SiteHeaderLogos.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { Link, useParams } from 'react-router-dom'; import edXLogo from '@edx/brand/logo.svg'; import { Stack } from '@openedx/paragon'; diff --git a/src/components/site-header/menu/Menu.jsx b/src/components/site-header/menu/Menu.jsx index 8ee8f1d440..3a782119e3 100644 --- a/src/components/site-header/menu/Menu.jsx +++ b/src/components/site-header/menu/Menu.jsx @@ -1,8 +1,14 @@ -import React from 'react'; +import { + createElement, + Component, + createRef, + Children, + cloneElement, +} from 'react'; import { CSSTransition } from 'react-transition-group'; import PropTypes from 'prop-types'; -const MenuTrigger = ({ tag, className, ...attributes }) => React.createElement(tag, { +const MenuTrigger = ({ tag, className, ...attributes }) => createElement(tag, { className: `menu-trigger ${className}`, ...attributes, }); @@ -17,7 +23,7 @@ MenuTrigger.defaultProps = { }; const MenuTriggerType = ().type; -const MenuContent = ({ tag, className, ...attributes }) => React.createElement(tag, { +const MenuContent = ({ tag, className, ...attributes }) => createElement(tag, { className: ['menu-content', className].join(' '), ...attributes, }); @@ -31,11 +37,11 @@ MenuContent.defaultProps = { className: null, }; -class Menu extends React.Component { +class Menu extends Component { constructor(props) { super(props); - this.menu = React.createRef(); + this.menu = createRef(); this.state = { expanded: false, }; @@ -208,7 +214,7 @@ class Menu extends React.Component { } renderTrigger(node) { - return React.cloneElement(node, { + return cloneElement(node, { onClick: this.onTriggerClick, 'aria-haspopup': 'menu', 'aria-expanded': this.state.expanded, @@ -231,7 +237,7 @@ class Menu extends React.Component { render() { const { className } = this.props; - const wrappedChildren = React.Children.map(this.props.children, (child) => { + const wrappedChildren = Children.map(this.props.children, (child) => { if (child.type === MenuTriggerType) { return this.renderTrigger(child); } @@ -240,7 +246,7 @@ class Menu extends React.Component { const rootClassName = this.state.expanded ? 'menu expanded' : 'menu'; - return React.createElement(this.props.tag, { + return createElement(this.props.tag, { className: `${rootClassName} ${className}`, ref: this.menu, onKeyDown: this.onKeyDown, diff --git a/src/components/site-header/tests/SiteHeader.test.jsx b/src/components/site-header/tests/SiteHeader.test.jsx index 5b7de7385a..f0b638d745 100644 --- a/src/components/site-header/tests/SiteHeader.test.jsx +++ b/src/components/site-header/tests/SiteHeader.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { breakpoints } from '@openedx/paragon'; diff --git a/src/components/skills-quiz-v2/JobCardComponent.jsx b/src/components/skills-quiz-v2/JobCardComponent.jsx index 5c5f620683..ab34326b8c 100644 --- a/src/components/skills-quiz-v2/JobCardComponent.jsx +++ b/src/components/skills-quiz-v2/JobCardComponent.jsx @@ -1,4 +1,4 @@ -import React, { useContext, useState, useEffect } from 'react'; +import { useContext, useState, useEffect } from 'react'; import { SelectableBox, Chip, Spinner, Stack, Button, } from '@openedx/paragon'; diff --git a/src/components/skills-quiz-v2/SkillsQuizHeader.jsx b/src/components/skills-quiz-v2/SkillsQuizHeader.jsx index cb5587f658..03be5a1695 100644 --- a/src/components/skills-quiz-v2/SkillsQuizHeader.jsx +++ b/src/components/skills-quiz-v2/SkillsQuizHeader.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; import edxLogo from '../skills-quiz/images/edx-logo.svg'; diff --git a/src/components/skills-quiz-v2/tests/SkillsQuiz.test.jsx b/src/components/skills-quiz-v2/tests/SkillsQuiz.test.jsx index b77162f64d..9aa7bc081f 100644 --- a/src/components/skills-quiz-v2/tests/SkillsQuiz.test.jsx +++ b/src/components/skills-quiz-v2/tests/SkillsQuiz.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { screen } from '@testing-library/react'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/skills-quiz-v2/tests/SkillsQuizForm.test.jsx b/src/components/skills-quiz-v2/tests/SkillsQuizForm.test.jsx index 719f699667..7cc50266ee 100644 --- a/src/components/skills-quiz-v2/tests/SkillsQuizForm.test.jsx +++ b/src/components/skills-quiz-v2/tests/SkillsQuizForm.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import algoliasearch from 'algoliasearch/lite'; import { screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; diff --git a/src/components/skills-quiz-v2/tests/SkillsQuizHeader.test.jsx b/src/components/skills-quiz-v2/tests/SkillsQuizHeader.test.jsx index 7da5afb9c9..681a7aee19 100644 --- a/src/components/skills-quiz-v2/tests/SkillsQuizHeader.test.jsx +++ b/src/components/skills-quiz-v2/tests/SkillsQuizHeader.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/skills-quiz/CardLoadingSkeleton.jsx b/src/components/skills-quiz/CardLoadingSkeleton.jsx index 9519cbdafd..03b6d1e6d8 100644 --- a/src/components/skills-quiz/CardLoadingSkeleton.jsx +++ b/src/components/skills-quiz/CardLoadingSkeleton.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { Card, CardGrid } from '@openedx/paragon'; import { v4 as uuidv4 } from 'uuid'; diff --git a/src/components/skills-quiz/CourseCard.jsx b/src/components/skills-quiz/CourseCard.jsx index 68e83a9e72..6c9fb6d837 100644 --- a/src/components/skills-quiz/CourseCard.jsx +++ b/src/components/skills-quiz/CourseCard.jsx @@ -1,4 +1,4 @@ -import React, { useContext, useMemo } from 'react'; +import { useContext, useMemo } from 'react'; import { Badge, Card, Stack, Truncate, } from '@openedx/paragon'; diff --git a/src/components/skills-quiz/CurrentJobDropdown.jsx b/src/components/skills-quiz/CurrentJobDropdown.jsx index 06cd72ade3..b01743a0c7 100644 --- a/src/components/skills-quiz/CurrentJobDropdown.jsx +++ b/src/components/skills-quiz/CurrentJobDropdown.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import { SearchContext } from '@edx/frontend-enterprise-catalog-search'; import FacetListRefinement from '@edx/frontend-enterprise-catalog-search/FacetListRefinement'; import PropTypes from 'prop-types'; diff --git a/src/components/skills-quiz/GoalDropdown.jsx b/src/components/skills-quiz/GoalDropdown.jsx index 3afa959f93..229e5d8f53 100644 --- a/src/components/skills-quiz/GoalDropdown.jsx +++ b/src/components/skills-quiz/GoalDropdown.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import { Dropdown } from '@openedx/paragon'; import { DROPDOWN_OPTION_CHANGE_CAREERS, DROPDOWN_OPTION_IMPROVE_CURRENT_ROLE, DROPDOWN_OPTION_GET_PROMOTED, diff --git a/src/components/skills-quiz/IndustryDropdown.jsx b/src/components/skills-quiz/IndustryDropdown.jsx index 3c92192d98..aad3a6c14d 100644 --- a/src/components/skills-quiz/IndustryDropdown.jsx +++ b/src/components/skills-quiz/IndustryDropdown.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import { SearchContext } from '@edx/frontend-enterprise-catalog-search'; import FacetListRefinement from '@edx/frontend-enterprise-catalog-search/FacetListRefinement'; import PropTypes from 'prop-types'; diff --git a/src/components/skills-quiz/SearchCourseCard.jsx b/src/components/skills-quiz/SearchCourseCard.jsx index 4f6dfbcc43..ae26e1fc75 100644 --- a/src/components/skills-quiz/SearchCourseCard.jsx +++ b/src/components/skills-quiz/SearchCourseCard.jsx @@ -1,4 +1,4 @@ -import React, { +import { useContext, useMemo, useState, useEffect, } from 'react'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; diff --git a/src/components/skills-quiz/SearchCurrentJobCard.jsx b/src/components/skills-quiz/SearchCurrentJobCard.jsx index ea0a48a3ec..187d818f2f 100644 --- a/src/components/skills-quiz/SearchCurrentJobCard.jsx +++ b/src/components/skills-quiz/SearchCurrentJobCard.jsx @@ -1,4 +1,4 @@ -import React, { +import { useContext, useState, useEffect, useMemo, } from 'react'; import PropTypes from 'prop-types'; diff --git a/src/components/skills-quiz/SearchJobCard.jsx b/src/components/skills-quiz/SearchJobCard.jsx index 8569cc93d7..87a1adf4d8 100644 --- a/src/components/skills-quiz/SearchJobCard.jsx +++ b/src/components/skills-quiz/SearchJobCard.jsx @@ -1,4 +1,4 @@ -import React, { +import { useContext, useState, useEffect, useMemo, } from 'react'; import PropTypes from 'prop-types'; diff --git a/src/components/skills-quiz/SearchJobDropdown.jsx b/src/components/skills-quiz/SearchJobDropdown.jsx index d781f86365..cc95317ded 100644 --- a/src/components/skills-quiz/SearchJobDropdown.jsx +++ b/src/components/skills-quiz/SearchJobDropdown.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import { SearchContext } from '@edx/frontend-enterprise-catalog-search'; import FacetListRefinement from '@edx/frontend-enterprise-catalog-search/FacetListRefinement'; import PropTypes from 'prop-types'; diff --git a/src/components/skills-quiz/SearchPathways.jsx b/src/components/skills-quiz/SearchPathways.jsx index 2682601c31..c114694289 100644 --- a/src/components/skills-quiz/SearchPathways.jsx +++ b/src/components/skills-quiz/SearchPathways.jsx @@ -1,4 +1,4 @@ -import React, { +import { useContext, useMemo, useState, useEffect, } from 'react'; import PropTypes from 'prop-types'; diff --git a/src/components/skills-quiz/SearchProgramCard.jsx b/src/components/skills-quiz/SearchProgramCard.jsx index 32812013e6..9d277ff3f5 100644 --- a/src/components/skills-quiz/SearchProgramCard.jsx +++ b/src/components/skills-quiz/SearchProgramCard.jsx @@ -1,4 +1,4 @@ -import React, { +import { useContext, useMemo, useState, useEffect, } from 'react'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; diff --git a/src/components/skills-quiz/SelectJobCard.jsx b/src/components/skills-quiz/SelectJobCard.jsx index 112e20887a..0998e7bffe 100644 --- a/src/components/skills-quiz/SelectJobCard.jsx +++ b/src/components/skills-quiz/SelectJobCard.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import { SelectableBox } from '@openedx/paragon'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; import { SkillsContext } from './SkillsContextProvider'; diff --git a/src/components/skills-quiz/SelectedJobSkills.jsx b/src/components/skills-quiz/SelectedJobSkills.jsx index 27fad881e4..99bedd74a7 100644 --- a/src/components/skills-quiz/SelectedJobSkills.jsx +++ b/src/components/skills-quiz/SelectedJobSkills.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import PropTypes from 'prop-types'; import { Badge } from '@openedx/paragon'; import { SearchContext } from '@edx/frontend-enterprise-catalog-search'; diff --git a/src/components/skills-quiz/SimilarJobs.jsx b/src/components/skills-quiz/SimilarJobs.jsx index a3fb461b4b..d1d4c0d934 100644 --- a/src/components/skills-quiz/SimilarJobs.jsx +++ b/src/components/skills-quiz/SimilarJobs.jsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import { useContext } from 'react'; import { Hyperlink } from '@openedx/paragon'; import PropTypes from 'prop-types'; import { SearchContext, setRefinementAction } from '@edx/frontend-enterprise-catalog-search'; diff --git a/src/components/skills-quiz/SkillsContextProvider.jsx b/src/components/skills-quiz/SkillsContextProvider.jsx index 094eac9209..5a6c1566ce 100644 --- a/src/components/skills-quiz/SkillsContextProvider.jsx +++ b/src/components/skills-quiz/SkillsContextProvider.jsx @@ -1,4 +1,4 @@ -import React, { createContext, useReducer, useMemo } from 'react'; +import { createContext, useReducer, useMemo } from 'react'; import PropTypes from 'prop-types'; import { SET_KEY_VALUE, diff --git a/src/components/skills-quiz/SkillsCourses.jsx b/src/components/skills-quiz/SkillsCourses.jsx index 6265199f8a..83d16adc88 100644 --- a/src/components/skills-quiz/SkillsCourses.jsx +++ b/src/components/skills-quiz/SkillsCourses.jsx @@ -1,5 +1,5 @@ -import React, { - useEffect, useState, useContext, useMemo, +import { + useEffect, useState, useContext, useMemo, Fragment, } from 'react'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; import { @@ -121,7 +121,7 @@ const SkillsCourses = ({ index }) => { {isLoading ? ( ) : coursesWithSkills?.map((coursesWithSkill) => ( - +

{ /> ))} - + ))}
{ hitCount === 0 && ( diff --git a/src/components/skills-quiz/SkillsQuiz.jsx b/src/components/skills-quiz/SkillsQuiz.jsx index eabe980546..143055a1d3 100644 --- a/src/components/skills-quiz/SkillsQuiz.jsx +++ b/src/components/skills-quiz/SkillsQuiz.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { Helmet } from 'react-helmet'; import { SearchData } from '@edx/frontend-enterprise-catalog-search'; diff --git a/src/components/skills-quiz/SkillsQuizHeader.jsx b/src/components/skills-quiz/SkillsQuizHeader.jsx index ab3428bf07..31a885c2b8 100644 --- a/src/components/skills-quiz/SkillsQuizHeader.jsx +++ b/src/components/skills-quiz/SkillsQuizHeader.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; import edxLogo from './images/edx-logo.svg'; diff --git a/src/components/skills-quiz/SkillsQuizPage.jsx b/src/components/skills-quiz/SkillsQuizPage.jsx index 7ee088e1f6..508b070469 100644 --- a/src/components/skills-quiz/SkillsQuizPage.jsx +++ b/src/components/skills-quiz/SkillsQuizPage.jsx @@ -1,7 +1,5 @@ -import React from 'react'; - -import { getConfig } from '@edx/frontend-platform/config'; import { Navigate } from 'react-router-dom'; +import { getConfig } from '@edx/frontend-platform/config'; import SkillsQuiz from './SkillsQuiz'; diff --git a/src/components/skills-quiz/SkillsQuizStepper.jsx b/src/components/skills-quiz/SkillsQuizStepper.jsx index f78bbf2a82..b9cf4354db 100644 --- a/src/components/skills-quiz/SkillsQuizStepper.jsx +++ b/src/components/skills-quiz/SkillsQuizStepper.jsx @@ -1,4 +1,4 @@ -import React, { +import { useEffect, useState, useContext, useMemo, } from 'react'; import PropTypes from 'prop-types'; diff --git a/src/components/skills-quiz/TopSkillsOverview.jsx b/src/components/skills-quiz/TopSkillsOverview.jsx index c48920faa4..f2e4f5b770 100644 --- a/src/components/skills-quiz/TopSkillsOverview.jsx +++ b/src/components/skills-quiz/TopSkillsOverview.jsx @@ -1,4 +1,4 @@ -import React, { +import { useContext, useEffect, useState, useMemo, } from 'react'; import PropTypes from 'prop-types'; diff --git a/src/components/skills-quiz/data/tests/hooks.test.jsx b/src/components/skills-quiz/data/tests/hooks.test.jsx index 08aabbd8a1..e00f856042 100644 --- a/src/components/skills-quiz/data/tests/hooks.test.jsx +++ b/src/components/skills-quiz/data/tests/hooks.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { renderHook } from '@testing-library/react-hooks'; import '@testing-library/jest-dom/extend-expect'; import { SearchContext } from '@edx/frontend-enterprise-catalog-search'; diff --git a/src/components/skills-quiz/tests/GoalsDropdown.test.jsx b/src/components/skills-quiz/tests/GoalsDropdown.test.jsx index ee0ef3f676..48e3baedaf 100644 --- a/src/components/skills-quiz/tests/GoalsDropdown.test.jsx +++ b/src/components/skills-quiz/tests/GoalsDropdown.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { screen } from '@testing-library/react'; import { GOAL_DROPDOWN_DEFAULT_OPTION } from '../constants'; diff --git a/src/components/skills-quiz/tests/JobDescriptions.test.jsx b/src/components/skills-quiz/tests/JobDescriptions.test.jsx index d053b09ce6..ce26ae7257 100644 --- a/src/components/skills-quiz/tests/JobDescriptions.test.jsx +++ b/src/components/skills-quiz/tests/JobDescriptions.test.jsx @@ -1,6 +1,5 @@ import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { act, screen, render } from '@testing-library/react'; import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; diff --git a/src/components/skills-quiz/tests/SearchCourseCard.test.jsx b/src/components/skills-quiz/tests/SearchCourseCard.test.jsx index f71c59c042..3ad4024f95 100644 --- a/src/components/skills-quiz/tests/SearchCourseCard.test.jsx +++ b/src/components/skills-quiz/tests/SearchCourseCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom'; import userEvent from '@testing-library/user-event'; import { screen } from '@testing-library/react'; diff --git a/src/components/skills-quiz/tests/SearchCurrentJobCard.test.jsx b/src/components/skills-quiz/tests/SearchCurrentJobCard.test.jsx index fc24aa6396..318f4c5863 100644 --- a/src/components/skills-quiz/tests/SearchCurrentJobCard.test.jsx +++ b/src/components/skills-quiz/tests/SearchCurrentJobCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { SearchContext } from '@edx/frontend-enterprise-catalog-search'; diff --git a/src/components/skills-quiz/tests/SearchFilters.test.jsx b/src/components/skills-quiz/tests/SearchFilters.test.jsx index 4a274d8ed7..2acca538ab 100644 --- a/src/components/skills-quiz/tests/SearchFilters.test.jsx +++ b/src/components/skills-quiz/tests/SearchFilters.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { act, screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { renderWithRouter } from '@edx/frontend-enterprise-utils'; diff --git a/src/components/skills-quiz/tests/SearchJobCard.test.jsx b/src/components/skills-quiz/tests/SearchJobCard.test.jsx index a9d337f14f..cd25faa54d 100644 --- a/src/components/skills-quiz/tests/SearchJobCard.test.jsx +++ b/src/components/skills-quiz/tests/SearchJobCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { render, screen, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { SearchContext } from '@edx/frontend-enterprise-catalog-search'; diff --git a/src/components/skills-quiz/tests/SearchPathways.test.jsx b/src/components/skills-quiz/tests/SearchPathways.test.jsx index 252481287b..c2f2f49d58 100644 --- a/src/components/skills-quiz/tests/SearchPathways.test.jsx +++ b/src/components/skills-quiz/tests/SearchPathways.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom'; import { screen, waitFor } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/skills-quiz/tests/SearchProgramCard.test.jsx b/src/components/skills-quiz/tests/SearchProgramCard.test.jsx index 8e427c8fc5..e97f2a938b 100644 --- a/src/components/skills-quiz/tests/SearchProgramCard.test.jsx +++ b/src/components/skills-quiz/tests/SearchProgramCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom'; import userEvent from '@testing-library/user-event'; import { screen } from '@testing-library/react'; diff --git a/src/components/skills-quiz/tests/SelectJobCard.test.jsx b/src/components/skills-quiz/tests/SelectJobCard.test.jsx index b02195c124..8592f209bd 100644 --- a/src/components/skills-quiz/tests/SelectJobCard.test.jsx +++ b/src/components/skills-quiz/tests/SelectJobCard.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/skills-quiz/tests/SelectedJobSkills.test.jsx b/src/components/skills-quiz/tests/SelectedJobSkills.test.jsx index 18ee94983b..e287c5378a 100644 --- a/src/components/skills-quiz/tests/SelectedJobSkills.test.jsx +++ b/src/components/skills-quiz/tests/SelectedJobSkills.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { AppContext } from '@edx/frontend-platform/react'; import { screen, render } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; diff --git a/src/components/skills-quiz/tests/SkillsCourses.test.jsx b/src/components/skills-quiz/tests/SkillsCourses.test.jsx index 7ca772c225..2553c036cd 100644 --- a/src/components/skills-quiz/tests/SkillsCourses.test.jsx +++ b/src/components/skills-quiz/tests/SkillsCourses.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom'; import userEvent from '@testing-library/user-event'; import { screen, waitFor } from '@testing-library/react'; diff --git a/src/components/skills-quiz/tests/SkillsQuiz.test.jsx b/src/components/skills-quiz/tests/SkillsQuiz.test.jsx index 181fff0709..464ee38bea 100644 --- a/src/components/skills-quiz/tests/SkillsQuiz.test.jsx +++ b/src/components/skills-quiz/tests/SkillsQuiz.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { screen } from '@testing-library/react'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/skills-quiz/tests/SkillsQuizHeader.test.jsx b/src/components/skills-quiz/tests/SkillsQuizHeader.test.jsx index 60c5985e75..dd7244c668 100644 --- a/src/components/skills-quiz/tests/SkillsQuizHeader.test.jsx +++ b/src/components/skills-quiz/tests/SkillsQuizHeader.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { IntlProvider } from '@edx/frontend-platform/i18n'; diff --git a/src/components/skills-quiz/tests/SkillsQuizPage.test.jsx b/src/components/skills-quiz/tests/SkillsQuizPage.test.jsx index 2a2ab6340a..5fe936e27d 100644 --- a/src/components/skills-quiz/tests/SkillsQuizPage.test.jsx +++ b/src/components/skills-quiz/tests/SkillsQuizPage.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import { screen } from '@testing-library/react'; import { AppContext } from '@edx/frontend-platform/react'; diff --git a/src/components/skills-quiz/tests/SkillsQuizStepper.test.jsx b/src/components/skills-quiz/tests/SkillsQuizStepper.test.jsx index 66885d5d07..833476254a 100644 --- a/src/components/skills-quiz/tests/SkillsQuizStepper.test.jsx +++ b/src/components/skills-quiz/tests/SkillsQuizStepper.test.jsx @@ -2,7 +2,6 @@ // "Cannot log after tests are done. Did you forget to wait // for something async in your test" and Algolia. -import React from 'react'; import '@testing-library/jest-dom/extend-expect'; import userEvent from '@testing-library/user-event'; import { fireEvent, screen } from '@testing-library/react'; diff --git a/src/components/skills-quiz/tests/utils.jsx b/src/components/skills-quiz/tests/utils.jsx index 1a3de71657..2e4b1c24aa 100644 --- a/src/components/skills-quiz/tests/utils.jsx +++ b/src/components/skills-quiz/tests/utils.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { renderWithRouter } from '@edx/frontend-enterprise-utils'; import { SearchData } from '@edx/frontend-enterprise-catalog-search'; diff --git a/src/components/skills-quiz/tests/utils.test.jsx b/src/components/skills-quiz/tests/utils.test.jsx index bd5fd6c38f..b72529401d 100644 --- a/src/components/skills-quiz/tests/utils.test.jsx +++ b/src/components/skills-quiz/tests/utils.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { screen } from '@testing-library/react'; import { renderWithSearchContext } from './utils'; diff --git a/src/components/stateful-enroll/StatefulEnroll.jsx b/src/components/stateful-enroll/StatefulEnroll.jsx index 1b46ae70ab..ecac79b544 100644 --- a/src/components/stateful-enroll/StatefulEnroll.jsx +++ b/src/components/stateful-enroll/StatefulEnroll.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import { useState } from 'react'; import PropTypes from 'prop-types'; import { StatefulButton } from '@openedx/paragon'; import { defineMessages, useIntl } from '@edx/frontend-platform/i18n'; diff --git a/src/components/system-wide-banner/SystemWideWarningBanner.jsx b/src/components/system-wide-banner/SystemWideWarningBanner.jsx index 3e0ff4082c..897b93599e 100644 --- a/src/components/system-wide-banner/SystemWideWarningBanner.jsx +++ b/src/components/system-wide-banner/SystemWideWarningBanner.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import PropTypes from 'prop-types'; import { PageBanner, Icon } from '@openedx/paragon'; import { WarningFilled } from '@openedx/paragon/icons'; diff --git a/src/components/video/VideoPlayer.jsx b/src/components/video/VideoPlayer.jsx index 00acc4ae46..f696c5b75b 100644 --- a/src/components/video/VideoPlayer.jsx +++ b/src/components/video/VideoPlayer.jsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import { useMemo } from 'react'; import PropTypes from 'prop-types'; import VideoJS from './VideoJS'; diff --git a/src/components/video/tests/VideoJS.test.jsx b/src/components/video/tests/VideoJS.test.jsx index 05bb3f23b9..0c0632faad 100644 --- a/src/components/video/tests/VideoJS.test.jsx +++ b/src/components/video/tests/VideoJS.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { waitFor } from '@testing-library/react'; import { renderWithRouter } from '../../../utils/tests'; import VideoJS from '../VideoJS'; diff --git a/src/components/video/tests/VideoPlayer.test.jsx b/src/components/video/tests/VideoPlayer.test.jsx index f288f2f4bf..5f7301de04 100644 --- a/src/components/video/tests/VideoPlayer.test.jsx +++ b/src/components/video/tests/VideoPlayer.test.jsx @@ -1,4 +1,3 @@ -import React from 'react'; import { waitFor } from '@testing-library/react'; import VideoPlayer from '../VideoPlayer'; import { renderWithRouter } from '../../../utils/tests'; diff --git a/src/index.jsx b/src/index.jsx index 9b8e365db5..21db55364b 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -2,7 +2,6 @@ import 'core-js/stable'; import 'regenerator-runtime/runtime'; -import React from 'react'; import ReactDOM from 'react-dom'; import { APP_INIT_ERROR, APP_READY, initialize, subscribe, diff --git a/src/types.d.ts b/src/types.d.ts index 4a4a0d56f0..caf122ea69 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -42,6 +42,10 @@ export interface EnterpriseCustomer { slug: string; name: string; enableOneAcademy: boolean; + enterpriseFeatures: { + enterpriseLearnerBFFEnabled: boolean; + [key: string]: boolean; + }; } export interface EnterpriseLearnerData { diff --git a/src/utils/hooks.jsx b/src/utils/hooks.jsx index ebbbf12fb2..bc8a2bc480 100644 --- a/src/utils/hooks.jsx +++ b/src/utils/hooks.jsx @@ -1,4 +1,4 @@ -import React, { useCallback, useMemo } from 'react'; +import { useCallback, useMemo } from 'react'; import algoliasearch from 'algoliasearch'; export const useRenderContactHelpText = (enterpriseCustomer) => { diff --git a/src/utils/tests.jsx b/src/utils/tests.jsx index 0250ab78f3..1a42d977b2 100644 --- a/src/utils/tests.jsx +++ b/src/utils/tests.jsx @@ -1,4 +1,4 @@ -import React, { isValidElement } from 'react'; +import { isValidElement } from 'react'; import { BrowserRouter as Router, RouterProvider, createMemoryRouter } from 'react-router-dom'; import { createMemoryHistory } from 'history'; import dayjs from 'dayjs';