@@ -22,6 +22,7 @@ type TableProps = {
2222 tableValues : TableValues [ ]
2323 questionTitles : TableValues
2424 isOutdated : any
25+ entries : any [ ]
2526}
2627
2728const additionalColumnNames : TableValues = {
@@ -32,8 +33,13 @@ const additionalColumnNames: TableValues = {
3233 unit : 'Yksikkö' ,
3334}
3435
35- const Table = ( { tableValues, questionTitles, isOutdated } : TableProps ) => {
36+ const Table = ( { tableValues, questionTitles, isOutdated, entries } : TableProps ) => {
3637 const deleteMutation = useDeleteEntryMutation ( )
38+
39+ const isTestVersion = ( id : string ) => {
40+ return entries . find ( e => e . id === Number ( id ) ) ?. testVersion || false
41+ }
42+
3743 const columns = useMemo < MRT_ColumnDef < TableValues > [ ] > ( ( ) => {
3844 const outdatedWarning = { paddingRight : 10 , color : 'red' , fontSize : 'x-large' }
3945 return tableValues . length
@@ -54,10 +60,18 @@ const Table = ({ tableValues, questionTitles, isOutdated }: TableProps) => {
5460 } ) }
5561 >
5662 { columnId === '3' ? (
57- < >
63+ < Box >
5864 { isOutdated ( row . getValue ( 'id' ) ) && < span style = { outdatedWarning } > !</ span > }
5965 < Link to = { `/admin/entry/${ row . getValue ( 'id' ) } ` } > { cell . getValue < string > ( ) } </ Link >
60- </ >
66+ { isTestVersion ( row . getValue ( 'id' ) ) && (
67+ < Box
68+ component = "div"
69+ sx = { { color : 'red' , fontWeight : 'bold' , fontSize : '0.75rem' , marginTop : '4px' } }
70+ >
71+ TEST VERSION
72+ </ Box >
73+ ) }
74+ </ Box >
6175 ) : (
6276 cell . getValue < number > ( )
6377 ) }
@@ -106,7 +120,12 @@ const Table = ({ tableValues, questionTitles, isOutdated }: TableProps) => {
106120 enableColumnOrdering : true ,
107121 enableGlobalFilter : false ,
108122 enableRowActions : true ,
109- muiTableBodyRowProps : { hover : false } ,
123+ muiTableBodyRowProps : ( { row } ) => ( {
124+ hover : false ,
125+ sx : {
126+ backgroundColor : isTestVersion ( row . original . id ) ? '#fffef5' : 'inherit' ,
127+ } ,
128+ } ) ,
110129 muiTableBodyCellProps : {
111130 sx : {
112131 border : '1px solid rgba(81, 81, 81, .5)' ,
@@ -208,7 +227,12 @@ const Summary = () => {
208227 px : 8 ,
209228 } }
210229 >
211- < Table tableValues = { tableData } questionTitles = { questionTitles } isOutdated = { isOutdated } />
230+ < Table
231+ tableValues = { tableData }
232+ questionTitles = { questionTitles }
233+ isOutdated = { isOutdated }
234+ entries = { entriesWithData }
235+ />
212236 </ Box >
213237 </ >
214238 )
0 commit comments