Skip to content
Open
2 changes: 2 additions & 0 deletions src/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export type CorporateCatalog = {
corporatePartner: number;
};

export type CorporateCatalogForm = Pick<CorporateCatalog, 'isPublic' | 'name' | 'catalogAlternativeLink' | 'supportEmail' | 'availableStartDate' | 'availableEndDate' | 'courseEnrollmentLimit' | 'userLimit' | 'emailRegexes' | 'customCourses' | 'isSelfEnrollment' >;

export interface PaginatedResponse<T> {
next: string | null;
previous: string | null;
Expand Down
17 changes: 16 additions & 1 deletion src/catalogs/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getConfig, camelCaseObject } from '@edx/frontend-platform';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { logError } from '@edx/frontend-platform/logging';

import { CorporateCatalog, PaginatedResponse } from '../app/types';
import { CorporateCatalog, CorporateCatalogForm, PaginatedResponse } from '../app/types';

export const getPartnerCatalogs = async (
partnerId: string,
Expand Down Expand Up @@ -43,3 +43,18 @@ export const getCatalogDetails = async (
return null;
}
};

export const modifyCatalog = async (
partnerId: string,
catalogId: string | number,
data: CorporateCatalogForm,
): Promise<CorporateCatalog | null> => {
try {
const url = `${getConfig().LMS_BASE_URL}/corporate_access/api/v1/partners/${partnerId}/catalogs/${catalogId}/`;
const response = await getAuthenticatedHttpClient().put(url, data);
return camelCaseObject(response.data);
} catch (error) {
logError(error);
return null;
}
};
Loading
Loading