Skip to content

Commit 624ff66

Browse files
committed
Fix duration logic on surge table
1 parent cc1ec33 commit 624ff66

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/views/EmergencySurge/SurgeTable/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,17 @@ export default function SurgeTable(props: Props) {
9595
'duration',
9696
strings.surgeAlertDuration,
9797
(item) => {
98-
if (isNotDefined(item.created_at) || isNotDefined(item.end)) {
98+
if (isNotDefined(item.start) || isNotDefined(item.end)) {
9999
return undefined;
100100
}
101101

102-
const alertDate = new Date(item.created_at);
102+
const alertDate = new Date(item.start);
103103
const deadline = new Date(item.end);
104+
105+
if (alertDate > deadline) {
106+
return undefined;
107+
}
108+
104109
const duration = getDuration(alertDate, deadline);
105110

106111
return duration;
@@ -117,11 +122,11 @@ export default function SurgeTable(props: Props) {
117122
const startDate = new Date(item.start);
118123
const nowMs = new Date().getTime();
119124

120-
const duration = startDate.getTime() < nowMs
125+
const start = startDate.getTime() < nowMs
121126
? strings.emergencySurgeImmediately
122127
: startDate.toLocaleString();
123128

124-
return duration;
129+
return start;
125130
},
126131
),
127132
createStringColumn<SurgeListItem, number>(

0 commit comments

Comments
 (0)