diff --git a/client/src/api/resources/collaborators.js b/client/src/api/resources/collaborators.js index 79b8e3f755..40f452ada9 100644 --- a/client/src/api/resources/collaborators.js +++ b/client/src/api/resources/collaborators.js @@ -16,9 +16,9 @@ export default { }; }, - create(collaborators) { + create(entityType, entityId, collaborators) { return { - endpoint: `/api/v1/collaborators/create_from_roles`, + endpoint: `/api/v1/${entityType}/${entityId}/relationships/collaborators/create_from_roles`, method: "POST", options: { body: JSON.stringify({ data: collaborators }) diff --git a/client/src/backend/components/collaborator/AddForm/index.js b/client/src/backend/components/collaborator/AddForm/index.js index ac86c7f913..e11acfbd5a 100644 --- a/client/src/backend/components/collaborator/AddForm/index.js +++ b/client/src/backend/components/collaborator/AddForm/index.js @@ -44,15 +44,14 @@ export default function AddCollaboratorForm({ e.preventDefault(); const data = { - attributes: { - roles - }, - relationships: { - maker: { data: { id: makerId.id, type: "maker" } }, - collaboratable: { data: { id: entityId, type: entityType } } - } + roles, + maker: { data: { id: makerId.id, type: "maker" } } }; - const { errors } = await createCollaborator(data); + const { errors } = await createCollaborator( + `${entityType.toLowerCase()}s`, + entityId, + data + ); if (!errors) { if (refresh) refresh();