@@ -137,24 +137,26 @@ const TumourSummaryEdit = ({
137
137
138
138
if ( reportDirty && newReportData ) {
139
139
apiCalls . push ( api . put ( `/reports/${ report . ident } ` , newReportData , { } ) ) ;
140
- } else {
141
- apiCalls . push ( { request : ( ) => null } ) ;
142
140
}
143
141
144
142
if ( mutationBurdenDirty && newMutationBurdenData ) {
145
143
if ( mutationBurden ?. ident ) {
146
144
apiCalls . push ( api . put ( `/reports/${ report . ident } /mutation-burden/${ mutationBurden . ident } ` , newMutationBurdenData , { } ) ) ;
147
145
} else {
148
- apiCalls . push ( api . post ( `/reports/${ report . ident } /mutation-burden` , newMutationBurdenData , { } ) ) ;
146
+ apiCalls . push ( api . post (
147
+ `/reports/${ report . ident } /mutation-burden` ,
148
+ { ...newMutationBurdenData , role : 'primary' } ,
149
+ { } ,
150
+ ) ) ;
149
151
}
150
- } else {
151
- apiCalls . push ( { request : ( ) => null } ) ;
152
152
}
153
153
154
- if ( tmburMutDirty && newTmburMutData && tmburMutBur ?. ident ) {
155
- apiCalls . push ( api . put ( `/reports/${ report . ident } /tmbur-mutation-burden` , newTmburMutData , { } ) ) ;
156
- } else {
157
- apiCalls . push ( { request : ( ) => null } ) ;
154
+ if ( tmburMutDirty && newTmburMutData ) {
155
+ if ( tmburMutBur ?. ident ) {
156
+ apiCalls . push ( api . put ( `/reports/${ report . ident } /tmbur-mutation-burden` , newTmburMutData , { } ) ) ;
157
+ } else {
158
+ apiCalls . push ( api . post ( `/reports/${ report . ident } /tmbur-mutation-burden` , newTmburMutData , { } ) ) ;
159
+ }
158
160
}
159
161
160
162
callSet = new ApiCallSet ( apiCalls ) ;
@@ -164,19 +166,33 @@ const TumourSummaryEdit = ({
164
166
setIsApiCalling ( false ) ;
165
167
} else {
166
168
try {
167
- const resp = await callSet . request ( ) ;
168
- const tmburMutResp = resp . pop ( ) ;
169
- const primaryBurdenResp = resp . pop ( ) ;
170
- const reportResp = resp . pop ( ) ;
169
+ await callSet . request ( ) ;
170
+
171
+ let microbialResp = null ;
172
+ let tmburMutResp = null ;
173
+ let mutationBurdenResp = null ;
174
+ let reportResp = null ;
171
175
172
176
// Too complicated between delete/update/new, might as well grab updated micb species for report again
173
- const microbialResp = await api . get ( `/reports/${ report . ident } /summary/microbial` ) . request ( ) ;
177
+ if ( microbialDirty ) {
178
+ microbialResp = await api . get ( `/reports/${ report . ident } /summary/microbial` ) . request ( ) ;
179
+ }
180
+ if ( tmburMutDirty ) {
181
+ tmburMutResp = await api . get ( `/reports/${ report . ident } /tmbur-mutation-burden` ) . request ( ) ;
182
+ }
183
+ if ( mutationBurdenDirty ) {
184
+ mutationBurdenResp = await api . get ( `/reports/${ report . ident } /mutation-burden/` ) . request ( ) ;
185
+ }
186
+ if ( reportDirty ) {
187
+ reportResp = await api . get ( `/reports/${ report . ident } ` ) . request ( ) ;
188
+ }
189
+
174
190
snackbar . success ( 'Successfully updated Tumour Summary' ) ;
175
191
onClose (
176
192
true ,
177
193
microbialDirty ? microbialResp : null ,
178
194
reportDirty ? reportResp : null ,
179
- mutationBurdenDirty ? primaryBurdenResp : null ,
195
+ mutationBurdenDirty ? mutationBurdenResp . find ( ( mb ) => mb . role === 'primary' ) : null ,
180
196
tmburMutDirty ? tmburMutResp : null ,
181
197
) ;
182
198
} catch ( callSetError ) {
@@ -324,12 +340,12 @@ const TumourSummaryEdit = ({
324
340
} , [ handleClicked , handleDelete , handleKeyDown , newMicrobialData ] ) ;
325
341
326
342
const mutBurDataSection = useMemo ( ( ) => {
327
- if ( newMutationBurdenData ) {
343
+ if ( reportType === 'genomic' ) {
328
344
return (
329
345
< TextField
330
346
className = "tumour-dialog__text-field"
331
347
label = "Mutation Burden (Mut/Mb)"
332
- value = { newMutationBurdenData . totalMutationsPerMb }
348
+ value = { newMutationBurdenData ? .totalMutationsPerMb ?? 0 }
333
349
name = "totalMutationsPerMb"
334
350
onChange = { handleMutationBurdenChange }
335
351
variant = "outlined"
@@ -339,16 +355,16 @@ const TumourSummaryEdit = ({
339
355
) ;
340
356
}
341
357
return null ;
342
- } , [ newMutationBurdenData , handleMutationBurdenChange ] ) ;
358
+ } , [ newMutationBurdenData ?. totalMutationsPerMb , reportType , handleMutationBurdenChange ] ) ;
343
359
344
360
const tmburMutBurSection = useMemo ( ( ) => {
345
- if ( newTmburMutData ) {
361
+ if ( reportType === 'rapid' ) {
346
362
return (
347
363
< >
348
364
< TextField
349
365
className = "tumour-dialog__text-field"
350
366
label = "genomeSnvTmb"
351
- value = { newTmburMutData . genomeSnvTmb }
367
+ value = { newTmburMutData ? .genomeSnvTmb ?? 0 }
352
368
name = "genomeSnvTmb"
353
369
onChange = { handleTmburChange }
354
370
variant = "outlined"
@@ -358,7 +374,7 @@ const TumourSummaryEdit = ({
358
374
< TextField
359
375
className = "tumour-dialog__text-field"
360
376
label = "genomeIndelTmb"
361
- value = { newTmburMutData . genomeIndelTmb }
377
+ value = { newTmburMutData ? .genomeIndelTmb ?? 0 }
362
378
name = "genomeIndelTmb"
363
379
onChange = { handleTmburChange }
364
380
variant = "outlined"
@@ -369,7 +385,7 @@ const TumourSummaryEdit = ({
369
385
) ;
370
386
}
371
387
return null ;
372
- } , [ newTmburMutData , handleTmburChange ] ) ;
388
+ } , [ reportType , newTmburMutData ?. genomeSnvTmb , newTmburMutData ?. genomeIndelTmb , handleTmburChange ] ) ;
373
389
374
390
return (
375
391
< Dialog open = { isOpen } >
0 commit comments