overleaf/services/web/frontend/js/features/share-project-modal/utils/api.js
Timothée Alby 6319455e91 Merge pull request #6236 from overleaf/ta-project-context-strict
Strict Project Context

GitOrigin-RevId: a0f7f2b3dcb29fbd0102dcb920cf5424a921d583
2022-01-11 09:05:03 +00:00

61 lines
1.6 KiB
JavaScript

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