Skip to content

Commit

Permalink
[C] Update create collaborator api resource
Browse files Browse the repository at this point in the history
  • Loading branch information
1aurend committed Feb 3, 2025
1 parent 127790c commit 556280f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions client/src/api/resources/collaborators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
15 changes: 7 additions & 8 deletions client/src/backend/components/collaborator/AddForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 556280f

Please sign in to comment.