From 8b1bbc5446bf69e04af084c1d05f8a59ac39cd76 Mon Sep 17 00:00:00 2001 From: PKulkoRaccoonGang Date: Thu, 13 Jun 2024 17:39:27 +0300 Subject: [PATCH] fix: fixed tests --- src/course-checklist/CourseChecklist.jsx | 6 +-- src/course-outline/data/thunk.js | 1 - src/grading-settings/GradingSettings.jsx | 4 +- src/grading-settings/data/thunks.js | 63 ------------------------ 4 files changed, 5 insertions(+), 69 deletions(-) delete mode 100644 src/grading-settings/data/thunks.js diff --git a/src/course-checklist/CourseChecklist.jsx b/src/course-checklist/CourseChecklist.jsx index b71817f168..cdce73695c 100644 --- a/src/course-checklist/CourseChecklist.jsx +++ b/src/course-checklist/CourseChecklist.jsx @@ -37,10 +37,10 @@ const CourseChecklist = ({ bestPracticeData, } = useSelector(state => state.courseChecklist); - const { bestPracticeChecklistStatus, launchChecklistStatus } = loadingStatus; + const { bestPracticeChecklistLoadingStatus, launchChecklistLoadingStatus, launchChecklistStatus } = loadingStatus; - const isCourseLaunchChecklistLoading = bestPracticeChecklistStatus === RequestStatus.IN_PROGRESS; - const isCourseBestPracticeChecklistLoading = launchChecklistStatus === RequestStatus.IN_PROGRESS; + const isCourseLaunchChecklistLoading = bestPracticeChecklistLoadingStatus === RequestStatus.IN_PROGRESS; + const isCourseBestPracticeChecklistLoading = launchChecklistLoadingStatus === RequestStatus.IN_PROGRESS; const isLoadingDenied = launchChecklistStatus === RequestStatus.DENIED; if (isLoadingDenied) { diff --git a/src/course-outline/data/thunk.js b/src/course-outline/data/thunk.js index 18b7eea2e2..c555fcb978 100644 --- a/src/course-outline/data/thunk.js +++ b/src/course-outline/data/thunk.js @@ -102,7 +102,6 @@ export function fetchCourseOutlineIndexQuery(courseId) { if (error.response && error.response.status === 403) { dispatch(updateOutlineIndexLoadingStatus({ status: RequestStatus.DENIED, - errors: getErrorDetails(error, false), })); } else { dispatch(updateOutlineIndexLoadingStatus({ diff --git a/src/grading-settings/GradingSettings.jsx b/src/grading-settings/GradingSettings.jsx index e6defa9b6d..8ddd7a9bb5 100644 --- a/src/grading-settings/GradingSettings.jsx +++ b/src/grading-settings/GradingSettings.jsx @@ -8,6 +8,7 @@ import { useGradingSettings, useGradingSettingUpdater, } from 'CourseAuthoring/grading-settings/data/apiHooks'; +import { RequestStatus } from 'CourseAuthoring/data/constants'; import PropTypes from 'prop-types'; import React, { useEffect, useState } from 'react'; import { Helmet } from 'react-helmet'; @@ -47,8 +48,7 @@ const GradingSettings = ({ courseId }) => { const courseAssignmentLists = gradingSettings?.courseAssignmentLists; const courseGradingDetails = gradingSettings?.courseDetails; - - const isLoadingDenied = loadingStatus === RequestStatus.DENIED; + const isLoadingDenied = isCourseSettingsLoading === RequestStatus.DENIED; const [showSuccessAlert, setShowSuccessAlert] = useState(false); const isLoading = isCourseSettingsLoading || isGradingSettingsLoading; const [isQueryPending, setIsQueryPending] = useState(false); diff --git a/src/grading-settings/data/thunks.js b/src/grading-settings/data/thunks.js deleted file mode 100644 index 39094ffe55..0000000000 --- a/src/grading-settings/data/thunks.js +++ /dev/null @@ -1,63 +0,0 @@ -import { RequestStatus } from '../../data/constants'; -import { - getGradingSettings, - sendGradingSettings, - getCourseSettings, -} from './api'; -import { - sendGradingSettingsSuccess, - updateLoadingStatus, - updateSavingStatus, - fetchGradingSettingsSuccess, - fetchCourseSettingsSuccess, -} from './slice'; - -export function fetchGradingSettings(courseId) { - return async (dispatch) => { - dispatch(updateLoadingStatus({ status: RequestStatus.IN_PROGRESS })); - try { - const settingValues = await getGradingSettings(courseId); - dispatch(fetchGradingSettingsSuccess(settingValues)); - dispatch(updateLoadingStatus({ status: RequestStatus.SUCCESSFUL })); - } catch (error) { - if (error.response && error.response.status === 403) { - dispatch(updateLoadingStatus({ status: RequestStatus.DENIED })); - } else { - dispatch(updateLoadingStatus({ courseId, status: RequestStatus.FAILED })); - } - } - }; -} - -export function sendGradingSetting(courseId, settings) { - return async (dispatch) => { - dispatch(updateSavingStatus({ status: RequestStatus.IN_PROGRESS })); - try { - const settingValues = await sendGradingSettings(courseId, settings); - dispatch(sendGradingSettingsSuccess(settingValues)); - dispatch(updateSavingStatus({ status: RequestStatus.SUCCESSFUL })); - } catch (error) { - dispatch(updateLoadingStatus({ status: RequestStatus.FAILED })); - } - }; -} - -export function fetchCourseSettingsQuery(courseId) { - return async (dispatch) => { - dispatch(updateLoadingStatus({ status: RequestStatus.IN_PROGRESS })); - - try { - const settingsValues = await getCourseSettings(courseId); - dispatch(fetchCourseSettingsSuccess(settingsValues)); - dispatch(updateLoadingStatus({ status: RequestStatus.SUCCESSFUL })); - return true; - } catch (error) { - if (error.response && error.response.status === 403) { - dispatch(updateLoadingStatus({ status: RequestStatus.DENIED })); - } else { - dispatch(updateLoadingStatus({ courseId, status: RequestStatus.FAILED })); - } - return false; - } - }; -}