@@ -63,37 +63,30 @@ export const setRoomToReadOnly = function(gigRoomId) {
63
63
} ) ;
64
64
} ;
65
65
66
- export const setRoomTypeToPublic = function ( gigId , gigRoomId , statusCallback ) {
66
+ export async function publishGig ( gigId , statusCallback ) {
67
67
const authSet = UserProfile . getAuthSet ( ) ;
68
- const publishPayload = {
69
- roomId : gigRoomId ,
70
- type : "c"
71
- } ;
72
-
73
- fetch ( `/admin-ui/api/rc/set_group_type` , {
68
+ const callback = statusCallback || ( ( ) => 0 ) ;
69
+ callback ( "loading" ) ;
70
+ const response = await fetch ( `/api/gigs/${ gigId } /publish` , {
74
71
method : "POST" ,
75
72
headers : {
76
73
"Content-Type" : "application/json" ,
77
74
"x-auth-token" : authSet . token ,
78
75
"x-user-id" : authSet . userId
79
- } ,
80
- body : JSON . stringify ( publishPayload )
81
- } ) . then ( data => {
82
- if ( data . status !== 200 ) {
83
- data . json ( ) . then ( json => {
84
- NotificationManager . error ( json . error . errmsg ) ;
85
- } ) ;
86
- } else {
87
- data . json ( ) . then ( json => {
88
- const updatePayload = {
89
- status : "Active" ,
90
- rc_channel_id : json . group
91
- } ;
92
- update ( gigId , updatePayload , statusCallback ) ;
93
- } ) ;
94
76
}
95
77
} ) ;
96
- } ;
78
+
79
+ const data = await response . json ( ) ;
80
+ if ( response . status !== 200 || ! data . success ) {
81
+ NotificationManager . error (
82
+ data . error || "There was an error publishing the gig"
83
+ ) ;
84
+ callback ( "error" ) ;
85
+ return ;
86
+ }
87
+
88
+ callback ( "success" ) ;
89
+ }
97
90
98
91
export const kick_user = async function ( gigRoomId , userId ) {
99
92
const authSet = UserProfile . getAuthSet ( ) ;
0 commit comments