@@ -3,10 +3,12 @@ import dayjs from "dayjs";
33import { orderBy } from "lodash" ;
44import ReactMarkdown from 'react-markdown' ;
55import MdEditor from 'react-markdown-editor-lite' ;
6+ import { useAuth } from "react-oidc-context" ;
67import remarkGfm from 'remark-gfm' ;
78import remarkIns from 'remark-ins' ;
89import { Dic , MDDecsPlugins } from "~/Helpers/Entities" ;
910import { useStatus } from "~/Services/Status" ;
11+ import { Roles } from "../Auth/With" ;
1012import { EventType , IsIncident } from "../Event/Enums" ;
1113import { useNewForm } from "./useNewForm" ;
1214
@@ -25,11 +27,19 @@ import { useNewForm } from "./useNewForm";
2527 *
2628 * @author Aloento
2729 * @since 1.0.0
28- * @version 0.2.0
30+ * @version 0.2.1
2931 */
3032export function NewForm ( ) {
3133 const { DB } = useStatus ( ) ;
3234 const { State, Actions, Validation, OnSubmit, Loading } = useNewForm ( ) ;
35+ const auth = useAuth ( ) ;
36+
37+ const groups : string [ ] = ( auth . user ?. profile as any ) ?. groups || [ ] ;
38+ const isCreatorOnly = ! groups . includes ( Roles . Operators ) && ! groups . includes ( Roles . Admins ) ;
39+
40+ const availableTypes = isCreatorOnly
41+ ? [ EventType . Maintenance ]
42+ : Object . values ( EventType ) . slice ( 1 ) ;
3343
3444 return (
3545 < >
@@ -48,8 +58,9 @@ export function NewForm() {
4858 onScale-change = { ( e ) => Actions . setType ( e . target . value as EventType ) }
4959 invalid = { ! ! Validation . type }
5060 helperText = { Validation . type }
61+ disabled = { isCreatorOnly }
5162 >
52- { Object . values ( EventType ) . slice ( 1 ) . map ( ( type , i ) =>
63+ { availableTypes . map ( ( type , i ) =>
5364 < ScaleDropdownSelectItem value = { type } key = { i } >
5465 { type }
5566 </ ScaleDropdownSelectItem > ) }
0 commit comments