@@ -23,7 +23,7 @@ import { EventStatus, EventType, GetEventImpact, GetStatusString, IsIncident, Is
2323 *
2424 * @author Aloento
2525 * @since 1.0.0
26- * @version 0.2.0
26+ * @version 0.2.1
2727 */
2828export function useEditForm ( event : Models . IEvent ) {
2929 const [ title , _setTitle ] = useState ( event . Title ) ;
@@ -60,12 +60,8 @@ export function useEditForm(event: Models.IEvent) {
6060 return false ;
6161 }
6262
63- if ( ! IsIncident ( type ) && IsIncident ( value ) ) {
64- _setStatus ( EventStatus . Analysing ) ;
65- }
66-
67- if ( IsIncident ( type ) && ! IsIncident ( value ) ) {
68- _setStatus ( EventStatus . Planned ) ;
63+ if ( type !== value ) {
64+ _setStatus ( undefined ) ;
6965 }
7066
7167 _setType ( value ) ;
@@ -95,7 +91,7 @@ export function useEditForm(event: Models.IEvent) {
9591 return ! err ;
9692 }
9793
98- const [ status , _setStatus ] = useState ( event . Status ) ;
94+ const [ status , _setStatus ] = useState < EventStatus | undefined > ( ) ;
9995 const [ valStatus , setValStatus ] = useState < string > ( ) ;
10096 function setStatus ( value = status ) {
10197 if ( ! value ) {
@@ -179,12 +175,11 @@ export function useEditForm(event: Models.IEvent) {
179175 if ( ! [ setTitle ( ) , setType ( ) , setUpdate ( ) , setStatus ( ) , setStart ( ) , setEnd ( ) , setUpdateAt ( ) ] . every ( Boolean ) ) {
180176 throw new Error ( "Validation failed." ) ;
181177 }
182-
183178 const url = process . env . SD_BACKEND_URL ! ;
184179
185180 const body : Record < string , any > = {
186181 title,
187- status : GetStatusString ( status ) ,
182+ status : GetStatusString ( status ! ) ,
188183 impact : GetEventImpact ( type ) ,
189184 message : update ,
190185 update_date : updateAt . toISOString ( ) ,
@@ -230,15 +225,15 @@ export function useEditForm(event: Models.IEvent) {
230225 const updatedEvent = { ...DB . Events [ eventIndex ] } ;
231226 updatedEvent . Title = title ;
232227 updatedEvent . Type = type ;
233- updatedEvent . Status = status ;
228+ updatedEvent . Status = status ! ;
234229 updatedEvent . Start = start ;
235230 updatedEvent . End = end ;
236231
237232 const newHistory : Models . IHistory = {
238233 Id : Math . max ( ...Array . from ( updatedEvent . Histories ) . map ( h => h . Id ) , 0 ) + 1 ,
239234 Message : update ,
240235 Created : updateAt ,
241- Status : status ,
236+ Status : status ! ,
242237 Event : updatedEvent
243238 } ;
244239 updatedEvent . Histories . add ( newHistory ) ;
0 commit comments