Skip to content

Commit 165244d

Browse files
authored
Merge pull request #416 from bcgsc/bugfix/DEVSU-2148-tumoursummary-fixes
[DEVSU-2148] tumour summary fixes
2 parents 3558695 + f648518 commit 165244d

File tree

3 files changed

+70
-65
lines changed

3 files changed

+70
-65
lines changed

app/components/TumourSummaryEdit/index.tsx

+66-60
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,26 @@ const TumourSummaryEdit = ({
137137

138138
if (reportDirty && newReportData) {
139139
apiCalls.push(api.put(`/reports/${report.ident}`, newReportData, {}));
140-
} else {
141-
apiCalls.push({ request: () => null });
142140
}
143141

144142
if (mutationBurdenDirty && newMutationBurdenData) {
145143
if (mutationBurden?.ident) {
146144
apiCalls.push(api.put(`/reports/${report.ident}/mutation-burden/${mutationBurden.ident}`, newMutationBurdenData, {}));
147145
} 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+
));
149151
}
150-
} else {
151-
apiCalls.push({ request: () => null });
152152
}
153153

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+
}
158160
}
159161

160162
callSet = new ApiCallSet(apiCalls);
@@ -164,19 +166,33 @@ const TumourSummaryEdit = ({
164166
setIsApiCalling(false);
165167
} else {
166168
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;
171175

172176
// 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+
174190
snackbar.success('Successfully updated Tumour Summary');
175191
onClose(
176192
true,
177193
microbialDirty ? microbialResp : null,
178194
reportDirty ? reportResp : null,
179-
mutationBurdenDirty ? primaryBurdenResp : null,
195+
mutationBurdenDirty ? mutationBurdenResp.find((mb) => mb.role === 'primary') : null,
180196
tmburMutDirty ? tmburMutResp : null,
181197
);
182198
} catch (callSetError) {
@@ -323,53 +339,43 @@ const TumourSummaryEdit = ({
323339
return null;
324340
}, [handleClicked, handleDelete, handleKeyDown, newMicrobialData]);
325341

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+
);
343354

344355
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]);
373379

374380
return (
375381
<Dialog open={isOpen}>

app/hooks/useConfirmDialog.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import AlertDialog from '@/components/AlertDialog';
22
import ReportContext from '@/context/ReportContext';
3-
import api from '@/services/api';
43
import React, { useCallback, useContext } from 'react';
54
import ReactDOM from 'react-dom';
65
import snackbar from '@/services/SnackbarUtils';

app/views/ReportView/components/GenomicSummary/index.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,12 @@ const GenomicSummary = ({
444444
isSaved: boolean,
445445
newMicrobialData: MicrobialType[],
446446
newReportData: ReportType,
447-
newMutationBurdenData: MutationBurdenType,
447+
newPrimaryBurdenData: MutationBurdenType,
448448
newTmBurMutBurData: TmburType,
449449
) => {
450450
setShowTumourSummaryEdit(false);
451451

452-
if (!isSaved || (!newMicrobialData && !newReportData && !newMutationBurdenData && !newTmBurMutBurData)) {
452+
if (!isSaved || (!newMicrobialData && !newReportData && !newPrimaryBurdenData && !newTmBurMutBurData)) {
453453
return;
454454
}
455455

@@ -461,8 +461,8 @@ const GenomicSummary = ({
461461
setReport(newReportData);
462462
}
463463

464-
if (newMutationBurdenData) {
465-
setPrimaryBurden(newMutationBurdenData);
464+
if (newPrimaryBurdenData) {
465+
setPrimaryBurden(newPrimaryBurdenData);
466466
}
467467

468468
if (newTmBurMutBurData) {

0 commit comments

Comments
 (0)