Skip to content

Commit

Permalink
refactor: remove delete unit hook and thunk till unit list is impleme…
Browse files Browse the repository at this point in the history
…nted
  • Loading branch information
navinkarkera committed Dec 19, 2023
1 parent 90faac1 commit d649b46
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 34 deletions.
18 changes: 0 additions & 18 deletions src/course-outline/data/slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,6 @@ const slice = createSlice({
return section;
});
},
deleteUnit: (state, { payload }) => {
state.sectionsList = state.sectionsList.map((section) => {
if (section.id !== payload.sectionId) {
return section;
}
section.childInfo.children = section.childInfo.children.map((subsection) => {
if (subsection.id !== payload.subsectionId) {
return subsection;
}
subsection.childInfo.children = subsection.childInfo.children.filter(
({ id }) => id !== payload.itemId,
);
return subsection;
});
return section;
});
},
duplicateSection: (state, { payload }) => {
state.sectionsList = state.sectionsList.reduce((result, currentValue) => {
if (currentValue.id === payload.id) {
Expand Down Expand Up @@ -166,7 +149,6 @@ export const {
setCurrentSubsection,
deleteSection,
deleteSubsection,
deleteUnit,
duplicateSection,
reorderSectionList,
} = slice.actions;
Expand Down
10 changes: 0 additions & 10 deletions src/course-outline/data/thunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {
updateFetchSectionLoadingStatus,
deleteSection,
deleteSubsection,
deleteUnit,
duplicateSection,
reorderSectionList,
} from './slice';
Expand Down Expand Up @@ -265,15 +264,6 @@ export function deleteCourseSubsectionQuery(subsectionId, sectionId) {
};
}

export function deleteCourseUnitQuery(unitId, subsectionId, sectionId) {
return async (dispatch) => {
dispatch(deleteCourseItemQuery(
unitId,
() => deleteUnit({ itemId: unitId, subsectionId, sectionId }),
));
};
}

/**
* Generic function to duplicate any course item. See wrapper functions below for specific implementations.
* @param {string} itemId
Expand Down
7 changes: 1 addition & 6 deletions src/course-outline/hooks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
addNewSubsectionQuery,
deleteCourseSectionQuery,
deleteCourseSubsectionQuery,
deleteCourseUnitQuery,
editCourseItemQuery,
duplicateSectionQuery,
duplicateSubsectionQuery,
Expand Down Expand Up @@ -133,11 +132,7 @@ const useCourseOutline = ({ courseId }) => {
dispatch(deleteCourseSubsectionQuery(currentItem.id, currentSection.id));
break;
case COURSE_BLOCK_NAMES.vertical.id:

Check warning on line 134 in src/course-outline/hooks.jsx

View check run for this annotation

Codecov / codecov/patch

src/course-outline/hooks.jsx#L128-L134

Added lines #L128 - L134 were not covered by tests
dispatch(deleteCourseUnitQuery(
currentItem.id,
currentSubsection.id,
currentSection.id,
));
// delete unit
break;
default:
return;

Check warning on line 138 in src/course-outline/hooks.jsx

View check run for this annotation

Codecov / codecov/patch

src/course-outline/hooks.jsx#L136-L138

Added lines #L136 - L138 were not covered by tests
Expand Down

0 comments on commit d649b46

Please sign in to comment.