chore(deps): update dependency universal-cookie to v8 (#2512)

* fix(deps): update dependency universal-cookie to v8

* refactor: validate typing of universal-cookie usages

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Braden MacDonald <braden@opencraft.com>
This commit is contained in:
renovate[bot]
2025-10-06 23:08:46 +00:00
committed by GitHub
parent 0315c05e11
commit 8fe5fb6a20
12 changed files with 40 additions and 32 deletions

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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 });
};

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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 });
};