Skip to content

Commit

Permalink
refactor: refactoring after review
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang authored and arbrandes committed Feb 27, 2024
1 parent 6aff1c1 commit 6b57ce3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/course-unit/CourseUnit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const CourseUnit = ({ courseId }) => {
unitTitle,
isQueryPending,
savingStatus,
isEditTitleFormOpen,
isTitleEditFormOpen,
isErrorAlert,
isInternetConnectionAlertFailed,
handleTitleEditSubmit,
Expand Down Expand Up @@ -62,7 +62,7 @@ const CourseUnit = ({ courseId }) => {
title={(
<HeaderTitle
unitTitle={unitTitle}
isEditTitleFormOpen={isEditTitleFormOpen}
isTitleEditFormOpen={isTitleEditFormOpen}
handleTitleEdit={handleTitleEdit}
handleTitleEditSubmit={handleTitleEditSubmit}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/course-unit/data/slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const slice = createSlice({
initialState: {
savingStatus: '',
isQueryPending: false,
isEditTitleFormOpen: false,
isTitleEditFormOpen: false,
loadingStatus: {
fetchUnitLoadingStatus: RequestStatus.IN_PROGRESS,
courseSectionVerticalLoadingStatus: RequestStatus.IN_PROGRESS,
Expand All @@ -30,7 +30,7 @@ const slice = createSlice({
state.isQueryPending = payload;
},
changeEditTitleFormOpen: (state, { payload }) => {
state.isEditTitleFormOpen = payload;
state.isTitleEditFormOpen = payload;
},
updateSavingStatus: (state, { payload }) => {
state.savingStatus = payload.status;
Expand Down
6 changes: 3 additions & 3 deletions src/course-unit/header-title/HeaderTitle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import messages from './messages';

const HeaderTitle = ({
unitTitle,
isEditTitleFormOpen,
isTitleEditFormOpen,
handleTitleEdit,
handleTitleEditSubmit,
}) => {
Expand All @@ -28,7 +28,7 @@ const HeaderTitle = ({

return (
<div className="d-flex align-items-center lead">
{isEditTitleFormOpen ? (
{isTitleEditFormOpen ? (
<Form.Group className="m-0">
<Form.Control
ref={(e) => e && e.focus()}
Expand Down Expand Up @@ -63,7 +63,7 @@ const HeaderTitle = ({

HeaderTitle.propTypes = {
unitTitle: PropTypes.string.isRequired,
isEditTitleFormOpen: PropTypes.bool.isRequired,
isTitleEditFormOpen: PropTypes.bool.isRequired,
handleTitleEdit: PropTypes.func.isRequired,
handleTitleEditSubmit: PropTypes.func.isRequired,
};
Expand Down
8 changes: 4 additions & 4 deletions src/course-unit/header-title/HeaderTitle.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import HeaderTitle from './HeaderTitle';
import messages from './messages';

const unitTitle = 'Getting Started';
const isEditTitleFormOpen = false;
const isTitleEditFormOpen = false;
const handleTitleEdit = jest.fn();
const handleTitleEditSubmit = jest.fn();
let store;
Expand All @@ -19,7 +19,7 @@ const renderComponent = (props) => render(
<IntlProvider locale="en">
<HeaderTitle
unitTitle={unitTitle}
isEditTitleFormOpen={isEditTitleFormOpen}
isTitleEditFormOpen={isTitleEditFormOpen}
handleTitleEdit={handleTitleEdit}
handleTitleEditSubmit={handleTitleEditSubmit}
{...props}
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('<HeaderTitle />', () => {

it('render HeaderTitle with open edit form', () => {
const { getByRole } = renderComponent({
isEditTitleFormOpen: true,
isTitleEditFormOpen: true,
});

expect(getByRole('textbox', { name: messages.ariaLabelButtonEdit.defaultMessage })).toBeInTheDocument();
Expand All @@ -71,7 +71,7 @@ describe('<HeaderTitle />', () => {

it('calls saving title by clicking outside or press Enter key', async () => {
const { getByRole } = renderComponent({
isEditTitleFormOpen: true,
isTitleEditFormOpen: true,
});

const titleField = getByRole('textbox', { name: messages.ariaLabelButtonEdit.defaultMessage });
Expand Down
6 changes: 3 additions & 3 deletions src/course-unit/hooks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const useCourseUnit = ({ courseId, blockId }) => {
const loadingStatus = useSelector(getLoadingStatus);
const { draftPreviewLink, publishedPreviewLink } = useSelector(getCourseSectionVertical);
const navigate = useNavigate();
const isEditTitleFormOpen = useSelector(state => state.courseUnit.isEditTitleFormOpen);
const isTitleEditFormOpen = useSelector(state => state.courseUnit.isTitleEditFormOpen);
const isQueryPending = useSelector(state => state.courseUnit.isQueryPending);

const unitTitle = courseUnit.metadata?.displayName || '';
Expand All @@ -49,7 +49,7 @@ export const useCourseUnit = ({ courseId, blockId }) => {
};

const handleTitleEdit = () => {
dispatch(changeEditTitleFormOpen(!isEditTitleFormOpen));
dispatch(changeEditTitleFormOpen(!isTitleEditFormOpen));
};

const handleTitleEditSubmit = (displayName) => {
Expand Down Expand Up @@ -95,7 +95,7 @@ export const useCourseUnit = ({ courseId, blockId }) => {
isErrorAlert,
isLoading: loadingStatus.fetchUnitLoadingStatus === RequestStatus.IN_PROGRESS
|| loadingStatus.courseSectionVerticalLoadingStatus === RequestStatus.IN_PROGRESS,
isEditTitleFormOpen,
isTitleEditFormOpen,
isInternetConnectionAlertFailed: savingStatus === RequestStatus.FAILED,
handleInternetConnectionFailed,
headerNavigationsActions,
Expand Down

0 comments on commit 6b57ce3

Please sign in to comment.