Skip to content

Commit b6efade

Browse files
committed
When publishing a gig create a new public room
1 parent a66a847 commit b6efade

File tree

2 files changed

+332
-264
lines changed

2 files changed

+332
-264
lines changed

client/src/components/Gigs/API/RocketChat/RocketChat.jsx

+16-23
Original file line numberDiff line numberDiff line change
@@ -63,37 +63,30 @@ export const setRoomToReadOnly = function(gigRoomId) {
6363
});
6464
};
6565

66-
export const setRoomTypeToPublic = function(gigId, gigRoomId, statusCallback) {
66+
export async function publishGig(gigId, statusCallback) {
6767
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`, {
7471
method: "POST",
7572
headers: {
7673
"Content-Type": "application/json",
7774
"x-auth-token": authSet.token,
7875
"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-
});
9476
}
9577
});
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+
}
9790

9891
export const kick_user = async function(gigRoomId, userId) {
9992
const authSet = UserProfile.getAuthSet();

0 commit comments

Comments
 (0)