diff --git a/frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte b/frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte index a3e309ff2..44a3aad75 100644 --- a/frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte +++ b/frontend/src/routes/(authenticated)/org/[org_id]/+page.svelte @@ -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; @@ -49,10 +50,8 @@ let userModal: UserModal; async function openUserModal(user: User): Promise { - // 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; diff --git a/frontend/src/routes/(authenticated)/org/[org_id]/+page.ts b/frontend/src/routes/(authenticated)/org/[org_id]/+page.ts index 3ada7c550..991197503 100644 --- a/frontend/src/routes/(authenticated)/org/[org_id]/+page.ts +++ b/frontend/src/routes/(authenticated)/org/[org_id]/+page.ts @@ -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> { +export async function _orgMemberById(orgId: UUID, userId: UUID): Promise { //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 {