1
1
import { useTranslation } from 'next-i18next' ;
2
2
import { Button } from 'suomifi-ui-components' ;
3
3
import { List , ListItem } from './crosswalk-list.styles' ;
4
- import { Grid } from '@mui/material' ;
4
+ import { Grid , Table , TableBody , TableCell , TableContainer , TableHead , TableRow } from '@mui/material' ;
5
5
import router from 'next/router' ;
6
6
import { Crosswalk } from '@app/common/interfaces/crosswalk.interface' ;
7
+ import { getLanguageVersion } from '@app/common/utils/get-language-version' ;
7
8
8
9
export interface CrosswalkListProps {
9
10
items : Partial < Crosswalk > [ ] ;
@@ -13,90 +14,58 @@ export interface CrosswalkListProps {
13
14
}
14
15
15
16
export default function CrosswalkList ( {
16
- items,
17
- handleRemoval,
18
- deleteDisabled,
17
+ items
19
18
} : CrosswalkListProps ) {
20
19
const { t } = useTranslation ( 'admin' ) ;
21
20
22
21
if ( items && items . length < 1 ) {
22
+ items = [ ] ;
23
23
return < div > { 'There is no Crosswalks to show' } </ div > ;
24
24
}
25
25
26
26
function handleClick ( pid : string ) {
27
27
// will go the crosswalk detail page
28
- router . push ( ' /crosswalk' ) ;
28
+ router . push ( ` /crosswalk/ ${ pid } ` ) ;
29
29
}
30
30
31
31
return (
32
32
//Creating Header row
33
33
< div >
34
- < List className = "header-list" >
35
- < ListItem >
36
- < Grid container spacing = { 2 } style = { { fontWeight : 'bold' } } >
37
- < Grid item xs = { 2 } >
38
- { 'Name' }
39
- </ Grid >
40
- < Grid item xs = { 2 } >
41
- { 'Namespace' }
42
- </ Grid >
43
- < Grid item xs = { 2 } >
44
- { 'Status' }
45
- </ Grid >
46
- < Grid item xs = { 2 } >
47
- { 'Revision' }
48
- </ Grid >
49
- < Grid item xs = { 2 } >
50
- { 'PID' }
51
- </ Grid >
52
- < Grid item xs = { 2 } > </ Grid >
53
- </ Grid >
54
- </ ListItem >
55
- </ List >
56
- < List className = "inline-list" >
57
- { items &&
58
- items . map ( ( item ) => (
59
- < ListItem
60
- key = { item . pid }
61
- onClick = { ( ) => handleClick ( item . pid ) }
62
- onMouseEnter = { ( ) => item . onMouseEnter && item . onMouseEnter ( ) }
63
- onMouseLeave = { ( ) => item . onMouseLeave && item . onMouseLeave ( ) }
64
- onKeyDown = { ( e ) => e . key === 'Enter' && item . onClick ( ) }
65
- >
66
- < Grid container spacing = { 2 } >
67
- < Grid item xs = { 2 } >
68
- { item . label }
69
- </ Grid >
70
- < Grid item xs = { 2 } >
71
- { item . namespace }
72
- </ Grid >
73
- < Grid item xs = { 2 } >
74
- { item . status }
75
- </ Grid >
76
- < Grid item xs = { 2 } >
77
- { item . versionLabel }
78
- </ Grid >
79
- < Grid item xs = { 2 } >
80
- { item . pid }
81
- </ Grid >
82
- < Grid item xs = { 2 } >
83
- { Array . isArray ( deleteDisabled ) &&
84
- deleteDisabled . includes ( item . pid ) ? (
85
- < > </ >
86
- ) : (
87
- < Button
88
- variant = "secondaryNoBorder"
89
- icon = "remove"
90
- onClick = { ( ) => handleRemoval ( item . pid ) }
91
- >
92
- { t ( 'remove' ) }
93
- </ Button >
94
- ) }
95
- </ Grid >
96
- </ Grid >
97
- </ ListItem >
98
- ) ) }
99
- </ List >
34
+ < TableContainer >
35
+ < Table aria-label = { 'Schemas' } >
36
+ < TableHead >
37
+ < TableRow >
38
+ < TableCell > { 'Name' } </ TableCell >
39
+ < TableCell > { 'Namespace' } </ TableCell >
40
+ < TableCell > { 'Status' } </ TableCell >
41
+ < TableCell > { 'Revision' } </ TableCell >
42
+ < TableCell > { 'PID' } </ TableCell >
43
+ </ TableRow >
44
+ </ TableHead >
45
+ < TableBody >
46
+ { /*TODO: Use the below template to create lines for files*/ }
47
+ { items &&
48
+ items . map ( ( item ) => (
49
+ < TableRow
50
+ key = { item . pid }
51
+ hover = { true }
52
+ onClick = { ( ) => handleClick ( item . pid ) }
53
+ sx = { { cursor : 'pointer' } }
54
+ >
55
+ < TableCell >
56
+ { item . label ?. en }
57
+ { /*getLanguageVersion({ data: item.label, lang })*/ }
58
+ </ TableCell >
59
+ < TableCell > { item . namespace } </ TableCell >
60
+ < TableCell > { item . state } </ TableCell >
61
+ < TableCell > { item . versionLabel } </ TableCell >
62
+ < TableCell > { item . pid } </ TableCell >
63
+ </ TableRow >
64
+ ) ) }
65
+ </ TableBody >
66
+ </ Table >
67
+ </ TableContainer >
100
68
</ div >
69
+
101
70
) ;
102
71
}
0 commit comments