2021-03-12 05:23:46 -05:00
|
|
|
import {
|
|
|
|
deleteJSON,
|
|
|
|
getJSON,
|
|
|
|
postJSON,
|
2021-04-27 03:52:58 -04:00
|
|
|
putJSON,
|
2021-03-12 05:23:46 -05:00
|
|
|
} from '../../../infrastructure/fetch-json'
|
|
|
|
import { executeV2Captcha } from './captcha'
|
|
|
|
|
|
|
|
export function sendInvite(project, email, privileges) {
|
|
|
|
return executeV2Captcha(
|
|
|
|
window.ExposedSettings.recaptchaDisabled?.invite
|
|
|
|
).then(grecaptchaResponse => {
|
|
|
|
return postJSON(`/project/${project._id}/invite`, {
|
|
|
|
body: {
|
|
|
|
email, // TODO: normalisedEmail?
|
|
|
|
privileges,
|
2021-04-27 03:52:58 -04:00
|
|
|
'g-recaptcha-response': grecaptchaResponse,
|
|
|
|
},
|
2021-03-12 05:23:46 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function resendInvite(project, invite) {
|
|
|
|
return postJSON(`/project/${project._id}/invite/${invite._id}/resend`)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function revokeInvite(project, invite) {
|
|
|
|
return deleteJSON(`/project/${project._id}/invite/${invite._id}`)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateMember(project, member, data) {
|
|
|
|
return putJSON(`/project/${project._id}/users/${member._id}`, {
|
2021-04-27 03:52:58 -04:00
|
|
|
body: data,
|
2021-03-12 05:23:46 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function removeMemberFromProject(project, member) {
|
|
|
|
return deleteJSON(`/project/${project._id}/users/${member._id}`)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function transferProjectOwnership(project, member) {
|
|
|
|
return postJSON(`/project/${project._id}/transfer-ownership`, {
|
|
|
|
body: {
|
2021-04-27 03:52:58 -04:00
|
|
|
user_id: member._id,
|
|
|
|
},
|
2021-03-12 05:23:46 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setProjectAccessLevel(project, publicAccessLevel) {
|
|
|
|
return postJSON(`/project/${project._id}/settings/admin`, {
|
2021-04-27 03:52:58 -04:00
|
|
|
body: { publicAccessLevel },
|
2021-03-12 05:23:46 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// export function updateProjectAdminSettings(project, data) {
|
|
|
|
// return postJSON(`/project/${project._id}/settings/admin`, {
|
|
|
|
// body: data
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
|
|
|
|
export function listProjectMembers(project) {
|
|
|
|
return getJSON(`/project/${project._id}/members`)
|
|
|
|
}
|
|
|
|
|
|
|
|
export function listProjectInvites(project) {
|
|
|
|
return getJSON(`/project/${project._id}/invites`)
|
|
|
|
}
|