chore: rename more files from .js to .ts (#2842)
* chore: rename more files from .js to .ts * fix: fix some little issues caught by TS * fix: fix type of 'certificateId'
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
advancedModules: {
|
||||
deprecated: false,
|
||||
displayName: 'Advanced Module List',
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = [
|
||||
export default [
|
||||
{
|
||||
id: 1,
|
||||
courseTitle: 'Course Title 1',
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
certificateActivationHandlerUrl: '/certificates/activation/course-v1:org+101+101/',
|
||||
certificateWebViewUrl: '//certificates/course/course-v1:org+101+101?preview=honor',
|
||||
certificates: [
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = [
|
||||
export default [
|
||||
{
|
||||
id: '1', name: 'John Doe', title: 'CEO', organization: 'Company', signatureImagePath: '/path/to/signature1.png',
|
||||
},
|
||||
@@ -5,17 +5,15 @@ import { prepareCertificatePayload } from '../utils';
|
||||
|
||||
const getApiBaseUrl = () => getConfig().STUDIO_BASE_URL;
|
||||
|
||||
export const getCertificatesApiUrl = (courseId) => `${getApiBaseUrl()}/api/contentstore/v1/certificates/${courseId}`;
|
||||
export const getCertificateApiUrl = (courseId) => `${getApiBaseUrl()}/certificates/${courseId}`;
|
||||
export const getUpdateCertificateApiUrl = (courseId, certificateId) => `${getCertificateApiUrl(courseId)}/${certificateId}`;
|
||||
export const getUpdateCertificateActiveStatusApiUrl = (path) => `${getApiBaseUrl()}${path}`;
|
||||
export const getCertificatesApiUrl = (courseId: string) => `${getApiBaseUrl()}/api/contentstore/v1/certificates/${courseId}`;
|
||||
export const getCertificateApiUrl = (courseId: string) => `${getApiBaseUrl()}/certificates/${courseId}`;
|
||||
export const getUpdateCertificateApiUrl = (courseId: string, certificateId: number) => `${getCertificateApiUrl(courseId)}/${certificateId}`;
|
||||
export const getUpdateCertificateActiveStatusApiUrl = (path: string) => `${getApiBaseUrl()}${path}`;
|
||||
|
||||
/**
|
||||
* Gets certificates for a course.
|
||||
* @param {string} courseId
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
export async function getCertificates(courseId) {
|
||||
export async function getCertificates(courseId: string): Promise<Record<string, any>> {
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.get(getCertificatesApiUrl(courseId));
|
||||
|
||||
@@ -24,12 +22,11 @@ export async function getCertificates(courseId) {
|
||||
|
||||
/**
|
||||
* Create course certificate.
|
||||
* @param {string} courseId
|
||||
* @param {object} certificatesData
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
|
||||
export async function createCertificate(courseId, certificatesData) {
|
||||
export async function createCertificate(
|
||||
courseId: string,
|
||||
certificatesData: Record<string, any>,
|
||||
): Promise<Record<string, any>> {
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.post(
|
||||
getCertificateApiUrl(courseId),
|
||||
@@ -41,11 +38,11 @@ export async function createCertificate(courseId, certificatesData) {
|
||||
|
||||
/**
|
||||
* Update course certificate.
|
||||
* @param {string} courseId
|
||||
* @param {object} certificateData
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
export async function updateCertificate(courseId, certificateData) {
|
||||
export async function updateCertificate(
|
||||
courseId: string,
|
||||
certificateData: Record<string, any>,
|
||||
): Promise<Record<string, any>> {
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.post(
|
||||
getUpdateCertificateApiUrl(courseId, certificateData.id),
|
||||
@@ -57,11 +54,8 @@ export async function updateCertificate(courseId, certificateData) {
|
||||
|
||||
/**
|
||||
* Delete course certificate.
|
||||
* @param {string} courseId
|
||||
* @param {object} certificateId
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
export async function deleteCertificate(courseId, certificateId) {
|
||||
export async function deleteCertificate(courseId: string, certificateId: number): Promise<Record<string, any>> {
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.delete(
|
||||
getUpdateCertificateApiUrl(courseId, certificateId),
|
||||
@@ -71,11 +65,8 @@ export async function deleteCertificate(courseId, certificateId) {
|
||||
|
||||
/**
|
||||
* Activate/deactivate course certificate.
|
||||
* @param {string} courseId
|
||||
* @param {object} activationStatus
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
export async function updateActiveStatus(path, activationStatus) {
|
||||
export async function updateActiveStatus(path: string, activationStatus: unknown): Promise<Record<string, any>> {
|
||||
const body = {
|
||||
is_active: activationStatus,
|
||||
};
|
||||
@@ -4,7 +4,7 @@ export const MODE_STATES = {
|
||||
view: 'view',
|
||||
editAll: 'edit_all',
|
||||
create: 'create',
|
||||
};
|
||||
} as const;
|
||||
|
||||
export const ACTIVATION_MESSAGES = {
|
||||
activating: 'Activating',
|
||||
@@ -1,22 +0,0 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
|
||||
export const getLoadingStatus = (state) => state.certificates.loadingStatus;
|
||||
export const getSavingStatus = (state) => state.certificates.savingStatus;
|
||||
export const getSavingImageStatus = (state) => state.certificates.savingImageStatus;
|
||||
export const getErrorMessage = (state) => state.certificates.errorMessage;
|
||||
export const getSendRequestErrors = (state) => state.certificates.sendRequestErrors.developer_message;
|
||||
export const getCertificates = state => state.certificates.certificatesData.certificates;
|
||||
export const getHasCertificateModes = state => state.certificates.certificatesData.hasCertificateModes;
|
||||
export const getCourseModes = state => state.certificates.certificatesData.courseModes;
|
||||
export const getCertificateActivationUrl = state => state.certificates.certificatesData.certificateActivationHandlerUrl;
|
||||
export const getCertificateWebViewUrl = state => state.certificates.certificatesData.certificateWebViewUrl;
|
||||
export const getIsCertificateActive = state => state.certificates.certificatesData.isActive;
|
||||
export const getComponentMode = state => state.certificates.componentMode;
|
||||
export const getCourseNumber = state => state.certificates.certificatesData.courseNumber;
|
||||
export const getCourseNumberOverride = state => state.certificates.certificatesData.courseNumberOverride;
|
||||
export const getCourseTitle = state => state.certificates.certificatesData.courseTitle;
|
||||
|
||||
export const getHasCertificates = createSelector(
|
||||
[getCertificates],
|
||||
(certificates) => certificates && certificates.length > 0,
|
||||
);
|
||||
25
src/certificates/data/selectors.ts
Normal file
25
src/certificates/data/selectors.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/* eslint-disable max-len */
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import type { DeprecatedReduxState } from '@src/store';
|
||||
|
||||
export const getLoadingStatus = (state: DeprecatedReduxState) => state.certificates.loadingStatus;
|
||||
export const getSavingStatus = (state: DeprecatedReduxState) => state.certificates.savingStatus;
|
||||
export const getSavingImageStatus = (state: DeprecatedReduxState) => state.certificates.savingImageStatus;
|
||||
export const getErrorMessage = (state: DeprecatedReduxState) => state.certificates.errorMessage;
|
||||
// Commenting this one out as it seems to be unused:
|
||||
// export const getSendRequestErrors = (state: DeprecatedReduxState) => state.certificates.sendRequestErrors.developer_message;
|
||||
export const getCertificates = (state: DeprecatedReduxState) => state.certificates.certificatesData.certificates;
|
||||
export const getHasCertificateModes = (state: DeprecatedReduxState) => state.certificates.certificatesData.hasCertificateModes;
|
||||
export const getCourseModes = (state: DeprecatedReduxState) => state.certificates.certificatesData.courseModes;
|
||||
export const getCertificateActivationUrl = (state: DeprecatedReduxState) => state.certificates.certificatesData.certificateActivationHandlerUrl;
|
||||
export const getCertificateWebViewUrl = (state: DeprecatedReduxState) => state.certificates.certificatesData.certificateWebViewUrl;
|
||||
export const getIsCertificateActive = (state: DeprecatedReduxState) => state.certificates.certificatesData.isActive;
|
||||
export const getComponentMode = (state: DeprecatedReduxState) => state.certificates.componentMode;
|
||||
export const getCourseNumber = (state: DeprecatedReduxState) => state.certificates.certificatesData.courseNumber;
|
||||
export const getCourseNumberOverride = (state: DeprecatedReduxState) => state.certificates.certificatesData.courseNumberOverride;
|
||||
export const getCourseTitle = (state: DeprecatedReduxState) => state.certificates.certificatesData.courseTitle;
|
||||
|
||||
export const getHasCertificates = createSelector(
|
||||
[getCertificates],
|
||||
(certificates) => certificates && certificates.length > 0,
|
||||
);
|
||||
@@ -7,7 +7,7 @@ import { MODE_STATES } from './constants';
|
||||
const slice = createSlice({
|
||||
name: 'certificates',
|
||||
initialState: {
|
||||
certificatesData: {},
|
||||
certificatesData: {} as Record<string, any>,
|
||||
componentMode: MODE_STATES.noModes,
|
||||
loadingStatus: RequestStatus.PENDING,
|
||||
savingStatus: '',
|
||||
@@ -32,7 +32,7 @@ export function fetchCertificates(courseId) {
|
||||
|
||||
dispatch(fetchCertificatesSuccess(certificates));
|
||||
dispatch(updateLoadingStatus({ status: RequestStatus.SUCCESSFUL }));
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (error.response && error.response.status === 403) {
|
||||
dispatch(updateLoadingStatus({ courseId, status: RequestStatus.DENIED }));
|
||||
} else {
|
||||
@@ -84,8 +84,8 @@ export function deleteCourseCertificate(courseId, certificateId) {
|
||||
dispatch(showProcessingNotification(NOTIFICATION_MESSAGES.deleting));
|
||||
|
||||
try {
|
||||
const certificatesValues = await deleteCertificate(courseId, certificateId);
|
||||
dispatch(deleteCertificateSuccess(certificatesValues));
|
||||
await deleteCertificate(courseId, certificateId);
|
||||
dispatch(deleteCertificateSuccess());
|
||||
dispatch(updateSavingStatus({ status: RequestStatus.SUCCESSFUL }));
|
||||
return true;
|
||||
} catch (error) {
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
id: 'block-v1:SampleTaxonomyOrg1+STC1+2023_1+type@vertical+block@7f47fe2dbcaf47c5a071671c741fe1ab',
|
||||
displayName: 'Unit 1.1.2',
|
||||
category: 'vertical',
|
||||
@@ -1,3 +1,3 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
'block-v1:SampleTaxonomyOrg1+STC1+2023_1+type@vertical+block@aaf8b8eb86b54281aeeab12499d2cb0b': 20,
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
'block-v1:SampleTaxonomyOrg1+STC1+2023_1+type@vertical+block@aaf8b8eb86b54281aeeab12499d2cb0b': {
|
||||
taxonomies: [
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
'hierarchical taxonomy tag 1': {
|
||||
explicit: false,
|
||||
canDeleteObjecttag: true,
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
next: null,
|
||||
previous: null,
|
||||
count: 4,
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
'block-v1:SampleTaxonomyOrg1+STC1+2023_1+type@vertical+block@aaf8b8eb86b54281aeeab12499d2cb0b': {
|
||||
taxonomies: [
|
||||
{
|
||||
@@ -1573,7 +1573,7 @@ describe('<CourseOutline />', () => {
|
||||
|
||||
// after configuraiton response
|
||||
unit.visibilityState = 'staff_only';
|
||||
unit.discussion_enabled = false;
|
||||
unit.discussionEnabled = false;
|
||||
unit.userPartitionInfo = {
|
||||
selectablePartitions: [
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
isSelfPaced: false,
|
||||
sections: {
|
||||
totalNumber: 6,
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
isSelfPaced: false,
|
||||
dates: {
|
||||
hasStartDate: true,
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
courseReleaseDate: 'Set Date',
|
||||
courseStructure: {
|
||||
id: 'block-v1:edX+DemoX+Demo_Course+type@course+block@course',
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
courseReleaseDate: 'Set Date',
|
||||
courseStructure: {},
|
||||
deprecatedBlocksInfo: {
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
id: 'block-v1:edX+DemoX+Demo_Course+type@chapter+block@d0e78d363a424da6be5c22704c34f7a7',
|
||||
display_name: 'Section',
|
||||
category: 'chapter',
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
id: 'block-v1:edX+DemoX+Demo_Course+type@sequential+block@b713bc2830f34f6f87554028c3068729',
|
||||
display_name: 'Subsection',
|
||||
category: 'sequential',
|
||||
@@ -1,4 +1,4 @@
|
||||
export const ITEM_BADGE_STATUS = /** @type {const} */ ({
|
||||
export const ITEM_BADGE_STATUS = {
|
||||
live: 'live',
|
||||
gated: 'gated',
|
||||
publishedNotLive: 'published_not_live',
|
||||
@@ -7,23 +7,23 @@ export const ITEM_BADGE_STATUS = /** @type {const} */ ({
|
||||
draft: 'draft',
|
||||
unscheduled: 'unscheduled',
|
||||
needs_attention: 'needs_attention',
|
||||
});
|
||||
} as const;
|
||||
|
||||
export const HIGHLIGHTS_FIELD_MAX_LENGTH = 250;
|
||||
|
||||
export const CHECKLIST_FILTERS = /** @type {const} */ ({
|
||||
export const CHECKLIST_FILTERS = {
|
||||
ALL: 'ALL',
|
||||
SELF_PACED: 'SELF_PACED',
|
||||
INSTRUCTOR_PACED: 'INSTRUCTOR_PACED',
|
||||
});
|
||||
} as const;
|
||||
|
||||
export const COURSE_BLOCK_NAMES = /** @type {const} */ ({
|
||||
export const COURSE_BLOCK_NAMES = {
|
||||
chapter: { id: 'chapter', name: 'Section' },
|
||||
sequential: { id: 'sequential', name: 'Subsection' },
|
||||
vertical: { id: 'vertical', name: 'Unit' },
|
||||
});
|
||||
} as const;
|
||||
|
||||
export const LAUNCH_CHECKLIST = /** @type {const} */ ({
|
||||
export const LAUNCH_CHECKLIST = {
|
||||
data: [
|
||||
{
|
||||
id: 'welcomeMessage',
|
||||
@@ -50,9 +50,9 @@ export const LAUNCH_CHECKLIST = /** @type {const} */ ({
|
||||
pacingTypeFilter: CHECKLIST_FILTERS.ALL,
|
||||
},
|
||||
],
|
||||
});
|
||||
} as const;
|
||||
|
||||
export const BEST_PRACTICES_CHECKLIST = /** @type {const} */ ({
|
||||
export const BEST_PRACTICES_CHECKLIST = {
|
||||
data: [
|
||||
{
|
||||
id: 'videoDuration',
|
||||
@@ -71,17 +71,17 @@ export const BEST_PRACTICES_CHECKLIST = /** @type {const} */ ({
|
||||
pacingTypeFilter: CHECKLIST_FILTERS.ALL,
|
||||
},
|
||||
],
|
||||
});
|
||||
} as const;
|
||||
|
||||
export const VIDEO_SHARING_OPTIONS = /** @type {const} */ ({
|
||||
export const VIDEO_SHARING_OPTIONS = {
|
||||
perVideo: 'per-video',
|
||||
allOn: 'all-on',
|
||||
allOff: 'all-off',
|
||||
});
|
||||
} as const;
|
||||
|
||||
export const API_ERROR_TYPES = /** @type {const} */ ({
|
||||
export const API_ERROR_TYPES = {
|
||||
networkError: 'networkError',
|
||||
serverError: 'serverError',
|
||||
unknown: 'unknown',
|
||||
forbidden: 'forbidden',
|
||||
});
|
||||
} as const;
|
||||
@@ -2,16 +2,16 @@ export const MODAL_TYPES = {
|
||||
error: 'error',
|
||||
delete: 'delete',
|
||||
warning: 'warning',
|
||||
};
|
||||
} as const;
|
||||
|
||||
export const BADGE_STATES = {
|
||||
admin: 'primary-700',
|
||||
staff: 'gray-500',
|
||||
};
|
||||
} as const;
|
||||
|
||||
export const USER_ROLES = {
|
||||
admin: 'instructor',
|
||||
staff: 'staff',
|
||||
};
|
||||
} as const;
|
||||
|
||||
export const EXAMPLE_USER_EMAIL = 'username@domain.com';
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
locator: 'block-v1:edX+L153+3T2023+type@drag-and-drop-v2+block@dc52e3cf8e6145e39ba5c1ff4888db4b',
|
||||
courseKey: 'course-v1:edX+L153+3T2023',
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
id: 'block-v1:edX+DemoX+Demo_Course+type@course+block@course',
|
||||
display_name: 'Demonstration Course',
|
||||
category: 'course',
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
language_code: 'en',
|
||||
action: 'view',
|
||||
xblock: {
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
id: 'block-v1:edX+DemoX+Demo_Course+type@vertical+block@d91b9e5d8bc64d57a1332d06bf2f2144',
|
||||
display_name: 'Getting Started new',
|
||||
category: 'vertical',
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
children: [
|
||||
{
|
||||
name: 'Discussion',
|
||||
@@ -11,7 +11,7 @@ export const UNIT_VISIBILITY_STATES = {
|
||||
staffOnly: 'staff_only',
|
||||
live: 'live',
|
||||
ready: 'ready',
|
||||
};
|
||||
} as const;
|
||||
|
||||
export const ICON_COLOR_VARIANTS = {
|
||||
BLACK: '#000',
|
||||
@@ -25,7 +25,7 @@ export const PUBLISH_TYPES = {
|
||||
republish: 'republish',
|
||||
discardChanges: 'discard_changes',
|
||||
makePublic: 'make_public',
|
||||
};
|
||||
} as const;
|
||||
|
||||
export const getXBlockSupportMessages = (intl) => ({
|
||||
fs: { // Fully supported
|
||||
|
||||
@@ -71,7 +71,7 @@ describe('<HeaderTitle />', () => {
|
||||
xblock_info: {
|
||||
...courseSectionVerticalMock.xblock_info,
|
||||
upstreamInfo: {
|
||||
...courseSectionVerticalMock.xblock_info.upstreamInfo,
|
||||
// ...courseSectionVerticalMock.xblock_info.upstream_info, // seems to be missing in the mock
|
||||
upstreamRef: 'lct:org:lib:unit:unit-1',
|
||||
},
|
||||
},
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user