Skip to content

Commit f5b3612

Browse files
authored
Merge pull request #645 from bcgsc/develop
add work to release
2 parents 914513d + 270b67d commit f5b3612

File tree

8 files changed

+263
-166
lines changed

8 files changed

+263
-166
lines changed

app/components/TumourSummaryEdit/index.tsx

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import useConfirmDialog from '@/hooks/useConfirmDialog';
2424
import './index.scss';
2525
import { ReportType } from '@/context/ReportContext';
2626
import {
27-
ImmuneType, MicrobialType, MutationBurdenType, TmburType,
27+
ImmuneType, MicrobialType, MsiType, MutationBurdenType, TmburType,
2828
} from '@/common';
2929
import snackbar from '@/services/SnackbarUtils';
3030
import { getMicbSiteIntegrationStatusLabel } from '@/utils/getMicbSiteIntegrationStatusLabel';
@@ -41,6 +41,7 @@ type TumourSummaryEditProps = {
4141
tCellCd8: ImmuneType;
4242
mutationBurden: MutationBurdenType;
4343
tmburMutBur: TmburType;
44+
msi?: MsiType;
4445
isOpen: boolean;
4546
onEditClose: (
4647
isSaved: boolean,
@@ -49,6 +50,7 @@ type TumourSummaryEditProps = {
4950
newTCellCd8Data?: ImmuneType,
5051
newMutationBurdenData?: MutationBurdenType,
5152
newTmBurMutBurData?: TmburType,
53+
newMsiData?: MsiType,
5254
) => void;
5355
};
5456

@@ -61,6 +63,7 @@ const TumourSummaryEdit = ({
6163
tCellCd8,
6264
mutationBurden,
6365
tmburMutBur,
66+
msi,
6467
isOpen,
6568
onEditClose,
6669
}: TumourSummaryEditProps): JSX.Element => {
@@ -72,11 +75,13 @@ const TumourSummaryEdit = ({
7275
const [newTCellCd8Data, setNewTCellCd8Data] = useState<Partial<ImmuneType>>(null);
7376
const [newMutationBurdenData, setNewMutationBurdenData] = useState<Partial<MutationBurdenType>>(null);
7477
const [newTmburMutData, setNewTmburMutData] = useState<Partial<TmburType>>(null);
78+
const [newMsiData, setNewMsiData] = useState<Partial<MsiType>>(null);
7579
const [microbialDirty, setMicrobialDirty] = useState(false);
7680
const [reportDirty, setReportDirty] = useState(false);
7781
const [tCellCd8Dirty, setTCellCd8Dirty] = useState(false);
7882
const [mutationBurdenDirty, setMutationBurdenDirty] = useState(false);
7983
const [tmburMutDirty, setTmburMutDirty] = useState(false);
84+
const [msiDirty, setMsiDirty] = useState(false);
8085
const [isApiCalling, setIsApiCalling] = useState(false);
8186

8287
useEffect(() => {
@@ -129,10 +134,19 @@ const TumourSummaryEdit = ({
129134
adjustedTmb: tmburMutBur.adjustedTmb,
130135
adjustedTmbComment: tmburMutBur.adjustedTmbComment,
131136
tmbHidden: tmburMutBur.tmbHidden,
137+
msiScore: tmburMutBur.msiScore,
132138
});
133139
}
134140
}, [tmburMutBur]);
135141

142+
useEffect(() => {
143+
if (msi) {
144+
setNewMsiData({
145+
score: msi.score,
146+
});
147+
}
148+
}, [msi]);
149+
136150
const handleReportChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
137151
const { target: { value, name } } = event;
138152
setNewReportData((prevVal) => ({ ...prevVal, [name]: value }));
@@ -189,6 +203,16 @@ const TumourSummaryEdit = ({
189203
setTmburMutDirty(true);
190204
}, []);
191205

206+
const handleMsiScoreChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
207+
const { target: { value, name } } = event;
208+
setNewMsiData((prevVal) => ({ ...prevVal, [name]: value }));
209+
if (msi) {
210+
setMsiDirty(true);
211+
} else if (tmburMutBur) {
212+
setTmburMutDirty(true);
213+
}
214+
}, []);
215+
192216
const handleAdjustedTmbCommentChange = useCallback(({ target: { value, name } }) => {
193217
setNewTmburMutData((tmb) => ({
194218
...tmb,
@@ -291,6 +315,14 @@ const TumourSummaryEdit = ({
291315
}
292316
}
293317

318+
if (msiDirty && newMsiData) {
319+
if (msi?.ident) {
320+
apiCalls.push(api.put(`/reports/${report.ident}/msi/${msi.ident}`, newMsiData, {}));
321+
} else {
322+
apiCalls.push(api.post(`/reports/${report.ident}/msi`, newMsiData, {}));
323+
}
324+
}
325+
294326
callSet = new ApiCallSet(apiCalls);
295327

296328
if (isSigned) {
@@ -303,6 +335,7 @@ const TumourSummaryEdit = ({
303335
let microbialResp = null;
304336
let immuneResp = null;
305337
let tmburMutResp = null;
338+
let msiResp = null;
306339
let mutationBurdenResp = null;
307340
let reportResp = null;
308341

@@ -315,6 +348,9 @@ const TumourSummaryEdit = ({
315348
if (tmburMutDirty) {
316349
tmburMutResp = await api.get(`/reports/${report.ident}/tmbur-mutation-burden`).request();
317350
}
351+
if (msiDirty) {
352+
msiResp = await api.get(`/reports/${report.ident}/msi`).request();
353+
}
318354
if (mutationBurdenDirty) {
319355
mutationBurdenResp = await api.get(`/reports/${report.ident}/mutation-burden`).request();
320356
}
@@ -330,6 +366,7 @@ const TumourSummaryEdit = ({
330366
tCellCd8Dirty ? immuneResp.find(({ cellType }) => cellType === 'T cells CD8') : null,
331367
mutationBurdenDirty ? mutationBurdenResp.find((mb) => mb.role === 'primary') : null,
332368
tmburMutDirty ? tmburMutResp : null,
369+
msiDirty ? msiResp : null,
333370
);
334371
} catch (callSetError) {
335372
snackbar.error(`Error updating Tumour Summary: ${callSetError?.message}`);
@@ -351,13 +388,16 @@ const TumourSummaryEdit = ({
351388
newMutationBurdenData,
352389
tmburMutDirty,
353390
newTmburMutData,
391+
msiDirty,
392+
newMsiData,
354393
isSigned,
355394
newMicrobialData,
356395
microbial,
357396
report?.ident,
358397
tCellCd8?.ident,
359398
mutationBurden?.ident,
360399
tmburMutBur?.ident,
400+
msi?.ident,
361401
showConfirmDialog,
362402
onEditClose,
363403
]);
@@ -732,6 +772,39 @@ const TumourSummaryEdit = ({
732772
handleAdjustedTmbVisibleChange,
733773
]);
734774

775+
const msiSection = useMemo(() => (
776+
<>
777+
{msi &&
778+
<TextField
779+
className="tumour-dialog__number-field"
780+
label="MSI Score"
781+
value={newMsiData?.score ?? null}
782+
name="score"
783+
onChange={handleMsiScoreChange}
784+
variant="outlined"
785+
fullWidth
786+
type="number"
787+
/>
788+
}
789+
{!msi && tmburMutBur &&
790+
<TextField
791+
className="tumour-dialog__number-field"
792+
label="MSI Score"
793+
value={newTmburMutData?.msiScore ?? null}
794+
name="msiScore"
795+
onChange={handleMsiScoreChange}
796+
variant="outlined"
797+
fullWidth
798+
type="number"
799+
/>
800+
}
801+
</>
802+
), [
803+
newMsiData?.score,
804+
newTmburMutData?.msiScore,
805+
handleMsiScoreChange,
806+
]);
807+
735808
return (
736809
<Dialog open={isOpen}>
737810
<DialogTitle>
@@ -743,6 +816,7 @@ const TumourSummaryEdit = ({
743816
{tCellCd8DataSection}
744817
{mutBurDataSection}
745818
{tmburMutBurSection}
819+
{msiSection}
746820
</DialogContent>
747821
<DialogActions>
748822
<Button onClick={() => handleClose(false)}>

app/utils/getMostCurrentObj.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function getMostCurrentObj(array) {
2+
let mostRecentObject = array[0];
3+
for (let i = 1; i < array.length; i++) {
4+
if (new Date(array[i].createdAt) > new Date(mostRecentObject.createdAt)) {
5+
mostRecentObject = array[i];
6+
}
7+
}
8+
return mostRecentObject;
9+
}
10+
11+
export default getMostCurrentObj;

app/views/AdminView/components/Users/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import snackbar from '@/services/SnackbarUtils';
1010
import { ErrorMixin } from '@/services/errors/errors';
1111
import columnDefs from './columnDefs';
1212
import AddEditUserDialog from './components/AddEditUserDialog';
13-
1413
import './index.scss';
1514

1615
const fetchUsers = async () => {
@@ -46,7 +45,7 @@ const Users = (): JSX.Element => {
4645
const handleDelete = useCallback((rowData) => {
4746
if (rowData.ident) {
4847
// TODO: Add an actual dialog whenever time allows
49-
// eslint-disable-next-line no-restricted-globals
48+
// eslint-disable-next-line no-restricted-globals, no-alert
5049
if (confirm(`Are you sure you want to remove this user (${rowData.username})?`)) {
5150
deleteUserMutation.mutate(rowData.ident);
5251
} else {

0 commit comments

Comments
 (0)