@@ -7,18 +7,51 @@ interface ScheduledProps {
7
7
isEven : boolean
8
8
}
9
9
10
- const ScheduledComponent : React . FC < ScheduledProps > = ( { scheduled, isEven } ) => {
10
+ const ScheduledComponent : React . FC < ScheduledProps > = ( { scheduled, isEven} ) => {
11
11
const backgroundColor = isEven ? "#0a0a0a" : "#1a1a1a" ;
12
12
13
+ const isDelayed = ( ) => {
14
+ const planned = new Date ( scheduled . plannedWhen ) ;
15
+ const actual = new Date ( scheduled . actualWhen ) ;
16
+ return actual > planned ;
17
+ }
18
+
13
19
return (
14
- < div
15
- className = "p-4 rounded-md text-white hover:cursor-pointer"
16
- style = { { backgroundColor } }
20
+ < div className = "container mx-auto flex justify-between space-x-4 text-white text-base font-bold border-gray-400"
21
+ style = { { backgroundColor} }
17
22
>
18
- < p className = "font-semibold" > { scheduled . line . name } </ p >
19
- < p className = "text-sm" >
20
- Richtung: { scheduled . directionName } - Abfahrt: { scheduled . plannedWhen }
21
- </ p >
23
+ { /* First col */ }
24
+ < div className = { `flex-[1] text-right mr-8 border-t pt-2 space-y-4` } >
25
+ { /* Line */ }
26
+ < span className = { `${ scheduled . color ? 'p-2 rounded-md' : '' } ` }
27
+ style = { { backgroundColor : scheduled . color ?. backgroundColor || 'inherit' } }
28
+ >
29
+ { scheduled . line . name }
30
+ </ span >
31
+
32
+ { /* Departure time */ }
33
+ < div className = "flex flex-row items-center justify-end space-x-4 text-xl" >
34
+ < span className = { `${ isDelayed ( ) ? 'line-through text-red-500' : '' } ` } >
35
+ { new Date ( scheduled . plannedWhen ) . toLocaleTimeString ( [ ] , { hour : '2-digit' , minute : '2-digit' } ) }
36
+ </ span >
37
+ { isDelayed ( ) ? (
38
+ < span className = "bg-red-500 p-1" >
39
+ { new Date ( scheduled . actualWhen ) . toLocaleTimeString ( [ ] , { hour : '2-digit' , minute : '2-digit' } ) }
40
+ </ span >
41
+ ) : ( < > </ > ) }
42
+ </ div >
43
+ </ div >
44
+
45
+ { /* Second col */ }
46
+ < div className = "flex-[4] text-left border-t pt-4" >
47
+ < p > Über</ p >
48
+ < p > Ziel</ p >
49
+ </ div >
50
+
51
+ { /* Third col */ }
52
+ < div className = "flex-[1] flex justify-end items-end text-right border-t pt-4^" >
53
+ < p > Gleis</ p >
54
+ </ div >
22
55
</ div >
23
56
) ;
24
57
}
0 commit comments