From d73d03b2f7c415dfe0004402c38a2ff73871a2db Mon Sep 17 00:00:00 2001 From: Leangseu Kim Date: Wed, 31 Jan 2024 16:07:39 -0500 Subject: [PATCH] chore: update left over test --- src/components/CriterionContainer/index.jsx | 1 + src/hooks/actions/useLoadNextAction.js | 16 +++++----------- src/hooks/routing.js | 16 +++------------- src/utils/isXblockStep.js | 11 ++++++++++- tsconfig.json | 3 ++- 5 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/components/CriterionContainer/index.jsx b/src/components/CriterionContainer/index.jsx index e6e9f822..f5a3192b 100644 --- a/src/components/CriterionContainer/index.jsx +++ b/src/components/CriterionContainer/index.jsx @@ -50,6 +50,7 @@ CriterionContainer.propTypes = { options: PropTypes.arrayOf( PropTypes.shape({ name: PropTypes.string.isRequired, + label: PropTypes.string.isRequired, description: PropTypes.string.isRequired, }), ).isRequired, diff --git a/src/hooks/actions/useLoadNextAction.js b/src/hooks/actions/useLoadNextAction.js index 77753ad5..5b3a97cd 100644 --- a/src/hooks/actions/useLoadNextAction.js +++ b/src/hooks/actions/useLoadNextAction.js @@ -1,11 +1,7 @@ import React from 'react'; import { useIntl } from '@edx/frontend-platform/i18n'; -import { - usePageDataStatus, - useRefreshPageData, - useStepInfo, -} from 'hooks/app'; +import { usePageDataStatus, useRefreshPageData, useStepInfo } from 'hooks/app'; import { useResetAssessment } from 'hooks/assessment'; import { useEffectiveStep } from 'hooks/routing'; import { useIsMounted } from 'hooks/utils'; @@ -22,16 +18,14 @@ export default () => { const stepInfo = useStepInfo(); const step = useEffectiveStep(); if ( - !( - step === stepNames.studentTraining - || (step === stepNames.peer) - || (step === stepNames.peer && !stepInfo.peer?.isWaitingForSubmissions) - ) + ![stepNames.studentTraining, stepNames.peer].includes(step) || + (step === stepNames.peer && stepInfo.peer?.isWaitingForSubmissions) ) { return null; } - const label = (message) => `${formatMessage(message)} ${formatMessage(loadNextSteps[step])}`; + const label = (message) => + `${formatMessage(message)} ${formatMessage(loadNextSteps[step])}`; return { action: { diff --git a/src/hooks/routing.js b/src/hooks/routing.js index 4549761f..b6ed784c 100644 --- a/src/hooks/routing.js +++ b/src/hooks/routing.js @@ -1,6 +1,7 @@ import { useLocation } from 'react-router-dom'; import { useActiveStepName } from 'data/services/lms/hooks/selectors'; -import { routeSteps, stepNames } from 'constants/index'; +import { routeSteps } from 'constants/index'; +import { isXblockStep } from 'utils'; export const hooks = { /** @@ -18,16 +19,6 @@ Object.assign(hooks, { */ useViewStep: () => routeSteps[hooks.useActiveView()], }); -Object.assign(hooks, { - /** - * isXblockStep(step) - * @description returns true if the step is an xblock step - * @param {string} step - step to check - * @returns {boolean} true if the step is an xblock step - */ - isXblockStep: (step) => [stepNames.xblock, stepNames.xblockStudio, stepNames.xblockPreview].includes(step), -}); - Object.assign(hooks, { /** * useEffectiveStep() @@ -37,12 +28,11 @@ Object.assign(hooks, { useEffectiveStep: () => { const viewStep = hooks.useViewStep(); const activeStep = useActiveStepName(); - return hooks.isXblockStep(isXblockStep) ? activeStep : viewStep; + return isXblockStep(viewStep) ? activeStep : viewStep; }, }); export const { useActiveView, useViewStep, useEffectiveStep, - isXblockStep, } = hooks; diff --git a/src/utils/isXblockStep.js b/src/utils/isXblockStep.js index 2c649035..749b3082 100644 --- a/src/utils/isXblockStep.js +++ b/src/utils/isXblockStep.js @@ -1,3 +1,12 @@ import { stepNames } from 'constants/index'; -export default (step) => [stepNames.xblock, stepNames.xblockStudio, stepNames.xblockPreview].includes(step); +/** + * isXblockStep(step) + * @description returns true if the step is an xblock step + * @param {string} step - step to check + * @returns {boolean} true if the step is an xblock step + */ +export default (step) => + [stepNames.xblock, stepNames.xblockStudio, stepNames.xblockPreview].includes( + step + ); diff --git a/tsconfig.json b/tsconfig.json index 4c65ac2f..1e86a4d6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,8 @@ "components": ["components/*"], "constants": ["constants/*"], "views": ["views/*"], - "utils": ["utils/*"] + "utils": ["utils/*"], + "hooks": ["hooks/*"], } }, "include": ["src"],