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'
|
|
|
|
|
2022-01-10 10:47:10 -05:00
|
|
|
export function sendInvite(projectId, email, privileges) {
|
2021-03-12 05:23:46 -05:00
|
|
|
return executeV2Captcha(
|
|
|
|
window.ExposedSettings.recaptchaDisabled?.invite
|
|
|
|
).then(grecaptchaResponse => {
|
2022-01-10 10:47:10 -05:00
|
|
|
return postJSON(`/project/${projectId}/invite`, {
|
2021-03-12 05:23:46 -05:00
|
|
|
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
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-01-10 10:47:10 -05:00
|
|
|
export function resendInvite(projectId, invite) {
|
|
|
|
return postJSON(`/project/${projectId}/invite/${invite._id}/resend`)
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
2022-01-10 10:47:10 -05:00
|
|
|
export function revokeInvite(projectId, invite) {
|
|
|
|
return deleteJSON(`/project/${projectId}/invite/${invite._id}`)
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
2022-01-10 10:47:10 -05:00
|
|
|
export function updateMember(projectId, member, data) {
|
|
|
|
return putJSON(`/project/${projectId}/users/${member._id}`, {
|
2021-04-27 03:52:58 -04:00
|
|
|
body: data,
|
2021-03-12 05:23:46 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-01-10 10:47:10 -05:00
|
|
|
export function removeMemberFromProject(projectId, member) {
|
|
|
|
return deleteJSON(`/project/${projectId}/users/${member._id}`)
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
2022-01-10 10:47:10 -05:00
|
|
|
export function transferProjectOwnership(projectId, member) {
|
|
|
|
return postJSON(`/project/${projectId}/transfer-ownership`, {
|
2021-03-12 05:23:46 -05:00
|
|
|
body: {
|
2021-04-27 03:52:58 -04:00
|
|
|
user_id: member._id,
|
|
|
|
},
|
2021-03-12 05:23:46 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-01-10 10:47:10 -05:00
|
|
|
export function setProjectAccessLevel(projectId, publicAccessLevel) {
|
|
|
|
return postJSON(`/project/${projectId}/settings/admin`, {
|
2021-04-27 03:52:58 -04:00
|
|
|
body: { publicAccessLevel },
|
2021-03-12 05:23:46 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-01-10 10:47:10 -05:00
|
|
|
export function listProjectMembers(projectId) {
|
|
|
|
return getJSON(`/project/${projectId}/members`)
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|
|
|
|
|
2022-01-10 10:47:10 -05:00
|
|
|
export function listProjectInvites(projectId) {
|
|
|
|
return getJSON(`/project/${projectId}/invites`)
|
2021-03-12 05:23:46 -05:00
|
|
|
}
|