From b094e4e4d3fc270f37073838624fb964f72745fb Mon Sep 17 00:00:00 2001 From: Marine LM Date: Thu, 26 Sep 2024 17:41:18 +0200 Subject: [PATCH] [frontend] improve code Signed-off-by: Marine LM --- .../simulations/simulation/overview/Exercise.tsx | 2 +- .../simulation/reports/ExerciseReportContent.tsx | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/openbas-front/src/admin/components/simulations/simulation/overview/Exercise.tsx b/openbas-front/src/admin/components/simulations/simulation/overview/Exercise.tsx index c4e2680d70..648375a41b 100644 --- a/openbas-front/src/admin/components/simulations/simulation/overview/Exercise.tsx +++ b/openbas-front/src/admin/components/simulations/simulation/overview/Exercise.tsx @@ -102,7 +102,7 @@ const Exercise = () => { {exercise.exercise_status !== 'SCHEDULED' && ( - {t('Injects Results')} + {t('Injects results')} = ({ report, exerciseId, canWrite = const [loading, setLoading] = useState(true); const globalObservationRef = useRef(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; }; @@ -145,12 +151,7 @@ const ExerciseReportContent: React.FC = ({ 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} /> : {globalObservationRef.current ?