diff --git a/package-lock.json b/package-lock.json index a34c5436b..a0ad3fd1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -74,7 +74,7 @@ "redux-thunk": "^2.4.1", "reselect": "^4.1.5", "tinymce": "^5.10.4", - "universal-cookie": "^4.0.4", + "universal-cookie": "^8.0.0", "uuid": "^11.1.0", "xmlchecker": "^0.1.0", "yup": "0.32.11" @@ -2703,6 +2703,25 @@ "proxy-from-env": "^1.1.0" } }, + "node_modules/@edx/frontend-platform/node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/@edx/frontend-platform/node_modules/universal-cookie": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-4.0.4.tgz", + "integrity": "sha512-lbRVHoOMtItjWbM7TwDLdl8wug7izB0tq3/YVKhT/ahB4VDvWMyvnADfnJI8y6fSvsjh51Ix7lTGC6Tn4rMPhw==", + "license": "MIT", + "dependencies": { + "@types/cookie": "^0.3.3", + "cookie": "^0.4.0" + } + }, "node_modules/@edx/new-relic-source-map-webpack-plugin": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/@edx/new-relic-source-map-webpack-plugin/-/new-relic-source-map-webpack-plugin-2.1.0.tgz", @@ -27905,22 +27924,21 @@ } }, "node_modules/universal-cookie": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-4.0.4.tgz", - "integrity": "sha512-lbRVHoOMtItjWbM7TwDLdl8wug7izB0tq3/YVKhT/ahB4VDvWMyvnADfnJI8y6fSvsjh51Ix7lTGC6Tn4rMPhw==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-8.0.1.tgz", + "integrity": "sha512-B6ks9FLLnP1UbPPcveOidfvB9pHjP+wekP2uRYB9YDfKVpvcjKgy1W5Zj+cEXJ9KTPnqOKGfVDQBmn8/YCQfRg==", "license": "MIT", "dependencies": { - "@types/cookie": "^0.3.3", - "cookie": "^0.4.0" + "cookie": "^1.0.2" } }, "node_modules/universal-cookie/node_modules/cookie": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", - "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz", + "integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==", "license": "MIT", "engines": { - "node": ">= 0.6" + "node": ">=18" } }, "node_modules/universalify": { diff --git a/package.json b/package.json index 0b57d3aa2..4376ce690 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "redux-thunk": "^2.4.1", "reselect": "^4.1.5", "tinymce": "^5.10.4", - "universal-cookie": "^4.0.4", + "universal-cookie": "^8.0.0", "uuid": "^11.1.0", "xmlchecker": "^0.1.0", "yup": "0.32.11" diff --git a/src/export-page/CourseExportPage.jsx b/src/export-page/CourseExportPage.tsx similarity index 97% rename from src/export-page/CourseExportPage.jsx rename to src/export-page/CourseExportPage.tsx index c83123336..870f6d151 100644 --- a/src/export-page/CourseExportPage.jsx +++ b/src/export-page/CourseExportPage.tsx @@ -1,5 +1,4 @@ import React, { useEffect } from 'react'; -import PropTypes from 'prop-types'; import { useDispatch, useSelector } from 'react-redux'; import { useIntl } from '@edx/frontend-platform/i18n'; import { @@ -27,7 +26,7 @@ import ExportModalError from './export-modal-error/ExportModalError'; import ExportFooter from './export-footer/ExportFooter'; import ExportStepper from './export-stepper/ExportStepper'; -const CourseExportPage = ({ courseId }) => { +const CourseExportPage = ({ courseId }: { courseId: string }) => { const intl = useIntl(); const dispatch = useDispatch(); const exportTriggered = useSelector(getExportTriggered); @@ -128,8 +127,4 @@ const CourseExportPage = ({ courseId }) => { ); }; -CourseExportPage.propTypes = { - courseId: PropTypes.string.isRequired, -}; - export default CourseExportPage; diff --git a/src/export-page/data/thunks.js b/src/export-page/data/thunks.ts similarity index 99% rename from src/export-page/data/thunks.js rename to src/export-page/data/thunks.ts index dd86ba84e..9b887adfc 100644 --- a/src/export-page/data/thunks.js +++ b/src/export-page/data/thunks.ts @@ -88,7 +88,7 @@ export function fetchExportStatus(courseId) { dispatch(updateLoadingStatus({ status: RequestStatus.SUCCESSFUL })); return true; - } catch (error) { + } catch (error: any) { if (error.response && error.response.status === 403) { dispatch(updateLoadingStatus({ status: RequestStatus.DENIED })); } else { diff --git a/src/export-page/utils.test.js b/src/export-page/utils.test.ts similarity index 96% rename from src/export-page/utils.test.js rename to src/export-page/utils.test.ts index 276f76ce4..ba7fa1ce9 100644 --- a/src/export-page/utils.test.js +++ b/src/export-page/utils.test.ts @@ -14,7 +14,7 @@ Object.defineProperty(window, 'location', { describe('setExportCookie', () => { it('should set the export cookie with the provided date and completed status', () => { const cookiesSetMock = jest.spyOn(Cookies.prototype, 'set'); - const date = '2023-07-24'; + const date = moment('2023-07-24').valueOf(); const completed = true; setExportCookie(date, completed); diff --git a/src/export-page/utils.js b/src/export-page/utils.ts similarity index 89% rename from src/export-page/utils.js rename to src/export-page/utils.ts index 9f24b743b..b85a8ffd9 100644 --- a/src/export-page/utils.js +++ b/src/export-page/utils.ts @@ -7,11 +7,11 @@ import { LAST_EXPORT_COOKIE_NAME, SUCCESS_DATE_FORMAT } from './data/constants'; /** * Sets an export-related cookie with the provided information. * - * @param {Date} date - Date of export. + * @param date - Date of export (unix timestamp). * @param {boolean} completed - Indicates if export was completed successfully. * @returns {void} */ -export const setExportCookie = (date, completed) => { +export const setExportCookie = (date: number, completed: boolean): void => { const cookies = new Cookies(); cookies.set(LAST_EXPORT_COOKIE_NAME, { date, completed }, { path: window.location.pathname }); }; diff --git a/src/import-page/CourseImportPage.jsx b/src/import-page/CourseImportPage.tsx similarity index 96% rename from src/import-page/CourseImportPage.jsx rename to src/import-page/CourseImportPage.tsx index 78cce332f..388ea8060 100644 --- a/src/import-page/CourseImportPage.jsx +++ b/src/import-page/CourseImportPage.tsx @@ -1,6 +1,5 @@ /* eslint-disable max-len */ import React, { useEffect } from 'react'; -import PropTypes from 'prop-types'; import { useDispatch, useSelector } from 'react-redux'; import { useIntl } from '@edx/frontend-platform/i18n'; import { @@ -24,7 +23,7 @@ import ImportSidebar from './import-sidebar/ImportSidebar'; import FileSection from './file-section/FileSection'; import messages from './messages'; -const CourseImportPage = ({ courseId }) => { +const CourseImportPage = ({ courseId }: { courseId: string }) => { const intl = useIntl(); const dispatch = useDispatch(); const cookies = new Cookies(); @@ -104,8 +103,4 @@ const CourseImportPage = ({ courseId }) => { ); }; -CourseImportPage.propTypes = { - courseId: PropTypes.string.isRequired, -}; - export default CourseImportPage; diff --git a/src/import-page/data/slice.js b/src/import-page/data/slice.ts similarity index 100% rename from src/import-page/data/slice.js rename to src/import-page/data/slice.ts diff --git a/src/import-page/data/thunks.js b/src/import-page/data/thunks.ts similarity index 98% rename from src/import-page/data/thunks.js rename to src/import-page/data/thunks.ts index 028fea2da..183dabbcb 100644 --- a/src/import-page/data/thunks.js +++ b/src/import-page/data/thunks.ts @@ -30,7 +30,7 @@ export function fetchImportStatus(courseId, fileName) { } dispatch(updateLoadingStatus(RequestStatus.SUCCESSFUL)); return true; - } catch (error) { + } catch (error: any) { if (error.response && error.response.status === 403) { dispatch(updateLoadingStatus(RequestStatus.DENIED)); } else { diff --git a/src/import-page/messages.js b/src/import-page/messages.ts similarity index 100% rename from src/import-page/messages.js rename to src/import-page/messages.ts diff --git a/src/import-page/utils.test.js b/src/import-page/utils.test.ts similarity index 90% rename from src/import-page/utils.test.js rename to src/import-page/utils.test.ts index 5b3c55dbf..48ed6e108 100644 --- a/src/import-page/utils.test.js +++ b/src/import-page/utils.test.ts @@ -1,4 +1,5 @@ import Cookies from 'universal-cookie'; +import moment from 'moment'; import { LAST_IMPORT_COOKIE_NAME } from './data/constants'; import { setImportCookie } from './utils'; @@ -13,7 +14,7 @@ Object.defineProperty(window, 'location', { describe('setImportCookie', () => { it('should set the import cookie with the provided data', () => { const cookiesSetMock = jest.spyOn(Cookies.prototype, 'set'); - const date = '2023-07-24'; + const date = moment('2023-07-24').valueOf(); const completed = true; const fileName = 'testFileName.test'; setImportCookie(date, completed, fileName); diff --git a/src/import-page/utils.js b/src/import-page/utils.ts similarity index 75% rename from src/import-page/utils.js rename to src/import-page/utils.ts index a5ce107ff..ee0d55a52 100644 --- a/src/import-page/utils.js +++ b/src/import-page/utils.ts @@ -5,12 +5,11 @@ import { LAST_IMPORT_COOKIE_NAME } from './data/constants'; /** * Sets an import-related cookie with the provided information. * - * @param {Date} date - Date of import. + * @param date - Date of import (unix timestamp). * @param {boolean} completed - Indicates if import was completed successfully. * @param {string} fileName - File name. - * @returns {void} */ -export const setImportCookie = (date, completed, fileName) => { +export const setImportCookie = (date: number, completed: boolean, fileName: string): void => { const cookies = new Cookies(); cookies.set(LAST_IMPORT_COOKIE_NAME, { date, completed, fileName }, { path: window.location.pathname }); };