Skip to content

Commit

Permalink
temp: tried to move hooks to hooks.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ilee2u committed Dec 14, 2023
1 parent dabb0d8 commit 7ab9d79
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
39 changes: 13 additions & 26 deletions src/pages/ExamsPage/components/ReviewExamAttemptModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ import {
import { useIntl } from '@edx/frontend-platform/i18n';
import { Info, Warning } from '@edx/paragon/icons';
import * as constants from 'data/constants';
import { useExamsData, useModifyExamAttempt } from '../hooks';
import { useExamAttemptUpdateData, useExamsData, useModifyExamAttempt } from '../hooks';

Check failure on line 10 in src/pages/ExamsPage/components/ReviewExamAttemptModal.jsx

View workflow job for this annotation

GitHub Actions / test (16)

useExamAttemptUpdateData not found in '../hooks'

Check failure on line 10 in src/pages/ExamsPage/components/ReviewExamAttemptModal.jsx

View workflow job for this annotation

GitHub Actions / test (16)

'useExamAttemptUpdateData' is defined but never used
import messages from '../messages';
import { getLaunchUrlByExamId, getMessageLabelForStatus } from '../utils';
import { RequestKeys } from 'data/constants';
import * as reduxHooks from 'data/redux/hooks';
import { async } from 'regenerator-runtime';


Check failure on line 14 in src/pages/ExamsPage/components/ReviewExamAttemptModal.jsx

View workflow job for this annotation

GitHub Actions / test (16)

More than 1 blank line not allowed

Expand All @@ -33,7 +30,12 @@ const ReviewExamAttemptModal = ({
}) => {
const [isOpen, open, close] = useToggle(false);
const modifyExamAttempt = useModifyExamAttempt();
const { currentExam } = useExamsData();
const {
currentExam,
isPending,

Check failure on line 35 in src/pages/ExamsPage/components/ReviewExamAttemptModal.jsx

View workflow job for this annotation

GitHub Actions / test (16)

'isPending' is assigned a value but never used
isCompleted,

Check failure on line 36 in src/pages/ExamsPage/components/ReviewExamAttemptModal.jsx

View workflow job for this annotation

GitHub Actions / test (16)

'isCompleted' is assigned a value but never used
isError,

Check failure on line 37 in src/pages/ExamsPage/components/ReviewExamAttemptModal.jsx

View workflow job for this annotation

GitHub Actions / test (16)

'isError' is assigned a value but never used
} = useExamsData();
const [rejectButtonStatus, setRejectButtonStatus] = useState('');

Check failure on line 39 in src/pages/ExamsPage/components/ReviewExamAttemptModal.jsx

View workflow job for this annotation

GitHub Actions / test (16)

'setRejectButtonStatus' is assigned a value but never used
const [verifyButtonStatus, setVerifyButtonStatus] = useState('');

Check failure on line 40 in src/pages/ExamsPage/components/ReviewExamAttemptModal.jsx

View workflow job for this annotation

GitHub Actions / test (16)

'setVerifyButtonStatus' is assigned a value but never used
const { formatMessage } = useIntl();
Expand All @@ -58,27 +60,6 @@ const ReviewExamAttemptModal = ({
variant: 'primary',
};

const getRequestStatus = () => {
console.log("OH BOY");
if (reduxHooks.useRequestIsPending(RequestKeys.modifyExamAttempt)) {
return 'pending';
} else if (reduxHooks.useRequestIsCompleted(RequestKeys.modifyExamAttempt)) {
return 'complete';
} else if (reduxHooks.useRequestError(RequestKeys.modifyExamAttempt)) {
return 'error';
};
return '';
};

// Set the status of the button
const updateButtonStatus = (buttonType) => {
if (buttonType == 'verify') {
setVerifyButtonStatus(getRequestStatus());
} else if (buttonType == 'reject') {
setRejectButtonStatus(getRequestStatus());
}
};

const getButton = (status) => {
if (ReviewRequiredStatuses.includes(status)) {
return (
Expand Down Expand Up @@ -116,6 +97,12 @@ const ReviewExamAttemptModal = ({
return null; // we should not get here
};

// const {
// isPending,
// isCompleted,
// isError,
// } = useExamAttemptUpdateData();

return (
<>
<div className="d-flex text-danger">
Expand Down
8 changes: 8 additions & 0 deletions src/pages/ExamsPage/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,18 @@ export const useExamsData = () => {
const setCurrentExam = module.useSetCurrentExam();
const isLoading = reduxHooks.useRequestIsPending(RequestKeys.fetchCourseExams);

// Request status vars for modifyexamattempt calls in ResetExamAttemptModal.jsx and ReviewExamAttemptModal.jsx
const isPending = reduxHooks.useRequestIsPending(RequestKeys.modifyExamAttempt);
const isCompleted = reduxHooks.useRequestIsCompleted(RequestKeys.modifyExamAttempt);
const isError = reduxHooks.useRequestError(RequestKeys.modifyExamAttempt);

return {
currentExam,
examsList,
isLoading,
isPending,
isCompleted,
isError,
exampleValue,
setCurrentExam,
setExampleValue,
Expand Down

0 comments on commit 7ab9d79

Please sign in to comment.