Skip to content

Commit

Permalink
Attempt to use orgMemberById query in frontend
Browse files Browse the repository at this point in the history
Not working yet due to type errors.
  • Loading branch information
rmunn committed Jun 20, 2024
1 parent 1cab03a commit e3d3e9c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type { PageData } from './$types';
import { OrgRole } from '$lib/gql/types';
import { useNotifications } from '$lib/notify';
import { _changeOrgName, _deleteOrgUser, _deleteOrg, type OrgSearchParams, type User, type OrgUser } from './+page';
import { _changeOrgName, _deleteOrgUser, _deleteOrg, _orgMemberById, type OrgSearchParams, type User, type OrgUser } from './+page';
import OrgTabs, { type OrgTabId } from './OrgTabs.svelte';
import { getSearchParams, queryParam } from '$lib/util/query-params';
import { Icon, TrashIcon } from '$lib/icons';
Expand Down Expand Up @@ -48,8 +48,10 @@
}
let userModal: UserModal;
function openUserModal(user: User): Promise<void> {
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);
}
Expand Down
39 changes: 39 additions & 0 deletions frontend/src/routes/(authenticated)/org/[org_id]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import type {
ChangeOrgNameMutation,
DeleteOrgMutation,
DeleteOrgUserMutation,
GqlResult,
OrgMemberDto,
OrgPageQuery,
OrgRole,
} from '$lib/gql/types';
Expand Down Expand Up @@ -167,6 +169,43 @@ 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>> {
//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
}
}
}
}
`),
{ orgId, userId },
);
return result;

}

export async function _changeOrgMemberRole(orgId: string, userId: string, role: OrgRole): $OpResult<ChangeOrgMemberRoleMutation> {
//language=GraphQL
const result = await getClient()
Expand Down

0 comments on commit e3d3e9c

Please sign in to comment.