@@ -19,19 +19,23 @@ import useConfirmDialog from '@/hooks/useConfirmDialog';
19
19
20
20
import './index.scss' ;
21
21
import { ReportType } from '@/context/ReportContext' ;
22
- import { MicrobialType , MutationBurdenType , TmburType } from '@/common' ;
22
+ import {
23
+ ImmuneType , MicrobialType , MutationBurdenType , TmburType ,
24
+ } from '@/common' ;
23
25
import snackbar from '@/services/SnackbarUtils' ;
24
26
25
27
type TumourSummaryEditProps = {
26
28
microbial : MicrobialType [ ] ;
27
29
report : ReportType ;
30
+ tCellCd8 : ImmuneType ;
28
31
mutationBurden : MutationBurdenType ;
29
- tmburMutBur ? : TmburType ;
32
+ tmburMutBur : TmburType ;
30
33
isOpen : boolean ;
31
34
onClose : (
32
35
isSaved : boolean ,
33
36
newMicrobialData ?: MicrobialType [ ] ,
34
37
newReportData ?: ReportType ,
38
+ newTCellCd8Data ?: ImmuneType ,
35
39
newMutationBurdenData ?: MutationBurdenType ,
36
40
newTmBurMutBurData ?: TmburType ,
37
41
) => void ;
@@ -43,6 +47,7 @@ const TumourSummaryEdit = ({
43
47
report : {
44
48
template : { name : reportType } ,
45
49
} ,
50
+ tCellCd8,
46
51
mutationBurden,
47
52
tmburMutBur,
48
53
isOpen,
@@ -53,10 +58,12 @@ const TumourSummaryEdit = ({
53
58
54
59
const [ newMicrobialData , setNewMicrobialData ] = useState ( cloneDeep ( microbial ) ) ;
55
60
const [ newReportData , setNewReportData ] = useState < Partial < ReportType > > ( null ) ;
61
+ const [ newTCellCd8Data , setNewTCellCd8Data ] = useState < Partial < ImmuneType > > ( null ) ;
56
62
const [ newMutationBurdenData , setNewMutationBurdenData ] = useState < Partial < MutationBurdenType > > ( null ) ;
57
63
const [ newTmburMutData , setNewTmburMutData ] = useState < Partial < TmburType > > ( null ) ;
58
64
const [ microbialDirty , setMicrobialDirty ] = useState ( false ) ;
59
65
const [ reportDirty , setReportDirty ] = useState ( false ) ;
66
+ const [ tCellCd8Dirty , setTCellCd8Dirty ] = useState ( false ) ;
60
67
const [ mutationBurdenDirty , setMutationBurdenDirty ] = useState ( false ) ;
61
68
const [ tmburMutDirty , setTmburMutDirty ] = useState ( false ) ;
62
69
const [ isApiCalling , setIsApiCalling ] = useState ( false ) ;
@@ -71,6 +78,15 @@ const TumourSummaryEdit = ({
71
78
}
72
79
} , [ report ] ) ;
73
80
81
+ useEffect ( ( ) => {
82
+ if ( tCellCd8 ) {
83
+ setNewTCellCd8Data ( {
84
+ score : tCellCd8 . score ,
85
+ percentile : tCellCd8 . percentile ,
86
+ } ) ;
87
+ }
88
+ } , [ tCellCd8 ] ) ;
89
+
74
90
useEffect ( ( ) => {
75
91
if ( mutationBurden ) {
76
92
setNewMutationBurdenData ( {
@@ -97,6 +113,12 @@ const TumourSummaryEdit = ({
97
113
setReportDirty ( true ) ;
98
114
} , [ ] ) ;
99
115
116
+ const handleTCellCd8Change = useCallback ( ( event : React . ChangeEvent < HTMLInputElement > ) => {
117
+ const { target : { value, name } } = event ;
118
+ setNewTCellCd8Data ( ( prevVal ) => ( { ...prevVal , [ name ] : value } ) ) ;
119
+ setTCellCd8Dirty ( true ) ;
120
+ } , [ ] ) ;
121
+
100
122
const handleMutationBurdenChange = useCallback ( ( event : React . ChangeEvent < HTMLInputElement > ) => {
101
123
const { target : { value, name } } = event ;
102
124
setNewMutationBurdenData ( ( prevVal ) => ( { ...prevVal , [ name ] : value } ) ) ;
@@ -142,6 +164,16 @@ const TumourSummaryEdit = ({
142
164
apiCalls . push ( api . put ( `/reports/${ report . ident } ` , newReportData , { } ) ) ;
143
165
}
144
166
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
+
145
177
if ( mutationBurdenDirty && newMutationBurdenData ) {
146
178
if ( mutationBurden ?. ident ) {
147
179
apiCalls . push ( api . put ( `/reports/${ report . ident } /mutation-burden/${ mutationBurden . ident } ` , newMutationBurdenData , { } ) ) ;
@@ -172,19 +204,22 @@ const TumourSummaryEdit = ({
172
204
await callSet . request ( ) ;
173
205
174
206
let microbialResp = null ;
207
+ let immuneResp = null ;
175
208
let tmburMutResp = null ;
176
209
let mutationBurdenResp = null ;
177
210
let reportResp = null ;
178
211
179
- // Too complicated between delete/update/new, might as well grab updated micb species for report again
180
212
if ( microbialDirty ) {
181
213
microbialResp = await api . get ( `/reports/${ report . ident } /summary/microbial` ) . request ( ) ;
182
214
}
215
+ if ( tCellCd8Dirty ) {
216
+ immuneResp = await api . get ( `/reports/${ report . ident } /immune-cell-types` ) . request ( ) ;
217
+ }
183
218
if ( tmburMutDirty ) {
184
219
tmburMutResp = await api . get ( `/reports/${ report . ident } /tmbur-mutation-burden` ) . request ( ) ;
185
220
}
186
221
if ( mutationBurdenDirty ) {
187
- mutationBurdenResp = await api . get ( `/reports/${ report . ident } /mutation-burden/ ` ) . request ( ) ;
222
+ mutationBurdenResp = await api . get ( `/reports/${ report . ident } /mutation-burden` ) . request ( ) ;
188
223
}
189
224
if ( reportDirty ) {
190
225
reportResp = await api . get ( `/reports/${ report . ident } ` ) . request ( ) ;
@@ -195,6 +230,7 @@ const TumourSummaryEdit = ({
195
230
true ,
196
231
microbialDirty ? microbialResp : null ,
197
232
reportDirty ? reportResp : null ,
233
+ tCellCd8Dirty ? immuneResp . find ( ( { cellType } ) => cellType === 'T cells CD8' ) : null ,
198
234
mutationBurdenDirty ? mutationBurdenResp . find ( ( mb ) => mb . role === 'primary' ) : null ,
199
235
tmburMutDirty ? tmburMutResp : null ,
200
236
) ;
@@ -213,6 +249,8 @@ const TumourSummaryEdit = ({
213
249
microbialDirty ,
214
250
reportDirty ,
215
251
newReportData ,
252
+ tCellCd8Dirty ,
253
+ newTCellCd8Data ,
216
254
mutationBurdenDirty ,
217
255
newMutationBurdenData ,
218
256
tmburMutDirty ,
@@ -221,6 +259,7 @@ const TumourSummaryEdit = ({
221
259
newMicrobialData ,
222
260
microbial ,
223
261
report ?. ident ,
262
+ tCellCd8 ?. ident ,
224
263
mutationBurden ?. ident ,
225
264
tmburMutBur ?. ident ,
226
265
showConfirmDialog ,
@@ -342,6 +381,31 @@ const TumourSummaryEdit = ({
342
381
return null ;
343
382
} , [ handleClicked , handleDelete , handleKeyDown , newMicrobialData ] ) ;
344
383
384
+ const tCellCd8DataSection = useMemo ( ( ) => (
385
+ < >
386
+ < TextField
387
+ className = "tumour-dialog__text-field"
388
+ label = "CD8+ T Cell Score"
389
+ value = { newTCellCd8Data ?. score ?? null }
390
+ name = "score"
391
+ onChange = { handleTCellCd8Change }
392
+ variant = "outlined"
393
+ fullWidth
394
+ type = "number"
395
+ />
396
+ < TextField
397
+ className = "tumour-dialog__text-field"
398
+ label = "CD8+ T Cell Percentile"
399
+ value = { newTCellCd8Data ?. percentile ?? null }
400
+ name = "percentile"
401
+ onChange = { handleTCellCd8Change }
402
+ variant = "outlined"
403
+ fullWidth
404
+ type = "number"
405
+ />
406
+ </ >
407
+ ) , [ newTCellCd8Data , handleTCellCd8Change ] ) ;
408
+
345
409
const mutBurDataSection = useMemo ( ( ) => (
346
410
< >
347
411
< TextField
@@ -377,7 +441,7 @@ const TumourSummaryEdit = ({
377
441
</ >
378
442
) , [ newMutationBurdenData , handleMutationBurdenChange ] ) ;
379
443
380
- const tmburMutBurSection = useMemo ( ( ) => {
444
+ const tmburMutBurSection = useMemo ( ( ) => (
381
445
< >
382
446
< TextField
383
447
className = "tumour-dialog__text-field"
@@ -399,8 +463,8 @@ const TumourSummaryEdit = ({
399
463
fullWidth
400
464
type = "number"
401
465
/>
402
- </ > ;
403
- } , [ newTmburMutData ?. genomeSnvTmb , newTmburMutData ?. genomeIndelTmb , handleTmburChange ] ) ;
466
+ </ >
467
+ ) , [ newTmburMutData ?. genomeSnvTmb , newTmburMutData ?. genomeIndelTmb , handleTmburChange ] ) ;
404
468
405
469
return (
406
470
< Dialog open = { isOpen } >
@@ -410,6 +474,7 @@ const TumourSummaryEdit = ({
410
474
< DialogContent className = "tumour-dialog__content" >
411
475
{ reportDataSection }
412
476
{ micbDataSection }
477
+ { tCellCd8DataSection }
413
478
{ mutBurDataSection }
414
479
{ tmburMutBurSection }
415
480
</ DialogContent >
0 commit comments