From 0648f590affadea3333a079656126bed53b95351 Mon Sep 17 00:00:00 2001 From: John Phan Date: Thu, 19 Dec 2024 11:39:24 -0800 Subject: [PATCH] 35447 Changing the run item name throws an error - I was unable to replicate the error - Changing the run item name should be possible - Removing the run item name should also be possible now --- .../useMolecularAnalysisRun.tsx | 56 ++++++------------- .../useGenericMolecularAnalysisRun.tsx | 16 +++--- 2 files changed, 24 insertions(+), 48 deletions(-) diff --git a/packages/dina-ui/components/molecular-analysis/useMolecularAnalysisRun.tsx b/packages/dina-ui/components/molecular-analysis/useMolecularAnalysisRun.tsx index cb2802838..8085e9bd1 100644 --- a/packages/dina-ui/components/molecular-analysis/useMolecularAnalysisRun.tsx +++ b/packages/dina-ui/components/molecular-analysis/useMolecularAnalysisRun.tsx @@ -946,19 +946,7 @@ export function getMolecularAnalysisRunColumns( defaultValue={original.molecularAnalysisRunItem?.name} onChange={(event: ChangeEvent) => { setMolecularAnalysisRunItemNames?.( - (molecularAnalysisRunItemNames) => { - const molecularAnalysisRunItemNamesMap = - molecularAnalysisRunItemNames; - if ( - original?.materialSampleSummary?.id && - event.target.value - ) { - molecularAnalysisRunItemNamesMap[ - original?.materialSampleSummary?.id - ] = event.target.value; - } - return molecularAnalysisRunItemNamesMap; - } + handleMolecularAnalysisRunItemNames(original, event) ); }} /> @@ -1059,19 +1047,7 @@ export function getMolecularAnalysisRunColumns( defaultValue={original.molecularAnalysisRunItem?.name} onChange={(event: ChangeEvent) => { setMolecularAnalysisRunItemNames?.( - (molecularAnalysisRunItemNames) => { - const molecularAnalysisRunItemNamesMap = - molecularAnalysisRunItemNames; - if ( - original?.materialSampleSummary?.id && - event.target.value - ) { - molecularAnalysisRunItemNamesMap[ - original?.materialSampleSummary?.id - ] = event.target.value; - } - return molecularAnalysisRunItemNamesMap; - } + handleMolecularAnalysisRunItemNames(original, event) ); }} /> @@ -1172,19 +1148,7 @@ export function getMolecularAnalysisRunColumns( defaultValue={original.molecularAnalysisRunItem?.name} onChange={(event: ChangeEvent) => { setMolecularAnalysisRunItemNames?.( - (molecularAnalysisRunItemNames) => { - const molecularAnalysisRunItemNamesMap = - molecularAnalysisRunItemNames; - if ( - original?.materialSampleSummary?.id && - event.target.value - ) { - molecularAnalysisRunItemNamesMap[ - original?.materialSampleSummary?.id - ] = event.target.value; - } - return molecularAnalysisRunItemNamesMap; - } + handleMolecularAnalysisRunItemNames(original, event) ); }} /> @@ -1206,4 +1170,18 @@ export function getMolecularAnalysisRunColumns( "metagenomics-batch-item": METAGENOMICS_BATCH_ITEM_COLUMNS }; return MOLECULAR_ANALYSIS_RUN_COLUMNS_MAP[type]; + + function handleMolecularAnalysisRunItemNames( + original: SequencingRunItem, + event: ChangeEvent + ): SetStateAction> { + return (molecularAnalysisRunItemNames) => { + const molecularAnalysisRunItemNamesMap = molecularAnalysisRunItemNames; + if (original?.materialSampleSummary?.id) { + molecularAnalysisRunItemNamesMap[original?.materialSampleSummary?.id] = + event.target.value; + } + return molecularAnalysisRunItemNamesMap; + }; + } } diff --git a/packages/dina-ui/components/seqdb/molecular-analysis-workflow/useGenericMolecularAnalysisRun.tsx b/packages/dina-ui/components/seqdb/molecular-analysis-workflow/useGenericMolecularAnalysisRun.tsx index 71684bda0..58eaaa31c 100644 --- a/packages/dina-ui/components/seqdb/molecular-analysis-workflow/useGenericMolecularAnalysisRun.tsx +++ b/packages/dina-ui/components/seqdb/molecular-analysis-workflow/useGenericMolecularAnalysisRun.tsx @@ -715,16 +715,14 @@ export function useGenericMolecularAnalysisRun({ const molecularAnalysisRunItemName = item.materialSampleSummary?.id ? molecularAnalysisRunItemNames[item.materialSampleSummary?.id] : undefined; - if (molecularAnalysisRunItemName) { - molecularAnalysisRunItemSaveArgs.push({ + molecularAnalysisRunItemSaveArgs.push({ + type: "molecular-analysis-run-item", + resource: { + id: item.molecularAnalysisRunItemId, type: "molecular-analysis-run-item", - resource: { - id: item.molecularAnalysisRunItemId, - type: "molecular-analysis-run-item", - name: molecularAnalysisRunItemName - } - }); - } + name: molecularAnalysisRunItemName + } + }); }); if (molecularAnalysisRunItemSaveArgs.length) { await save(molecularAnalysisRunItemSaveArgs, {