1- import {
2- Box ,
3- Typography ,
4- Card ,
5- CardContent ,
6- Stack ,
7- Chip ,
8- Grid ,
9- Link ,
10- } from "@mui/material" ;
1+ import { Typography , Card , CardContent , Stack , Chip } from "@mui/material" ;
112import { Colors } from "design/theme" ;
123import React from "react" ;
4+ import { Link } from "react-router-dom" ;
5+ import RoutesEnum from "types/routes.enum" ;
136
147interface SubjectCardProps {
158 dbname : string ;
@@ -35,19 +28,50 @@ const SubjectCard: React.FC<SubjectCardProps> = ({
3528 parsedJson,
3629} ) => {
3730 const { modalities, tasks, sessions, types } = parsedJson . value ;
31+ const subjectLink = `${ RoutesEnum . DATABASES } /${ dbname } /${ dsname } ` ;
32+
33+ // get the gender of subject
34+ const genderCode = parsedJson ?. key ?. [ 1 ] ;
35+ let genderDisplay = "Unknown" ;
36+
37+ if ( genderCode ) {
38+ if ( genderCode === "000F" ) genderDisplay = "Female" ;
39+ else if ( genderCode === "000M" ) genderDisplay = "Male" ;
40+ }
41+
42+ // cover age string to readable format
43+ let ageDisplay = "N/A" ;
44+
45+ if ( age ) {
46+ const ageNum = parseInt ( age , 10 ) / 100 ;
47+ if ( Number . isInteger ( ageNum ) ) {
48+ ageDisplay = `${ ageNum } years` ;
49+ } else {
50+ ageDisplay = `${ ageNum . toFixed ( 1 ) } years` ;
51+ }
52+ }
3853
3954 return (
4055 < Card sx = { { mb : 3 } } >
4156 < CardContent >
4257 < Typography
4358 variant = "h6"
44- sx = { { fontWeight : 600 , color : Colors . darkPurple } }
59+ sx = { {
60+ fontWeight : 600 ,
61+ color : Colors . darkPurple ,
62+ textDecoration : "none" ,
63+ ":hover" : { textDecoration : "underline" } ,
64+ } }
65+ component = { Link }
66+ to = { subjectLink }
67+ target = "_blank"
4568 >
4669 Database: { dbname } | Dataset Number: { dsname }
4770 </ Typography >
4871
4972 < Typography variant = "body2" color = "text.secondary" gutterBottom >
50- Subject: { subj } | Age: { age }
73+ Subject: { subj } | Age: { ageDisplay }
74+ | Gender: { genderDisplay }
5175 </ Typography >
5276
5377 < Stack spacing = { 2 } margin = { 1 } >
0 commit comments