Skip to content

Commit 4df3e27

Browse files
committed
fix: initialize status state with EventStatus type and ensure non-null value in event updates
1 parent 4654c1f commit 4df3e27

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/Components/Event/useEditForm.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function useEditForm(event: Models.IEvent) {
8181
return !err;
8282
}
8383

84-
const [status, _setStatus] = useState(event.Status);
84+
const [status, _setStatus] = useState<EventStatus>();
8585
const [valStatus, setValStatus] = useState<string>();
8686
function setStatus(value = status) {
8787
if (!value) {
@@ -170,7 +170,7 @@ export function useEditForm(event: Models.IEvent) {
170170

171171
const body: Record<string, any> = {
172172
title,
173-
status: GetStatusString(status),
173+
status: GetStatusString(status!),
174174
impact: GetEventImpact(type),
175175
message: update,
176176
update_date: updateAt.toISOString(),
@@ -216,15 +216,15 @@ export function useEditForm(event: Models.IEvent) {
216216
const updatedEvent = { ...DB.Events[eventIndex] };
217217
updatedEvent.Title = title;
218218
updatedEvent.Type = type;
219-
updatedEvent.Status = status;
219+
updatedEvent.Status = status!;
220220
updatedEvent.Start = start;
221221
updatedEvent.End = end;
222222

223223
const newHistory: Models.IHistory = {
224224
Id: Math.max(...Array.from(updatedEvent.Histories).map(h => h.Id), 0) + 1,
225225
Message: update,
226226
Created: updateAt,
227-
Status: status,
227+
Status: status!,
228228
Event: updatedEvent
229229
};
230230
updatedEvent.Histories.add(newHistory);

0 commit comments

Comments
 (0)