Skip to content

Commit 55d80db

Browse files
committed
DEVSU-2213 Jacky Review
The bugs occurring include: - tCellCd8 default values in the text fields not available - tCellCd8 ident not found even though it exists, making the handle does POST instead of PUT
1 parent 4985015 commit 55d80db

File tree

2 files changed

+100
-16
lines changed
  • app

2 files changed

+100
-16
lines changed

app/components/TumourSummaryEdit/index.tsx

+93-14
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ import useConfirmDialog from '@/hooks/useConfirmDialog';
1919

2020
import './index.scss';
2121
import { ReportType } from '@/context/ReportContext';
22-
import { MicrobialType, MutationBurdenType, TmburType } from '@/common';
22+
import { ImmuneType, MicrobialType, MutationBurdenType, TmburType } from '@/common';
2323
import snackbar from '@/services/SnackbarUtils';
2424

2525
type TumourSummaryEditProps = {
2626
microbial: MicrobialType[];
2727
report: ReportType;
28+
tCellCd8: ImmuneType;
2829
mutationBurden: MutationBurdenType;
29-
tmburMutBur?: TmburType;
30+
tmburMutBur: TmburType;
3031
isOpen: boolean;
3132
onClose: (
3233
isSaved: boolean,
3334
newMicrobialData?: MicrobialType[],
3435
newReportData?: ReportType,
36+
newTCellCd8Data?: ImmuneType,
3537
newMutationBurdenData?: MutationBurdenType,
3638
newTmBurMutBurData?: TmburType,
3739
) => void;
@@ -43,6 +45,7 @@ const TumourSummaryEdit = ({
4345
report: {
4446
template: { name: reportType },
4547
},
48+
tCellCd8,
4649
mutationBurden,
4750
tmburMutBur,
4851
isOpen,
@@ -53,10 +56,12 @@ const TumourSummaryEdit = ({
5356

5457
const [newMicrobialData, setNewMicrobialData] = useState(cloneDeep(microbial));
5558
const [newReportData, setNewReportData] = useState<Partial<ReportType>>(null);
59+
const [newTCellCd8Data, setNewTCellCd8Data] = useState<Partial<ImmuneType>>(null);
5660
const [newMutationBurdenData, setNewMutationBurdenData] = useState<Partial<MutationBurdenType>>(null);
5761
const [newTmburMutData, setNewTmburMutData] = useState<Partial<TmburType>>(null);
5862
const [microbialDirty, setMicrobialDirty] = useState(false);
5963
const [reportDirty, setReportDirty] = useState(false);
64+
const [tCellCd8Dirty, setTCellCd8Dirty] = useState(false);
6065
const [mutationBurdenDirty, setMutationBurdenDirty] = useState(false);
6166
const [tmburMutDirty, setTmburMutDirty] = useState(false);
6267
const [isApiCalling, setIsApiCalling] = useState(false);
@@ -71,6 +76,15 @@ const TumourSummaryEdit = ({
7176
}
7277
}, [report]);
7378

79+
useEffect(() => {
80+
if (tCellCd8) {
81+
setNewTCellCd8Data({
82+
score: tCellCd8.score,
83+
percentile: tCellCd8.percentile,
84+
});
85+
}
86+
}, [tCellCd8]);
87+
7488
useEffect(() => {
7589
if (mutationBurden) {
7690
setNewMutationBurdenData({
@@ -97,6 +111,12 @@ const TumourSummaryEdit = ({
97111
setReportDirty(true);
98112
}, []);
99113

114+
const handleTCellCd8Change = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
115+
const { target: { value, name } } = event;
116+
setNewTCellCd8Data((prevVal) => ({ ...prevVal, [name]: value }));
117+
setTCellCd8Dirty(true);
118+
}, []);
119+
100120
const handleMutationBurdenChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
101121
const { target: { value, name } } = event;
102122
setNewMutationBurdenData((prevVal) => ({ ...prevVal, [name]: value }));
@@ -144,6 +164,16 @@ const TumourSummaryEdit = ({
144164
apiCalls.push({ request: () => null });
145165
}
146166

167+
if (tCellCd8Dirty && newTCellCd8Data) {
168+
if (tCellCd8?.ident) {
169+
apiCalls.push(api.put(`/reports/${report.ident}/immune-cell-types/${tCellCd8.ident}`, newTCellCd8Data, {}));
170+
} else {
171+
apiCalls.push(api.post(`/reports/${report.ident}/immune-cell-types`, { ...newTCellCd8Data, cellType: 'T cells CD8' }, {}));
172+
}
173+
} else {
174+
apiCalls.push({ request: () => null });
175+
}
176+
147177
if (mutationBurdenDirty && newMutationBurdenData) {
148178
if (mutationBurden?.ident) {
149179
apiCalls.push(api.put(`/reports/${report.ident}/mutation-burden/${mutationBurden.ident}`, newMutationBurdenData, {}));
@@ -168,19 +198,37 @@ const TumourSummaryEdit = ({
168198
setIsApiCalling(false);
169199
} else {
170200
try {
171-
const resp = await callSet.request();
172-
const tmburMutResp = resp.pop();
173-
const primaryBurdenResp = resp.pop();
174-
const reportResp = resp.pop();
201+
await callSet.request();
202+
203+
let microbialResp = null;
204+
let immuneResp = null;
205+
let tmburMutResp = null;
206+
let mutationBurdenResp = null;
207+
let reportResp = null;
208+
209+
if (microbialDirty) {
210+
microbialResp = await api.get(`/reports/${report.ident}/summary/microbial`).request();
211+
}
212+
if (tCellCd8Dirty) {
213+
immuneResp = await api.get(`/reports/${report.ident}/immune-cell-types`).request();
214+
}
215+
if (tmburMutDirty) {
216+
tmburMutResp = await api.get(`/reports/${report.ident}/tmbur-mutation-burden`).request();
217+
}
218+
if (mutationBurdenDirty) {
219+
mutationBurdenResp = await api.get(`/reports/${report.ident}/mutation-burden`).request();
220+
}
221+
if (reportDirty) {
222+
reportResp = await api.get(`/reports/${report.ident}`).request();
223+
}
175224

176-
// Too complicated between delete/update/new, might as well grab updated micb species for report again
177-
const microbialResp = await api.get(`/reports/${report.ident}/summary/microbial`).request();
178225
snackbar.success('Successfully updated Tumour Summary');
179226
onClose(
180227
true,
181228
microbialDirty ? microbialResp : null,
229+
tCellCd8Dirty ? immuneResp.find(({cellType}) => cellType === 'T cells CD8') : null,
182230
reportDirty ? reportResp : null,
183-
mutationBurdenDirty ? primaryBurdenResp : null,
231+
mutationBurdenDirty ? mutationBurdenResp.find((mb) => mb.role === 'primary') : null,
184232
tmburMutDirty ? tmburMutResp : null,
185233
);
186234
} catch (callSetError) {
@@ -198,6 +246,8 @@ const TumourSummaryEdit = ({
198246
microbialDirty,
199247
reportDirty,
200248
newReportData,
249+
tCellCd8Dirty,
250+
newTCellCd8Data,
201251
mutationBurdenDirty,
202252
newMutationBurdenData,
203253
tmburMutDirty,
@@ -206,6 +256,7 @@ const TumourSummaryEdit = ({
206256
newMicrobialData,
207257
microbial,
208258
report?.ident,
259+
tCellCd8?.ident,
209260
mutationBurden?.ident,
210261
tmburMutBur?.ident,
211262
showConfirmDialog,
@@ -327,13 +378,40 @@ const TumourSummaryEdit = ({
327378
return null;
328379
}, [handleClicked, handleDelete, handleKeyDown, newMicrobialData]);
329380

381+
const tCellCd8DataSection = useMemo(() => {
382+
return (
383+
<>
384+
<TextField
385+
className="tumour-dialog__text-field"
386+
label="CD8+ T Cell Score"
387+
value={newTCellCd8Data?.score ?? 0}
388+
name="score"
389+
onChange={handleTCellCd8Change}
390+
variant="outlined"
391+
fullWidth
392+
type="number"
393+
/>
394+
<TextField
395+
className="tumour-dialog__text-field"
396+
label="CD8+ T Cell Percentile"
397+
value={newTCellCd8Data?.percentile ?? 0}
398+
name="percentile"
399+
onChange={handleTCellCd8Change}
400+
variant="outlined"
401+
fullWidth
402+
type="number"
403+
/>
404+
</>
405+
)
406+
}, [newTCellCd8Data, handleTCellCd8Change])
407+
330408
const mutBurDataSection = useMemo(() => {
331409
return (
332410
<>
333411
<TextField
334412
className="tumour-dialog__text-field"
335413
label="Mutation Burden (Mut/Mb)"
336-
value={newMutationBurdenData?.totalMutationsPerMb ?? null}
414+
value={newMutationBurdenData?.totalMutationsPerMb ?? 0}
337415
name="totalMutationsPerMb"
338416
onChange={handleMutationBurdenChange}
339417
variant="outlined"
@@ -343,7 +421,7 @@ const TumourSummaryEdit = ({
343421
<TextField
344422
className="tumour-dialog__text-field"
345423
label="SV Burden (POG average)"
346-
value={newMutationBurdenData?.qualitySvCount ?? null}
424+
value={newMutationBurdenData?.qualitySvCount ?? 0}
347425
name="qualitySvCount"
348426
onChange={handleMutationBurdenChange}
349427
variant="outlined"
@@ -353,7 +431,7 @@ const TumourSummaryEdit = ({
353431
<TextField
354432
className="tumour-dialog__text-field"
355433
label="SV Burden (Percentile)"
356-
value={newMutationBurdenData?.qualitySvPercentile ?? null}
434+
value={newMutationBurdenData?.qualitySvPercentile ?? 0}
357435
name="qualitySvPercentile"
358436
onChange={handleMutationBurdenChange}
359437
variant="outlined"
@@ -370,7 +448,7 @@ const TumourSummaryEdit = ({
370448
<TextField
371449
className="tumour-dialog__text-field"
372450
label="genomeSnvTmb"
373-
value={newTmburMutData?.genomeSnvTmb ?? null}
451+
value={newTmburMutData?.genomeSnvTmb ?? 0}
374452
name="genomeSnvTmb"
375453
onChange={handleTmburChange}
376454
variant="outlined"
@@ -380,7 +458,7 @@ const TumourSummaryEdit = ({
380458
<TextField
381459
className="tumour-dialog__text-field"
382460
label="genomeIndelTmb"
383-
value={newTmburMutData?.genomeIndelTmb ?? null}
461+
value={newTmburMutData?.genomeIndelTmb ?? 0}
384462
name="genomeIndelTmb"
385463
onChange={handleTmburChange}
386464
variant="outlined"
@@ -399,6 +477,7 @@ const TumourSummaryEdit = ({
399477
<DialogContent className="tumour-dialog__content">
400478
{reportDataSection}
401479
{micbDataSection}
480+
{tCellCd8DataSection}
402481
{mutBurDataSection}
403482
{tmburMutBurSection}
404483
</DialogContent>

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const GenomicSummary = ({
164164

165165
setPrimaryComparator(comparatorsResp.find(({ analysisRole }) => analysisRole === 'mutation burden (primary)'));
166166
setPrimaryBurden(burdenResp.find((entry: Record<string, unknown>) => entry.role === 'primary'));
167-
setTCellCd8(immuneResp.find(({ cellType }) => cellType === 'T cells CD8'));
167+
setTCellCd8(immuneResp.find(({cellType}) => cellType === 'T cells CD8'));
168168
setSignatures(signaturesResp);
169169

170170
if (microbialResp.length) {
@@ -445,12 +445,13 @@ const GenomicSummary = ({
445445
isSaved: boolean,
446446
newMicrobialData: MicrobialType[],
447447
newReportData: ReportType,
448+
newTCellCd8Data: ImmuneType,
448449
newMutationBurdenData: MutationBurdenType,
449450
newTmBurMutBurData: TmburType,
450451
) => {
451452
setShowTumourSummaryEdit(false);
452453

453-
if (!isSaved || (!newMicrobialData && !newReportData && !newMutationBurdenData && !newTmBurMutBurData)) {
454+
if (!isSaved || (!newMicrobialData && !newReportData && !newTCellCd8Data && !newMutationBurdenData && !newTmBurMutBurData)) {
454455
return;
455456
}
456457

@@ -462,6 +463,10 @@ const GenomicSummary = ({
462463
setReport(newReportData);
463464
}
464465

466+
if (newTCellCd8Data) {
467+
setTCellCd8(newTCellCd8Data)
468+
}
469+
465470
if (newMutationBurdenData) {
466471
setPrimaryBurden(newMutationBurdenData);
467472
}

0 commit comments

Comments
 (0)