File tree Expand file tree Collapse file tree 3 files changed +35
-19
lines changed
EmergencySurge/SurgeTable Expand file tree Collapse file tree 3 files changed +35
-19
lines changed Original file line number Diff line number Diff line change 1717 "surgeAlertStatus" : " Status" ,
1818 "surgeAlertOpen" : " Open" ,
1919 "surgeAlertClosed" : " Closed" ,
20- "surgeAlertStoodDown" : " Stood down"
20+ "surgeAlertStoodDown" : " Stood down" ,
21+ "surgeAlertImmediately" : " Immediately"
2122 }
2223}
Original file line number Diff line number Diff line change @@ -192,18 +192,25 @@ export function Component() {
192192 'start' ,
193193 strings . surgeAlertStartDate ,
194194 ( item ) => {
195- if ( isNotDefined ( item . start ) ) {
196- return undefined ;
197- }
198-
199- const startDate = new Date ( item . start ) ;
195+ const startDate = isDefined ( item . start ) ? new Date ( item . start ) : undefined ;
196+ const endDate = isDefined ( item . end ) ? new Date ( item . end ) : undefined ;
200197 const nowMs = new Date ( ) . getTime ( ) ;
201198
202- const duration = startDate . getTime ( ) < nowMs
203- ? item . closes
204- : startDate . toLocaleString ( ) ;
199+ const closed = isDefined ( item . end )
200+ ? new Date ( item . end ) . getTime ( ) < today : undefined ;
205201
206- return duration ;
202+ if ( isDefined ( endDate ) && closed ) {
203+ return endDate . toLocaleString ( ) ;
204+ }
205+
206+ if ( isDefined ( startDate ) ) {
207+ const dateStarted = startDate . getTime ( ) < nowMs
208+ ? strings . surgeAlertImmediately
209+ : startDate . toLocaleString ( ) ;
210+
211+ return dateStarted ;
212+ }
213+ return undefined ;
207214 } ,
208215 ) ,
209216 createStringColumn < SurgeListItem , TableKey > (
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ export default function SurgeTable(props: Props) {
6565 preserveResponse : true ,
6666 query : {
6767 event : Number ( emergencyId ) ,
68+ is_active : true ,
6869 limit,
6970 offset,
7071
@@ -122,18 +123,25 @@ export default function SurgeTable(props: Props) {
122123 'start' ,
123124 strings . surgeAlertStartDate ,
124125 ( item ) => {
125- if ( isNotDefined ( item . start ) ) {
126- return undefined ;
127- }
128-
129- const startDate = new Date ( item . start ) ;
126+ const startDate = isDefined ( item . start ) ? new Date ( item . start ) : undefined ;
127+ const endDate = isDefined ( item . end ) ? new Date ( item . end ) : undefined ;
130128 const nowMs = new Date ( ) . getTime ( ) ;
131129
132- const start = startDate . getTime ( ) < nowMs
133- ? strings . emergencySurgeImmediately
134- : startDate . toLocaleString ( ) ;
130+ const closed = isDefined ( item . end )
131+ ? new Date ( item . end ) . getTime ( ) < today : undefined ;
135132
136- return start ;
133+ if ( isDefined ( endDate ) && closed ) {
134+ return endDate . toLocaleString ( ) ;
135+ }
136+
137+ if ( isDefined ( startDate ) ) {
138+ const dateStarted = startDate . getTime ( ) < nowMs
139+ ? strings . emergencySurgeImmediately
140+ : startDate . toLocaleString ( ) ;
141+
142+ return dateStarted ;
143+ }
144+ return undefined ;
137145 } ,
138146 ) ,
139147 createStringColumn < SurgeListItem , number > (
You can’t perform that action at this time.
0 commit comments