From 1847785dcb3bcc1d1a08c87415fa4dae79b8e3e8 Mon Sep 17 00:00:00 2001 From: hamed-musallam <35760236+hamed-musallam@users.noreply.github.com> Date: Fri, 3 Nov 2023 10:16:07 +0100 Subject: [PATCH] refactor: multiple spectra analysis modal (#2734) close #2732 --- .../elements/ReactTable/ReactTable.tsx | 2 +- .../modal/MultipletAnalysisModal.tsx | 202 +++++++++--------- 2 files changed, 107 insertions(+), 97 deletions(-) diff --git a/src/component/elements/ReactTable/ReactTable.tsx b/src/component/elements/ReactTable/ReactTable.tsx index 06497a1cd..4191514ae 100644 --- a/src/component/elements/ReactTable/ReactTable.tsx +++ b/src/component/elements/ReactTable/ReactTable.tsx @@ -235,7 +235,7 @@ const ReactTableInner = forwardRef(function ReactTableInner( const index = rowsData.at(-1)?.original[indexKey] || rowsData.at(-1)?.index; const total = totalCount ? totalCount : data.length; - const startColumn = columns[virtualBoundary.columns.start].Header; + const startColumn = columns[virtualBoundary.columns.start]?.Header; return ( <> diff --git a/src/component/modal/MultipletAnalysisModal.tsx b/src/component/modal/MultipletAnalysisModal.tsx index 35932c225..a072fa200 100644 --- a/src/component/modal/MultipletAnalysisModal.tsx +++ b/src/component/modal/MultipletAnalysisModal.tsx @@ -78,12 +78,15 @@ const loaderStyles = css` } `; -interface MultipletAnalysisModalProps { +interface InnerMultipleAnalysisProps { data: Spectrum[]; activeSpectrum: ActiveSpectrum | null; scaleX: any; startX: any; endX: any; +} + +interface MultipletAnalysisModalProps extends InnerMultipleAnalysisProps { isOpen: boolean; onClose: (element?: string) => void; } @@ -97,7 +100,31 @@ export default function MultipletAnalysisModal({ onClose, isOpen, }: MultipletAnalysisModalProps) { - const [analysisData, setAnalysisData] = useState(); + return ( + +
+ +
+ Analyse Multiplet +
+
+ + + +
+
+ ); +} + +function InnerMultipleAnalysis(props: InnerMultipleAnalysisProps) { const [calcStart, setCalcStartStatus] = useState(false); const [isCalcFinished, setCalcFinished] = useState(false); @@ -107,6 +134,9 @@ export default function MultipletAnalysisModal({ }, 400); }, []); + const { data, activeSpectrum, scaleX, startX, endX } = props; + const [analysisData, setAnalysisData] = useState(); + useEffect(() => { if (activeSpectrum && startX && endX && calcStart) { const spectrum = data[activeSpectrum.index]; @@ -153,104 +183,84 @@ export default function MultipletAnalysisModal({ if (!isCalcFinished) { return ( - -
- - - - - - -

Analyse Multiplet in progress. Please wait ...

-
-
+
+ + + + + + +

Analyse Multiplet in progress. Please wait ...

+
); } return ( - -
- -
- Analyse Multiplet -
-
- -
- {analysisData?.debug?.steps.map((d, index) => { - return ( - // eslint-disable-next-line react/no-array-index-key -
- - - - - -
-

- {analysisData.js[index] - ? `${analysisData.js[index] - ?.multiplicity}: ${analysisData.js[ - index - ]?.coupling.toFixed(3)} Hz` - : ''} -

-
- - - - - -
- ); - })} +
+ {analysisData?.debug?.steps.map((d, index) => { + return ( + // eslint-disable-next-line react/no-array-index-key +
+ + + + + +
+

+ {analysisData.js[index] + ? `${analysisData.js[index]?.multiplicity}: ${analysisData.js[ + index + ]?.coupling.toFixed(3)} Hz` + : ''} +

+
+ + + + +
- -
- + ); + })} +
); }