Skip to content

Commit

Permalink
[frontend] improve code
Browse files Browse the repository at this point in the history
Signed-off-by: Marine LM <[email protected]>
  • Loading branch information
MarineLeM committed Sep 26, 2024
1 parent fb52802 commit b094e4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const Exercise = () => {
{exercise.exercise_status !== 'SCHEDULED' && (
<Grid item xs={12} style={{ marginTop: 25 }}>
<Typography variant="h4" gutterBottom style={{ marginBottom: 15 }}>
{t('Injects Results')}
{t('Injects results')}
</Typography>
<Paper classes={{ root: classes.paper }} variant="outlined">
<InjectDtoList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ const ExerciseReportContent: React.FC<Props> = ({ report, exerciseId, canWrite =
const [loading, setLoading] = useState(true);
const globalObservationRef = useRef<string>(report?.report_global_observation ?? '');

const saveGlobalObservation = () => updateReportGlobalObservation(exerciseId, report.report_id, {
report_informations: report.report_informations,
report_global_observation: globalObservationRef.current,
report_name: report.report_name,
} as ReportInput);

const displayModule = (moduleType: ReportInformationType) => {
return report?.report_informations?.find((info: ReportInformation) => info.report_informations_type === moduleType)?.report_informations_display;
};
Expand Down Expand Up @@ -145,12 +151,7 @@ const ExerciseReportContent: React.FC<Props> = ({ report, exerciseId, canWrite =
globalObservationRef.current = value;
}}
style={{ height: 200, width: '100%' }}
onBlur={() => updateReportGlobalObservation(exerciseId, report.report_id, {
report_informations: report.report_informations,
report_global_observation: globalObservationRef.current,
report_name: report.report_name,
} as ReportInput)
}
onBlur={saveGlobalObservation}
/> : <Paper variant="outlined" sx={{ padding: '10px 15px 10px 15px' }}>
{globalObservationRef.current
? <div dangerouslySetInnerHTML={{ __html: globalObservationRef.current }}/>
Expand Down

0 comments on commit b094e4e

Please sign in to comment.