Skip to content

Commit

Permalink
refactor load function
Browse files Browse the repository at this point in the history
  • Loading branch information
SeongHo Park committed Jul 4, 2024
1 parent f0dfe69 commit 5549165
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions frontend/src/routes/(authenticated)/project/create/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function load(event: PageLoadEvent) {
requestingUser = userResultsPromise.data?.users?.items?.[0];
}

let orgs;
if (userIsAdmin) {
const orgsPromise = await client.query(graphql(`
query loadOrgs {
Expand All @@ -45,8 +46,7 @@ export async function load(event: PageLoadEvent) {
}
}
`), {}, { fetch: event.fetch });
const orgs = orgsPromise.data?.orgs;
return { requestingUser, myOrgs: orgs };
orgs = orgsPromise.data?.orgs;
} else {
const myOrgsPromise = await client.query(graphql(`
query loadMyOrgs {
Expand All @@ -56,9 +56,9 @@ export async function load(event: PageLoadEvent) {
}
}
`), {}, { fetch: event.fetch });
const myOrgs = myOrgsPromise.data?.myOrgs;
return { requestingUser, myOrgs };
orgs = myOrgsPromise.data?.myOrgs;
}
return { requestingUser, myOrgs: orgs };
}

export async function _createProject(input: CreateProjectInput): $OpResult<CreateProjectMutation> {
Expand Down

0 comments on commit 5549165

Please sign in to comment.