Skip to content

Commit e6d3466

Browse files
committed
feat: Move Assessment Statement into history
* Combine HistoryCard.tests into a single file * Add new tests for assessment statement * default expand first history item
1 parent 2703477 commit e6d3466

File tree

7 files changed

+335
-360
lines changed

7 files changed

+335
-360
lines changed

frontend/src/assets/locales/en/reports.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@
179179
"AssessedBy": "Assessed {{createDate}} by the director under the <i>Low Carbon Fuels Act.</i>",
180180
"Reassessed": "Re-assessed",
181181
"renewableTarget": "Renewable fuel target",
182-
"lowCarbonTarget": "Low carbon fuel target"
182+
"lowCarbonTarget": "Low carbon fuel target",
183+
"directorStatement": "Assessment statement from the director"
183184
},
184185
"internalComments": "Internal comments",
185186
"fuelLabels": {
@@ -202,8 +203,6 @@
202203
"reportAssessed": "Compliance report, Assessed",
203204
"changelog": "Change log",
204205
"documentLabel": "Add file attachments (maximum file size: 50 MB):",
205-
"assessmentStatement": "Assessment statement from the director",
206-
"assessmentStatementEdit": "(can be edited below)",
207206
"assessmentRecommendation": "Assessment recommendation",
208207
"directorStatement": "Director assessment statement to the organization (optional)",
209208
"assessmentStatementInstructions": "The analyst and/or compliance manager can draft an assessment statement to the organization. The director can edit or delete this statement. This is suggested when making analyst adjustments or reassessments.",

frontend/src/hooks/useCurrentUser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export const useCurrentUser = () => {
2121
onSuccess: setUser,
2222
onError: (error) => {
2323
console.error('Error fetching current user:', error)
24-
}
24+
},
25+
staleTime: 5 * (60 * 1000), // 5 mins
26+
cacheTime: 10 * (60 * 1000) // 10 mins
2527
})
2628

2729
/**

frontend/src/views/ComplianceReports/__tests__/HistoryCard.test.jsx

Lines changed: 0 additions & 238 deletions
This file was deleted.

frontend/src/views/ComplianceReports/components/AssessmentCard.jsx

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -134,39 +134,6 @@ export const AssessmentCard = ({
134134
setIsEditing={setIsEditing}
135135
/>
136136
)}
137-
{((!isGovernmentUser &&
138-
['Assessed', 'Reassessed', 'Rejected'].includes(
139-
reportData.report.currentStatus?.status
140-
)) ||
141-
isGovernmentUser) && (
142-
<>
143-
<BCTypography
144-
sx={{ paddingTop: '16px' }}
145-
component="div"
146-
variant="h6"
147-
color="primary"
148-
>
149-
{t('report:assessmentStatement')}
150-
{((hasRoles('Analyst') && currentStatus === 'Submitted') ||
151-
(hasRoles('Compliance Manager') &&
152-
currentStatus === 'Recommended by analyst') ||
153-
(hasRoles('Director') &&
154-
currentStatus === 'Recommended by manager')) && (
155-
<span style={{ color: 'red' }}>
156-
{' '}
157-
{t('report:assessmentStatementEdit')}
158-
</span>
159-
)}
160-
</BCTypography>
161-
<List sx={{ padding: 0 }}>
162-
<StyledListItem>
163-
<ListItemText primaryTypographyProps={{ variant: 'body4' }}>
164-
{reportData.report.assessmentStatement || 'N/A'}
165-
</ListItemText>
166-
</StyledListItem>
167-
</List>
168-
</>
169-
)}
170137
{filteredChain.length > 0 &&
171138
currentStatus !== COMPLIANCE_REPORT_STATUSES.DRAFT && (
172139
<>
@@ -178,8 +145,12 @@ export const AssessmentCard = ({
178145
>
179146
{t('report:reportHistory')}
180147
</BCTypography>
181-
{filteredChain.map((report) => (
182-
<HistoryCard key={report.version} report={report} />
148+
{filteredChain.map((report, index) => (
149+
<HistoryCard
150+
defaultExpanded={index === 0}
151+
key={report.version}
152+
report={report}
153+
/>
183154
))}
184155
</>
185156
)}

frontend/src/views/ComplianceReports/components/HistoryCard.jsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const AccordionDetails = styled(MuiAccordionDetails)(() => ({
4545
paddingBottom: 0
4646
}))
4747

48-
export const HistoryCard = ({ report }) => {
48+
export const HistoryCard = ({ report, defaultExpanded = false }) => {
4949
const { data: currentUser } = useCurrentUser()
5050
const isGovernmentUser = currentUser?.isGovernmentUser
5151
const { t } = useTranslation(['report'])
@@ -70,7 +70,7 @@ export const HistoryCard = ({ report }) => {
7070
}, [isGovernmentUser, report.history])
7171

7272
return (
73-
<Accordion>
73+
<Accordion defaultExpanded={defaultExpanded}>
7474
<AccordionSummary
7575
expandIcon={<ExpandMore sx={{ width: '2rem', height: '2rem' }} />}
7676
aria-controls="panel1-content"
@@ -107,9 +107,11 @@ export const HistoryCard = ({ report }) => {
107107
}}
108108
/>
109109
</ListItemText>
110-
{item.status.status === COMPLIANCE_REPORT_STATUSES.ASSESSED && (
110+
{[COMPLIANCE_REPORT_STATUSES.ASSESSED, 'AssessedBy'].includes(
111+
item.status.status
112+
) && (
111113
<List sx={{ p: 0, m: 0 }}>
112-
<StyledListItem key={index} disablePadding>
114+
<StyledListItem disablePadding>
113115
<ListItemText
114116
primaryTypographyProps={{ variant: 'body4' }}
115117
>
@@ -126,7 +128,7 @@ export const HistoryCard = ({ report }) => {
126128
})}
127129
</ListItemText>
128130
</StyledListItem>
129-
<StyledListItem key={index} disablePadding>
131+
<StyledListItem disablePadding>
130132
<ListItemText
131133
primaryTypographyProps={{ variant: 'body4' }}
132134
>
@@ -144,6 +146,21 @@ export const HistoryCard = ({ report }) => {
144146
})}
145147
</ListItemText>
146148
</StyledListItem>
149+
{report.assessmentStatement && (
150+
<StyledListItem disablePadding>
151+
<ListItemText
152+
primaryTypographyProps={{ variant: 'body4' }}
153+
>
154+
<strong>
155+
{t(
156+
'report:complianceReportHistory.directorStatement'
157+
)}
158+
:&nbsp;
159+
</strong>
160+
{report.assessmentStatement}
161+
</ListItemText>
162+
</StyledListItem>
163+
)}
147164
</List>
148165
)}
149166
</StyledListItem>

0 commit comments

Comments
 (0)