@@ -3,7 +3,7 @@ import { useBoolean } from "ahooks";
33import dayjs from "dayjs" ;
44import { Dic } from "~/Helpers/Entities" ;
55import { Models } from "~/Services/Status.Models" ;
6- import { EventStatus , EventType , IsOpenStatus } from "./Enums" ;
6+ import { EventStatus , EventType , GetStatusList , IsIncident , IsOpenStatus } from "./Enums" ;
77import { useEditForm } from "./useEditForm" ;
88
99/**
@@ -20,7 +20,7 @@ import { useEditForm } from "./useEditForm";
2020 *
2121 * @author Aloento
2222 * @since 1.0.0
23- * @version 0.1 .0
23+ * @version 0.2 .0
2424 */
2525export function EventEditor ( { Event } : { Event : Models . IEvent } ) {
2626 const { State, Actions, Validation, OnSubmit, Loading } = useEditForm ( Event ) ;
@@ -60,12 +60,12 @@ export function EventEditor({ Event }: { Event: Models.IEvent }) {
6060 < ScaleDropdownSelect
6161 label = "Type"
6262 value = { State . type }
63- disabled = { Event . Type === EventType . Maintenance }
63+ disabled = { ! IsIncident ( Event . Type ) }
6464 onScale-change = { ( e ) => Actions . setType ( e . target . value as EventType ) }
6565 invalid = { ! ! Validation . type }
6666 helperText = { Validation . type }
6767 >
68- { Object . values ( EventType ) . slice ( 2 ) . map ( ( type , i ) =>
68+ { Object . values ( EventType ) . slice ( 2 , 5 ) . map ( ( type , i ) =>
6969 < ScaleDropdownSelectItem value = { type } key = { i } >
7070 { type }
7171 </ ScaleDropdownSelectItem > ) }
@@ -78,11 +78,8 @@ export function EventEditor({ Event }: { Event: Models.IEvent }) {
7878 invalid = { ! ! Validation . status }
7979 helperText = { Validation . status }
8080 >
81- { Object . values ( EventStatus )
82- . slice (
83- State . type === EventType . Maintenance ? 4 : 0 ,
84- State . type === EventType . Maintenance ? 9 : 4
85- ) . map ( ( status , i ) =>
81+ { GetStatusList ( State . type )
82+ . map ( ( status , i ) =>
8683 < ScaleDropdownSelectItem value = { status } key = { i } >
8784 { status }
8885 </ ScaleDropdownSelectItem > ) }
@@ -91,7 +88,7 @@ export function EventEditor({ Event }: { Event: Models.IEvent }) {
9188 < ScaleTextField
9289 type = "datetime-local"
9390 label = "Start CET"
94- disabled = { State . type !== EventType . Maintenance && IsOpenStatus ( Event . Status ) }
91+ disabled = { IsIncident ( State . type ) && IsOpenStatus ( Event . Status ) }
9592 value = { dayjs ( State . start ) . format ( Dic . Picker ) }
9693 onScale-input = { ( e ) => Actions . setStart ( new Date ( e . target . value as string ) ) }
9794 invalid = { ! ! Validation . start }
@@ -101,7 +98,7 @@ export function EventEditor({ Event }: { Event: Models.IEvent }) {
10198 < ScaleTextField
10299 type = "datetime-local"
103100 label = "(Plan) End CET"
104- disabled = { ! ( State . type === EventType . Maintenance || ! IsOpenStatus ( State . status ) ) }
101+ disabled = { ! ( ! IsIncident ( State . type ) || ! IsOpenStatus ( State . status ) ) }
105102 value = { State . end ? dayjs ( State . end ) . format ( Dic . Picker ) : null }
106103 onScale-input = { ( e ) => Actions . setEnd ( new Date ( e . target . value as string ) ) }
107104 invalid = { ! ! Validation . end }
0 commit comments