Skip to content

Commit

Permalink
feat: update query client for share item (#1400)
Browse files Browse the repository at this point in the history
* feat: update query client for share item

* refactor: fix test
  • Loading branch information
pyphilia authored Aug 7, 2024
1 parent b8d66e8 commit e6d826d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
8 changes: 4 additions & 4 deletions cypress/e2e/memberships/createItemMembership.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ describe('Create Membership', () => {
const permission = PermissionLevel.Read;
shareItem({ id, member, permission });

cy.wait('@postManyItemMemberships').then(
cy.wait('@postInvitations').then(
({
request: {
url,
body: { memberships },
body: { invitations },
},
}) => {
expect(url).to.contain(id);
expect(memberships[0].permission).to.equal(permission);
expect(memberships[0].memberId).to.equal(member.id);
expect(invitations[0].permission).to.equal(permission);
expect(invitations[0].email).to.equal(member.email);
},
);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@emotion/styled": "11.13.0",
"@graasp/chatbox": "3.1.0",
"@graasp/map": "1.17.0",
"@graasp/query-client": "3.20.3",
"@graasp/query-client": "3.21.0",
"@graasp/sdk": "4.22.0",
"@graasp/translations": "1.33.0",
"@graasp/ui": "4.23.0",
Expand Down
20 changes: 7 additions & 13 deletions src/components/item/sharing/CreateItemMembershipForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,21 @@ const CreateItemMembershipForm = ({

let returnedValue;
try {
const result = await shareItem({
await shareItem({
itemId,
data: [
invitations: [
{
id: itemId,
email: invitation.email,
permission: invitation.permission,
},
],
});

// manually notify error
if (result?.errors?.length) {
console.error(result?.errors);
} else {
// reset email input
setInvitation({
...invitation,
email: '',
});
}
// reset email input
setInvitation({
...invitation,
email: '',
});
} catch (e) {
console.error(e);
}
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1857,9 +1857,9 @@ __metadata:
languageName: node
linkType: hard

"@graasp/query-client@npm:3.20.3":
version: 3.20.3
resolution: "@graasp/query-client@npm:3.20.3"
"@graasp/query-client@npm:3.21.0":
version: 3.21.0
resolution: "@graasp/query-client@npm:3.21.0"
dependencies:
"@tanstack/react-query": "npm:4.36.1"
"@tanstack/react-query-devtools": "npm:4.36.1"
Expand All @@ -1869,7 +1869,7 @@ __metadata:
"@graasp/sdk": ^4.0.0
"@graasp/translations": "*"
react: ^18.0.0
checksum: 10/29b741787df01cfd537b78985a56c0b9d5a8660943902ee6f4f051a3dcef62028a577068accf590d9ef9010c6892707ee602fb0c666dbe91f81cde01a6c12fe7
checksum: 10/801a1e1b45f985f82468b2527adc2cda8b2541aac3549a22fde81dc40387867e9f7c46dee001f77d23f4b6a4de19c0d2ea85b0a2f1499e848c880ece69a34177
languageName: node
linkType: hard

Expand Down Expand Up @@ -8145,7 +8145,7 @@ __metadata:
"@emotion/styled": "npm:11.13.0"
"@graasp/chatbox": "npm:3.1.0"
"@graasp/map": "npm:1.17.0"
"@graasp/query-client": "npm:3.20.3"
"@graasp/query-client": "npm:3.21.0"
"@graasp/sdk": "npm:4.22.0"
"@graasp/translations": "npm:1.33.0"
"@graasp/ui": "npm:4.23.0"
Expand Down

0 comments on commit e6d826d

Please sign in to comment.