Skip to content

Commit

Permalink
chore: remove ts ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
brobro10000 committed Feb 13, 2025
1 parent fcd9ecd commit 6071f5b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
8 changes: 2 additions & 6 deletions src/components/app/data/queries/extractEnterpriseCustomer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,16 @@ async function extractEnterpriseCustomer({
queryClient,
authenticatedUser,
enterpriseSlug,
} : ExtractEnterpriseCustomerArgs) : Promise<Types.EnterpriseCustomer> {
} : 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<Types.EnterpriseLearnerData>(
// @ts-ignore
const enterpriseLearnerData = await queryClient.ensureQueryData(
linkedEnterpriseCustomersQuery,
);
const {
// @ts-ignore
activeEnterpriseCustomer,
// @ts-ignore
allLinkedEnterpriseCustomerUsers,
// @ts-ignore
staffEnterpriseCustomer,
} = enterpriseLearnerData;

Expand Down
4 changes: 1 addition & 3 deletions src/components/app/data/queries/extractEnterpriseFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Types.EnterpriseLearnerData>(
// @ts-ignore
const enterpriseLearnerData = await queryClient.ensureQueryData(
linkedEnterpriseCustomersQuery,
);
// @ts-ignore
const { enterpriseFeatures } = enterpriseLearnerData;
return enterpriseFeatures;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Types.EnterpriseLearnerData> {
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()}`;
Expand Down Expand Up @@ -149,16 +150,16 @@ 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()}`;
try {
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 [];
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/app/routes/loaders/rootLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Types.EnterpriseLearnerData>(
// @ts-ignore
enterpriseLearnerData = await queryClient.ensureQueryData(
queryEnterpriseLearner(username, enterpriseSlug),
);
}
Expand Down
14 changes: 8 additions & 6 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 | {};
shouldUpdateActiveEnterpriseCustomerUser: boolean | null;
}

interface EnrollmentDueDate {
Expand Down

0 comments on commit 6071f5b

Please sign in to comment.