File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " statusdashboard" ,
3- "version" : " 1.4 .0" ,
3+ "version" : " 1.5 .0" ,
44 "type" : " module" ,
55 "scripts" : {
66 "dev" : " farm start" ,
Original file line number Diff line number Diff line change 1+ import { ScaleButton , ScaleIconActionCheckmark } from "@telekom/scale-components-react" ;
2+ import { useRequest } from "ahooks" ;
3+ import { useAccessToken } from "../Auth/useAccessToken" ;
4+
5+ /**
6+ * @author Aloento
7+ * @since 1.5.0
8+ * @version 0.1.0
9+ */
10+ export function EventApprove ( { EventId } : { EventId : number } ) {
11+ const getToken = useAccessToken ( ) ;
12+
13+ const { runAsync, loading } = useRequest ( async ( ) => {
14+ const url = process . env . SD_BACKEND_URL ! ;
15+ const raw = await fetch ( `${ url } /v2/events/${ EventId } ` , {
16+ method : "PATCH" ,
17+ headers : {
18+ "Content-Type" : "application/json" ,
19+ "Authorization" : `Bearer ${ getToken ( ) } ` ,
20+ } ,
21+ body : JSON . stringify ( {
22+ status : "reviewed" ,
23+ message : "Approved by operator" ,
24+ update_date : new Date ( ) . toISOString ( ) ,
25+ } ) ,
26+ } ) ;
27+
28+ if ( ! raw . ok ) {
29+ throw new Error ( "Failed to approve event: " + await raw . text ( ) ) ;
30+ }
31+
32+ window . location . reload ( ) ;
33+ } , {
34+ manual : true ,
35+ } ) ;
36+
37+ return (
38+ < ScaleButton
39+ size = "small"
40+ variant = "secondary"
41+ disabled = { loading }
42+ onClick = { ( ) => runAsync ( ) }
43+ >
44+ < ScaleIconActionCheckmark />
45+ Approve
46+ </ ScaleButton >
47+ ) ;
48+ }
Original file line number Diff line number Diff line change 1- import { ScaleButton , ScaleIconActionCheckmark } from "@telekom/scale-components-react" ;
21import dayjs from "dayjs" ;
32import { Dic } from "~/Helpers/Entities" ;
43import { Models } from "~/Services/Status.Models" ;
54import { Authorized } from "../Auth/With" ;
65import { Indicator } from "../Home/Indicator" ;
76import { EventStatus , EventType , IsIncident } from "./Enums" ;
87import { EventAffected } from "./EventAffected" ;
8+ import { EventApprove } from "./EventApprove" ;
99import { EventEditor } from "./EventEditor" ;
1010import { EventExtract } from "./EventExtract" ;
1111
@@ -40,10 +40,9 @@ export function EventCard({ Event }: { Event: Models.IEvent }) {
4040
4141 < Authorized >
4242 < div className = "flex gap-x-3" >
43- < ScaleButton size = "small" variant = "secondary" >
44- < ScaleIconActionCheckmark />
45- Approve
46- </ ScaleButton >
43+ { Event . Status === EventStatus . PendingReview && (
44+ < EventApprove EventId = { Event . Id } />
45+ ) }
4746
4847 {
4948 Event . RegionServices . size > 1 &&
You can’t perform that action at this time.
0 commit comments