@@ -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 ) {
@@ -323,53 +339,43 @@ const TumourSummaryEdit = ({
323
339
return null ;
324
340
} , [ handleClicked , handleDelete , handleKeyDown , newMicrobialData ] ) ;
325
341
326
- const mutBurDataSection = useMemo ( ( ) => {
327
- if ( newMutationBurdenData ) {
328
- return (
329
- < TextField
330
- className = "tumour-dialog__text-field"
331
- label = "Mutation Burden (Mut/Mb)"
332
- value = { newMutationBurdenData . totalMutationsPerMb }
333
- name = "totalMutationsPerMb"
334
- onChange = { handleMutationBurdenChange }
335
- variant = "outlined"
336
- fullWidth
337
- type = "number"
338
- />
339
- ) ;
340
- }
341
- return null ;
342
- } , [ newMutationBurdenData , handleMutationBurdenChange ] ) ;
342
+ const mutBurDataSection = (
343
+ < TextField
344
+ className = "tumour-dialog__text-field"
345
+ label = "Mutation Burden (Mut/Mb)"
346
+ value = { newMutationBurdenData ?. totalMutationsPerMb ?? 0 }
347
+ name = "totalMutationsPerMb"
348
+ onChange = { handleMutationBurdenChange }
349
+ variant = "outlined"
350
+ fullWidth
351
+ type = "number"
352
+ />
353
+ ) ;
343
354
344
355
const tmburMutBurSection = useMemo ( ( ) => {
345
- if ( newTmburMutData ) {
346
- return (
347
- < >
348
- < TextField
349
- className = "tumour-dialog__text-field"
350
- label = "genomeSnvTmb"
351
- value = { newTmburMutData . genomeSnvTmb }
352
- name = "genomeSnvTmb"
353
- onChange = { handleTmburChange }
354
- variant = "outlined"
355
- fullWidth
356
- type = "number"
357
- />
358
- < TextField
359
- className = "tumour-dialog__text-field"
360
- label = "genomeIndelTmb"
361
- value = { newTmburMutData . genomeIndelTmb }
362
- name = "genomeIndelTmb"
363
- onChange = { handleTmburChange }
364
- variant = "outlined"
365
- fullWidth
366
- type = "number"
367
- />
368
- </ >
369
- ) ;
370
- }
371
- return null ;
372
- } , [ newTmburMutData , handleTmburChange ] ) ;
356
+ < >
357
+ < TextField
358
+ className = "tumour-dialog__text-field"
359
+ label = "genomeSnvTmb"
360
+ value = { newTmburMutData ?. genomeSnvTmb ?? 0 }
361
+ name = "genomeSnvTmb"
362
+ onChange = { handleTmburChange }
363
+ variant = "outlined"
364
+ fullWidth
365
+ type = "number"
366
+ />
367
+ < TextField
368
+ className = "tumour-dialog__text-field"
369
+ label = "genomeIndelTmb"
370
+ value = { newTmburMutData ?. genomeIndelTmb ?? 0 }
371
+ name = "genomeIndelTmb"
372
+ onChange = { handleTmburChange }
373
+ variant = "outlined"
374
+ fullWidth
375
+ type = "number"
376
+ />
377
+ </ > ;
378
+ } , [ newTmburMutData ?. genomeSnvTmb , newTmburMutData ?. genomeIndelTmb , handleTmburChange ] ) ;
373
379
374
380
return (
375
381
< Dialog open = { isOpen } >
0 commit comments