diff --git a/frontend/src/views/ComplianceReports/EditViewComplianceReport.jsx b/frontend/src/views/ComplianceReports/EditViewComplianceReport.jsx
index f5129eb4f..afebb1cb9 100644
--- a/frontend/src/views/ComplianceReports/EditViewComplianceReport.jsx
+++ b/frontend/src/views/ComplianceReports/EditViewComplianceReport.jsx
@@ -90,8 +90,7 @@ export const EditViewComplianceReport = ({ reportData, isError, error }) => {
hasRoles
} = useCurrentUser()
const isGovernmentUser = currentUser?.isGovernmentUser
- const isAnalystRole =
- currentUser?.roles?.some((role) => role.name === roles.analyst) || false
+ const userRoles = currentUser?.roles
const currentStatus = reportData?.report.currentStatus?.status
const { data: orgData, isLoading } = useOrganization(
@@ -228,7 +227,7 @@ export const EditViewComplianceReport = ({ reportData, isError, error }) => {
<>
{
+const ReportDetails = ({ currentStatus = 'Draft', userRoles }) => {
const { t } = useTranslation()
const { compliancePeriod, complianceReportId } = useParams()
const navigate = useNavigate()
const [isFileDialogOpen, setFileDialogOpen] = useState(false)
+ const isAnalystRole = userRoles.some(role => role.name === roles.analyst) || false;
+ const isSupplierRole = userRoles.some(role => role.name === roles.supplier) || false;
+
const editSupportingDocs = useMemo(() => {
return isAnalystRole && (
currentStatus === COMPLIANCE_REPORT_STATUSES.SUBMITTED ||
currentStatus === COMPLIANCE_REPORT_STATUSES.ASSESSED
- ) || currentStatus === COMPLIANCE_REPORT_STATUSES.DRAFT;
+ )
+ }, [isAnalystRole, currentStatus]);
+
+ const editAnalyst = useMemo(() => {
+ return isAnalystRole && (
+ currentStatus === COMPLIANCE_REPORT_STATUSES.REASSESSED
+ )
}, [isAnalystRole, currentStatus]);
+ const editSupplier = useMemo(() => {
+ return isSupplierRole && (
+ currentStatus === COMPLIANCE_REPORT_STATUSES.DRAFT
+ )
+ }, [isSupplierRole, currentStatus]);
+
+ const shouldShowEditIcon = (activityName) => {
+ if (activityName === t('report:supportingDocs')) {
+ return editSupportingDocs;
+ }
+ return editAnalyst || editSupplier;
+ };
+
const isArrayEmpty = useCallback((data) => {
if (Array.isArray(data)) {
return data.length === 0
@@ -260,13 +282,12 @@ const ReportDetails = ({ currentStatus = 'Draft', isAnalystRole }) => {
component="div"
>
{activity.name}
- {editSupportingDocs && (
+ {shouldShowEditIcon(activity.name) && (
<>