Skip to content

Commit

Permalink
chore: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
leangseu-edx committed Sep 22, 2023
1 parent d8c4443 commit f70220e
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/data/services/lms/hooks/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const submitResponse = () =>
return Promise.resolve(data);
});

export const saveResponseForLater = () =>
export const saveResponse = () =>
createMutationAction(async (data: any, queryClient) => {
// TODO: save response for later
await new Promise((resolve) => setTimeout(() => {
Expand Down
16 changes: 8 additions & 8 deletions src/views/SubmissionView/SubmissionActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ import messages from './messages';
const SubmissionActions = ({
submitResponseHandler,
submitResponseStatus,
saveResponseForLaterHandler,
saveResponseForLaterStatus,
saveResponseHandler,
saveResponseStatus,
}) => {
const { formatMessage } = useIntl();

return (
<ActionRow>
<StatefulButton
variant="secondary"
onClick={saveResponseForLaterHandler}
state={saveResponseForLaterStatus}
onClick={saveResponseHandler}
state={saveResponseStatus}
disabledStates={[MutationStatus.loading]}
labels={{
default: formatMessage(messages.saveForLaterActionSave),
default: formatMessage(messages.saveActionSave),
[MutationStatus.loading]: formatMessage(
messages.saveForLaterActionSaving,
messages.saveActionSaving,
),
}}
/>
Expand All @@ -49,8 +49,8 @@ SubmissionActions.propTypes = {
submitResponseHandler: PropTypes.func.isRequired,
submitResponseStatus: PropTypes.oneOf(Object.values(MutationStatus))
.isRequired,
saveResponseForLaterHandler: PropTypes.func.isRequired,
saveResponseForLaterStatus: PropTypes.oneOf(Object.values(MutationStatus))
saveResponseHandler: PropTypes.func.isRequired,
saveResponseStatus: PropTypes.oneOf(Object.values(MutationStatus))
.isRequired,
};

Expand Down
4 changes: 2 additions & 2 deletions src/views/SubmissionView/SubmissionActions.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ describe('<SubmissionActions />', () => {
const props = {
submitResponseHandler: jest.fn().mockName('submitResponseHandler'),
submitResponseStatus: 'idle',
saveResponseForLaterHandler: jest.fn().mockName('saveResponseForLaterHandler'),
saveResponseForLaterStatus: 'idle',
saveResponseHandler: jest.fn().mockName('saveResponseHandler'),
saveResponseStatus: 'idle',
};

it('renders', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports[`<SubmissionActions /> renders 1`] = `
"loading": "Saving response",
}
}
onClick={[MockFunction saveResponseForLaterHandler]}
onClick={[MockFunction saveResponseHandler]}
state="idle"
variant="secondary"
/>
Expand Down
4 changes: 2 additions & 2 deletions src/views/SubmissionView/__snapshots__/index.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ exports[`<SubmissionView /> renders 1`] = `
<FullscreenModal
footerNode={
<SubmissionActions
saveResponseForLaterHandler={[MockFunction saveResponseForLaterHandler]}
saveResponseForLaterStatus="saveResponseForLaterStatus"
saveResponseHandler={[MockFunction saveResponseHandler]}
saveResponseStatus="saveResponseStatus"
submitResponseHandler={[MockFunction submitResponseHandler]}
submitResponseStatus="submitResponseStatus"
/>
Expand Down
14 changes: 7 additions & 7 deletions src/views/SubmissionView/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { useEffect, useReducer } from 'react';

import { useORAConfigData, usePageData } from 'data/services/lms/hooks/selectors';

import { submitResponse, saveResponseForLater, uploadFiles } from 'data/services/lms/hooks/actions';
import { submitResponse, saveResponse, uploadFiles } from 'data/services/lms/hooks/actions';
import { MutationStatus } from 'data/services/lms/constants';

const useSubmissionViewHooks = () => {
const submitResponseMutation = submitResponse();
const saveResponseForLaterMutation = saveResponseForLater();
const saveResponseMutation = saveResponse();
const uploadFilesMutation = uploadFiles();
const pageData = usePageData();
const oraConfigData = useORAConfigData();

Check warning on line 13 in src/views/SubmissionView/hooks.js

View check run for this annotation

Codecov / codecov/patch

src/views/SubmissionView/hooks.js#L8-L13

Added lines #L8 - L13 were not covered by tests
Expand Down Expand Up @@ -47,17 +47,17 @@ const useSubmissionViewHooks = () => {
submitResponseMutation.mutate(submission);

Check warning on line 47 in src/views/SubmissionView/hooks.js

View check run for this annotation

Codecov / codecov/patch

src/views/SubmissionView/hooks.js#L45-L47

Added lines #L45 - L47 were not covered by tests
};

const saveResponseForLaterHandler = () => {
const saveResponseHandler = () => {
dispatchSubmission({ isDirty: false });
saveResponseForLaterMutation.mutate(submission);
saveResponseMutation.mutate(submission);

Check warning on line 52 in src/views/SubmissionView/hooks.js

View check run for this annotation

Codecov / codecov/patch

src/views/SubmissionView/hooks.js#L50-L52

Added lines #L50 - L52 were not covered by tests
};

return {

Check warning on line 55 in src/views/SubmissionView/hooks.js

View check run for this annotation

Codecov / codecov/patch

src/views/SubmissionView/hooks.js#L55

Added line #L55 was not covered by tests
submitResponseHandler,
submitResponseStatus: submitResponseMutation.status,
saveResponseForLaterHandler,
saveResponseForLaterStatus: saveResponseForLaterMutation.status,
draftSaved: saveResponseForLaterMutation.status === MutationStatus.success && !submission.isDirty,
saveResponseHandler,
saveResponseStatus: saveResponseMutation.status,
draftSaved: saveResponseMutation.status === MutationStatus.success && !submission.isDirty,

Check warning on line 60 in src/views/SubmissionView/hooks.js

View check run for this annotation

Codecov / codecov/patch

src/views/SubmissionView/hooks.js#L60

Added line #L60 was not covered by tests
pageData,
oraConfigData,
submission,
Expand Down
8 changes: 4 additions & 4 deletions src/views/SubmissionView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const SubmissionView = () => {
onTextResponseChange,
submitResponseHandler,
submitResponseStatus,
saveResponseForLaterHandler,
saveResponseForLaterStatus,
saveResponseHandler,
saveResponseStatus,
draftSaved,
} = useSubmissionViewHooks();

Expand All @@ -29,8 +29,8 @@ export const SubmissionView = () => {
<SubmissionActions
submitResponseHandler={submitResponseHandler}
submitResponseStatus={submitResponseStatus}
saveResponseForLaterHandler={saveResponseForLaterHandler}
saveResponseForLaterStatus={saveResponseForLaterStatus}
saveResponseHandler={saveResponseHandler}
saveResponseStatus={saveResponseStatus}
/>
)}
>
Expand Down
4 changes: 2 additions & 2 deletions src/views/SubmissionView/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jest.mock('./hooks', () => jest.fn().mockReturnValue({
onTextResponseChange: jest.fn().mockName('onTextResponseChange'),
submitResponseHandler: jest.fn().mockName('submitResponseHandler'),
submitResponseStatus: 'submitResponseStatus',
saveResponseForLaterHandler: jest.fn().mockName('saveResponseForLaterHandler'),
saveResponseForLaterStatus: 'saveResponseForLaterStatus',
saveResponseHandler: jest.fn().mockName('saveResponseHandler'),
saveResponseStatus: 'saveResponseStatus',
draftSaved: true,
}));

Expand Down
8 changes: 4 additions & 4 deletions src/views/SubmissionView/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ const messages = defineMessages({
defaultMessage: 'Response submitted',
description: 'Submit button text after successful submission',
},
saveForLaterActionSave: {
id: 'ora-grading.SaveForLaterAction.save',
saveActionSave: {
id: 'ora-grading.SaveAction.save',
defaultMessage: 'Finish later',
description: 'Save for later button text',
},
saveForLaterActionSaving: {
id: 'ora-grading.SaveForLaterAction.saving',
saveActionSaving: {
id: 'ora-grading.SaveAction.saving',
defaultMessage: 'Saving response',
description: 'Save for later button text while saving',
},
Expand Down

0 comments on commit f70220e

Please sign in to comment.