Skip to content

Commit

Permalink
Get org member GQL query working
Browse files Browse the repository at this point in the history
  • Loading branch information
myieye authored and rmunn committed Jun 20, 2024
1 parent e3d3e9c commit eaf6e8b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
7 changes: 3 additions & 4 deletions frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import UserModal from '$lib/components/Users/UserModal.svelte';
import OrgMemberTable from './OrgMemberTable.svelte';
import ProjectTable from '$lib/components/Projects/ProjectTable.svelte';
import type { UUID } from 'crypto';
export let data: PageData;
$: user = data.user;
Expand Down Expand Up @@ -49,10 +50,8 @@
let userModal: UserModal;
async function openUserModal(user: User): Promise<void> {
// Although we receive a TableUser, we know in practice it's a full User object
const queryUser = await _orgMemberById(org.id, user.id);
console.log('_orgMemberById returned', queryUser);
return userModal.open(user);
const queryUser = await _orgMemberById(org.id as UUID, user.id as UUID);
return userModal.open(queryUser);
}
let addOrgMemberModal: AddOrgMemberModal;
Expand Down
45 changes: 19 additions & 26 deletions frontend/src/routes/(authenticated)/org/[org_id]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,41 +169,34 @@ export async function _addOrgMember(orgId: UUID, emailOrUsername: string, role:
return result;
}

// NOT WOKRING YET: having trouble getting this to type-check and compile
export async function _orgMemberById(orgId: UUID, userId: UUID): Promise<GqlResult<OrgMemberDto>> {
export async function _orgMemberById(orgId: UUID, userId: UUID): Promise<OrgMemberDto> {
//language=GraphQL
const result = await getClient()
.query(
graphql(`
query OrgMemberById($orgId: UUID!, $userId: UUID!}!) {
orgMemberById($orgId, $userId) {
orgMemberDto {
id
name
email
emailVerified
isAdmin
createdDate
username
locked
localizationCode
updatedDate
lastActive
canCreateProjects
}
errors {
__typename
... on Error {
message
}
}
query OrgMemberById($orgId: UUID!, $userId: UUID!) {
orgMemberById(orgId: $orgId, userId: $userId) {
id
name
email
emailVerified
isAdmin
createdDate
username
locked
localizationCode
updatedDate
lastActive
canCreateProjects
}
}
`),
{ orgId, userId },
);
return result;
);

if (!result.data?.orgMemberById) error(404);

return result.data.orgMemberById;
}

export async function _changeOrgMemberRole(orgId: string, userId: string, role: OrgRole): $OpResult<ChangeOrgMemberRoleMutation> {
Expand Down

0 comments on commit eaf6e8b

Please sign in to comment.