diff --git a/src/components/app/data/queries/extractEnterpriseCustomer.ts b/src/components/app/data/queries/extractEnterpriseCustomer.ts index e05bf66292..52dd256eb1 100644 --- a/src/components/app/data/queries/extractEnterpriseCustomer.ts +++ b/src/components/app/data/queries/extractEnterpriseCustomer.ts @@ -13,20 +13,16 @@ async function extractEnterpriseCustomer({ queryClient, authenticatedUser, enterpriseSlug, -} : ExtractEnterpriseCustomerArgs) : Promise { +} : ExtractEnterpriseCustomerArgs) { // Retrieve linked enterprise customers for the current user from query cache, or // fetch from the server if not available. const linkedEnterpriseCustomersQuery = queryEnterpriseLearner(authenticatedUser.username, enterpriseSlug); - const enterpriseLearnerData = await queryClient.ensureQueryData( - // @ts-ignore + const enterpriseLearnerData = await queryClient.ensureQueryData( linkedEnterpriseCustomersQuery, ); const { - // @ts-ignore activeEnterpriseCustomer, - // @ts-ignore allLinkedEnterpriseCustomerUsers, - // @ts-ignore staffEnterpriseCustomer, } = enterpriseLearnerData; diff --git a/src/components/app/data/queries/extractEnterpriseFeatures.ts b/src/components/app/data/queries/extractEnterpriseFeatures.ts index 5496693793..f6eab35243 100644 --- a/src/components/app/data/queries/extractEnterpriseFeatures.ts +++ b/src/components/app/data/queries/extractEnterpriseFeatures.ts @@ -17,11 +17,9 @@ async function extractEnterpriseFeatures({ // Retrieve linked enterprise customers for the current user from query cache, or // fetch from the server if not available. const linkedEnterpriseCustomersQuery = queryEnterpriseLearner(authenticatedUser.username, enterpriseSlug); - const enterpriseLearnerData = await queryClient.ensureQueryData( - // @ts-ignore + const enterpriseLearnerData = await queryClient.ensureQueryData( linkedEnterpriseCustomersQuery, ); - // @ts-ignore const { enterpriseFeatures } = enterpriseLearnerData; return enterpriseFeatures; } diff --git a/src/components/app/data/services/enterpriseCustomerUser.js b/src/components/app/data/services/enterpriseCustomerUser.ts similarity index 97% rename from src/components/app/data/services/enterpriseCustomerUser.js rename to src/components/app/data/services/enterpriseCustomerUser.ts index e8ce642ad0..0b73ca59a0 100644 --- a/src/components/app/data/services/enterpriseCustomerUser.js +++ b/src/components/app/data/services/enterpriseCustomerUser.ts @@ -57,11 +57,12 @@ export async function fetchEnterpriseCustomerForSlug(enterpriseSlug) { * @param {Object} [options] Additional query options. * @returns */ -export async function fetchEnterpriseLearnerData(username, enterpriseSlug, options = {}) { +export async function fetchEnterpriseLearnerData(username, enterpriseSlug, options = {}): +Promise { const enterpriseLearnerUrl = `${getConfig().LMS_BASE_URL}/enterprise/api/v1/enterprise-learner/`; const queryParams = new URLSearchParams({ username, - page: 1, + page: '1', ...options, }); const url = `${enterpriseLearnerUrl}?${queryParams.toString()}`; @@ -149,7 +150,7 @@ export async function fetchEnterpriseLearnerData(username, enterpriseSlug, optio export async function fetchEnterpriseCourseEnrollments(enterpriseId, options = {}) { const queryParams = new URLSearchParams({ enterprise_id: enterpriseId, - is_active: true, + is_active: 'true', ...options, }); const url = `${getConfig().LMS_BASE_URL}/enterprise_learner_portal/api/v1/enterprise_course_enrollments/?${queryParams.toString()}`; @@ -157,8 +158,8 @@ export async function fetchEnterpriseCourseEnrollments(enterpriseId, options = { const response = await getAuthenticatedHttpClient().get(url); return camelCaseObject(response.data); } catch (error) { - if (getErrorResponseStatusCode(error) !== 404) { - logError(error); + if (getErrorResponseStatusCode(error as Error) !== 404) { + logError(error as Error); } return []; } diff --git a/src/components/app/routes/loaders/rootLoader.ts b/src/components/app/routes/loaders/rootLoader.ts index b671f2f6d5..df55331f48 100644 --- a/src/components/app/routes/loaders/rootLoader.ts +++ b/src/components/app/routes/loaders/rootLoader.ts @@ -38,14 +38,13 @@ const makeRootLoader: Types.MakeRouteLoaderFunctionWithQueryClient = function ma const matchedBFFQuery = resolveBFFQuery( requestUrl.pathname, ); - let enterpriseLearnerData; + let enterpriseLearnerData: Types.EnterpriseLearnerData | any; if (matchedBFFQuery) { enterpriseLearnerData = await queryClient.ensureQueryData( matchedBFFQuery({ enterpriseSlug }), ); } else { - enterpriseLearnerData = await queryClient.ensureQueryData( - // @ts-ignore + enterpriseLearnerData = await queryClient.ensureQueryData( queryEnterpriseLearner(username, enterpriseSlug), ); } diff --git a/src/types.d.ts b/src/types.d.ts index 01e25114fc..7563ced456 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -55,12 +55,14 @@ export interface EnterpriseFeatures { } export interface EnterpriseLearnerData { - enterpriseCustomer: Types.EnterpriseCustomer; - activeEnterpriseCustomer: Types.EnterpriseCustomer; - allLinkedEnterpriseCustomerUsers: any[]; - staffEnterpriseCustomer: Types.EnterpriseCustomer; - enterpriseFeatures: Types.EnterpriseFeatures; - shouldUpdateActiveEnterpriseCustomerUser: boolean; + enterpriseCustomer: Types.EnterpriseCustomer | null; + activeEnterpriseCustomer: Types.EnterpriseCustomer | null; + activeEnterpriseCustomerUserRoleAssignments: any[]; + allLinkedEnterpriseCustomerUsers: EnterpriseCustomerUser[]; + enterpriseCustomerUserRoleAssignments: any[]; + staffEnterpriseCustomer: Types.EnterpriseCustomer | null; + enterpriseFeatures: Types.EnterpriseFeatures | null; + shouldUpdateActiveEnterpriseCustomerUser: boolean | null; } interface EnrollmentDueDate {