diff --git a/src/containers/course-section/CourseSectionContainer.tsx b/src/containers/course-section/CourseSectionContainer.tsx index 03c6446732..fe6f0af802 100644 --- a/src/containers/course-section/CourseSectionContainer.tsx +++ b/src/containers/course-section/CourseSectionContainer.tsx @@ -238,6 +238,7 @@ const CourseSectionContainer: FC = ({ sectionId: sectionData.id }) } + const handleAddResources = async ( resources: T[], isDuplicate: boolean @@ -273,7 +274,6 @@ const CourseSectionContainer: FC = ({ } } } - // resourceEventHandler?.({ type: CourseResourceEventType.AddSectionResources, @@ -283,12 +283,19 @@ const CourseSectionContainer: FC = ({ }) } + const onAddResourcesWrapper = ( + resources: (Lesson | Quiz | Attachment)[], + isDuplicate: boolean + ) => { + void handleAddResources(resources, isDuplicate) + } + const handleOpenAddLessonsModal = () => { openModal({ component: ( columns={lessonColumns} - onAddResources={() => handleAddResources} + onAddResources={onAddResourcesWrapper} removeColumnRules={removeLessonColumnRules} requestService={ResourceService.getUsersLessons} resourceTab={resourcesData.lessons.resourceTab} @@ -304,7 +311,7 @@ const CourseSectionContainer: FC = ({ component: ( columns={quizColumns} - onAddResources={() => handleAddResources} + onAddResources={onAddResourcesWrapper} removeColumnRules={removeQuizColumnRules} requestService={ResourceService.getQuizzes} resourceTab={resourcesData.quizzes.resourceTab} @@ -320,7 +327,7 @@ const CourseSectionContainer: FC = ({ component: ( columns={attachmentColumns} - onAddResources={() => handleAddResources} + onAddResources={onAddResourcesWrapper} removeColumnRules={removeAttachmentColumnRules} requestService={ResourceService.getAttachments} resourceTab={resourcesData.attachments.resourceTab} diff --git a/tests/unit/redux/cooperationsSlice.spec.js b/tests/unit/redux/cooperationsSlice.spec.js index 9fe2b42966..40ba496baf 100644 --- a/tests/unit/redux/cooperationsSlice.spec.js +++ b/tests/unit/redux/cooperationsSlice.spec.js @@ -182,7 +182,7 @@ describe('Test cooperationsSlice', () => { const addedResource = state.sections[0].resources[0].resource - expect(isValidUUID(addedResource.id)).toBe(true) + expect(addedResource.id).toBe(resources[0]._id) expect(addedResource).toMatchObject({ _id: 'some id', title: 'Resource 1', @@ -214,13 +214,8 @@ describe('Test cooperationsSlice', () => { const addedResource = state.sections[0].resources[0].resource - expect(isValidUUID(addedResource.id)).toBe(true) - expect(addedResource).toMatchObject({ - _id: '', - title: 'Resource 1', - resourceType: ResourceType.Lesson, - isDuplicate: true - }) + expect(addedResource.id).toBe(resources[0]._id) + expect(addedResource).toMatchObject(resources[0]) }) it('should update resources order correctly with updateResourcesOrder', () => {