1- import type { $OpResult , AskToJoinProjectMutation , CreateProjectInput , CreateProjectMutation , ProjectsByLangCodeAndOrgQuery , ProjectsByNameAndOrgQuery } from '$lib/gql/types' ;
1+ import type { $OpResult , AskToJoinProjectMutation , CreateProjectInput , CreateProjectMutation , LoadRequestingUserQuery , ProjectStatus , ProjectsByLangCodeAndOrgQuery , ProjectsByNameAndOrgQuery } from '$lib/gql/types' ;
22import { getClient , graphql } from '$lib/gql' ;
33
44import type { PageLoadEvent } from './$types' ;
@@ -8,7 +8,7 @@ import {isGuid} from '$lib/util/guid';
88export async function load ( event : PageLoadEvent ) {
99 const userIsAdmin = ( await event . parent ( ) ) . user . isAdmin ;
1010 const requestingUserId = getSearchParam < CreateProjectInput > ( 'projectManagerId' , event . url . searchParams ) ;
11- let requestingUser = null ;
11+ let requestingUser : NonNullable < NonNullable < NonNullable < LoadRequestingUserQuery > [ 'users' ] > [ 'items' ] > [ number ] | undefined ;
1212 const client = getClient ( ) ;
1313 if ( userIsAdmin && isGuid ( requestingUserId ) ) {
1414 const userResultsPromise = await client . query ( graphql ( `
@@ -36,7 +36,7 @@ export async function load(event: PageLoadEvent) {
3636 requestingUser = userResultsPromise . data ?. users ?. items ?. [ 0 ] ;
3737 }
3838
39- let orgs ;
39+ let orgs : undefined | { id : string , name : string } [ ] ;
4040 if ( userIsAdmin ) {
4141 const orgsPromise = await client . query ( graphql ( `
4242 query loadOrgs {
@@ -58,7 +58,24 @@ export async function load(event: PageLoadEvent) {
5858 ` ) , { } , { fetch : event . fetch } ) ;
5959 orgs = myOrgsPromise . data ?. myOrgs ;
6060 }
61- return { requestingUser, myOrgs : orgs } ;
61+
62+ const projectId = getSearchParam < CreateProjectInput > ( 'id' , event . url . searchParams ) ;
63+ let projectStatus : ProjectStatus | undefined ;
64+ if ( projectId ) {
65+ const projectStatusResult = await client . query ( graphql ( `
66+ query loadProjectStatus($projectId: UUID!) {
67+ projectStatus(projectId: $projectId) {
68+ id
69+ exists
70+ deleted
71+ accessibleCode
72+ }
73+ }
74+ ` ) , { projectId} , { fetch : event . fetch } ) ;
75+ projectStatus = projectStatusResult . data ?. projectStatus ;
76+ }
77+
78+ return { requestingUser, myOrgs : orgs , projectStatus } ;
6279}
6380
6481export async function _createProject ( input : CreateProjectInput ) : $OpResult < CreateProjectMutation > {
0 commit comments