diff --git a/met-web/src/components/comments/admin/reviewListing/Submissions.tsx b/met-web/src/components/comments/admin/reviewListing/Submissions.tsx index 917f4b794..2daf4ac07 100644 --- a/met-web/src/components/comments/admin/reviewListing/Submissions.tsx +++ b/met-web/src/components/comments/admin/reviewListing/Submissions.tsx @@ -18,6 +18,7 @@ import { CommentListingContext } from './CommentListingContext'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import { useAppSelector } from 'hooks'; import { USER_ROLES } from 'services/userService/constants'; +import { USER_GROUP } from 'models/user'; const Submissions = () => { const { @@ -32,7 +33,7 @@ const Submissions = () => { pageInfo, loading, } = useContext(CommentListingContext); - const { roles } = useAppSelector((state) => state.user); + const { roles, userDetail, assignedEngagements } = useAppSelector((state) => state.user); const { state } = useLocation(); const [isExporting, setIsExporting] = useState(false); const [isAdvancedSearchOpen, setIsAdvancedSearchOpen] = useState(Boolean(state)); @@ -60,7 +61,11 @@ const Submissions = () => { label: 'ID', allowSort: true, renderCell: (row) => { - if (roles.includes(USER_ROLES.REVIEW_COMMENTS)) { + if ( + roles.includes(USER_ROLES.REVIEW_COMMENTS) || + (assignedEngagements.includes(Number(survey.engagement_id)) && + userDetail.groups?.includes('/' + USER_GROUP.TEAM_MEMBER.value)) + ) { return ( {row.id} diff --git a/met-web/src/components/comments/admin/textListing/index.tsx b/met-web/src/components/comments/admin/textListing/index.tsx index 33457558d..8680535f8 100644 --- a/met-web/src/components/comments/admin/textListing/index.tsx +++ b/met-web/src/components/comments/admin/textListing/index.tsx @@ -14,9 +14,10 @@ import { getSubmissionPage } from 'services/submissionService'; import { SurveySubmission } from 'models/surveySubmission'; import { formatDate } from 'components/common/dateHelper'; import { USER_ROLES } from 'services/userService/constants'; +import { USER_GROUP } from 'models/user'; const CommentTextListing = () => { - const { roles } = useAppSelector((state) => state.user); + const { roles, userDetail, assignedEngagements } = useAppSelector((state) => state.user); const badgeStyle: React.CSSProperties = { padding: 0, margin: 0, @@ -90,7 +91,11 @@ const CommentTextListing = () => { label: 'ID', allowSort: true, renderCell: (row) => { - if (roles.includes(USER_ROLES.REVIEW_COMMENTS)) { + if ( + roles.includes(USER_ROLES.REVIEW_COMMENTS) || + (assignedEngagements.includes(Number(row.engagement_id)) && + userDetail.groups?.includes('/' + USER_GROUP.TEAM_MEMBER.value)) + ) { return ( {row.id} diff --git a/met-web/src/models/surveySubmission.ts b/met-web/src/models/surveySubmission.ts index 75842fc0b..96786579b 100644 --- a/met-web/src/models/surveySubmission.ts +++ b/met-web/src/models/surveySubmission.ts @@ -16,6 +16,7 @@ export interface SurveySubmission { notify_email?: boolean; comments?: Comment[]; staff_note: StaffNote[]; + engagement_id: number; } export interface PublicSubmission { @@ -33,5 +34,6 @@ export const createDefaultSubmission = (): SurveySubmission => { reviewed_by: '', comment_status_id: 1, staff_note: [], + engagement_id: 0, }; }; diff --git a/met-web/src/routes/AuthGate.tsx b/met-web/src/routes/AuthGate.tsx index fff24ab4e..46b35d0e8 100644 --- a/met-web/src/routes/AuthGate.tsx +++ b/met-web/src/routes/AuthGate.tsx @@ -1,9 +1,11 @@ import React from 'react'; import { useAppSelector } from 'hooks'; import { useLocation, Navigate, Outlet } from 'react-router-dom'; +import { USER_GROUP } from 'models/user'; const AuthGate = ({ allowedRoles }: { allowedRoles: string[] }) => { const permissions = useAppSelector((state) => state.user.roles); + const userGroups = useAppSelector((state) => state.user.userDetail.groups); const location = useLocation(); const scopesMap: { [scope: string]: boolean } = {}; @@ -11,7 +13,8 @@ const AuthGate = ({ allowedRoles }: { allowedRoles: string[] }) => { scopesMap[scope] = true; }); - return permissions.some((permission) => scopesMap[permission]) ? ( + return permissions.some((permission) => scopesMap[permission]) || + userGroups?.includes('/' + USER_GROUP.TEAM_MEMBER.value) ? ( ) : ( diff --git a/met-web/src/services/userService/types.ts b/met-web/src/services/userService/types.ts index 3b83c51f2..b2bfde1b1 100644 --- a/met-web/src/services/userService/types.ts +++ b/met-web/src/services/userService/types.ts @@ -5,6 +5,7 @@ export interface UserDetail { email_verified?: boolean; preferred_username?: string; user?: User; + groups?: string[]; } export interface UserAuthentication {