From a37630fa3e0f22faae1f5c509e80d1c4119da247 Mon Sep 17 00:00:00 2001 From: YuliaRomanyk <117859473+YulichkaR@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:56:13 +0300 Subject: [PATCH] Bugfix/2276/set not visible button (#2299) * Set not visible Edit button in cooperation * Fixed tests --- .../CooperationActivitiesView.tsx | 25 ++++++++++++------- .../ CooperationActivitiesView.spec.jsx | 4 ++- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/containers/cooperation-details/cooperetion-activities-view/CooperationActivitiesView.tsx b/src/containers/cooperation-details/cooperetion-activities-view/CooperationActivitiesView.tsx index c06074da8..834dba5c5 100644 --- a/src/containers/cooperation-details/cooperetion-activities-view/CooperationActivitiesView.tsx +++ b/src/containers/cooperation-details/cooperetion-activities-view/CooperationActivitiesView.tsx @@ -11,6 +11,7 @@ import { } from '~/redux/features/cooperationsSlice' import { styles } from '~/containers/cooperation-details/cooperetion-activities-view/CooperationActivitiesView.style' +import { CourseSection, UserRoleEnum } from '~/types' interface CooperationActivitiesViewProps { sections: CourseSection[] @@ -28,20 +29,26 @@ const CooperationActivitiesView: FC = ({ dispatch(setIsAddedClicked(false)) } + const { userRole } = useAppSelector((state) => state.appMain) + const isTutor = userRole === UserRoleEnum.Tutor + return ( {sections.map((item) => ( ))} - - - - - + + {isTutor && ( + + + + + + )} ) } diff --git a/tests/unit/containers/cooperation-details/ CooperationActivitiesView.spec.jsx b/tests/unit/containers/cooperation-details/ CooperationActivitiesView.spec.jsx index 6c5bf7bae..c23f2da28 100644 --- a/tests/unit/containers/cooperation-details/ CooperationActivitiesView.spec.jsx +++ b/tests/unit/containers/cooperation-details/ CooperationActivitiesView.spec.jsx @@ -1,5 +1,6 @@ import { render, screen, act, fireEvent } from '@testing-library/react' import { describe, it, expect, vi, beforeEach } from 'vitest' +import { UserRoleEnum } from '~/types' import CooperationActivitiesView from '~/containers/cooperation-details/cooperetion-activities-view/CooperationActivitiesView.tsx' vi.mock('~/components/cooperation-section-view/CooperationSectionView', () => ({ @@ -13,7 +14,8 @@ vi.mock('~/hooks/use-redux', () => ({ sections: [ { _id: '1', title: 'Section1' }, { _id: '2', title: 'Section2' } - ] + ], + userRole: UserRoleEnum.Tutor }), useAppDispatch: vi.fn().mockReturnValue(vi.fn()) }))