Skip to content

Commit 98f11c5

Browse files
committed
fix: can't read undefinded of origanization while creating new organization
1 parent c99966a commit 98f11c5

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/resolvers/team.resolvers.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,11 @@ const resolvers = {
272272
const { name, cohortName, orgToken, startingPhase, ttlEmail } = args
273273

274274
// some validations
275-
;(await checkUserLoggedIn(context))([RoleOfUser.SUPER_ADMIN, RoleOfUser.ADMIN, RoleOfUser.MANAGER])
275+
;(await checkUserLoggedIn(context))([
276+
RoleOfUser.SUPER_ADMIN,
277+
RoleOfUser.ADMIN,
278+
RoleOfUser.MANAGER,
279+
])
276280
const cohort = await Cohort.findOne({ name: cohortName })
277281

278282
const organ = await checkLoggedInOrganization(orgToken)
@@ -346,7 +350,10 @@ const resolvers = {
346350
}
347351
},
348352
deleteTeam: async (parent: any, args: any, context: Context) => {
349-
;(await checkUserLoggedIn(context))([RoleOfUser.ADMIN, RoleOfUser.MANAGER])
353+
;(await checkUserLoggedIn(context))([
354+
RoleOfUser.ADMIN,
355+
RoleOfUser.MANAGER,
356+
])
350357
const findTeam = await Team.findById(args.id)
351358
if (!findTeam)
352359
throw new Error('The Team you want to delete does not exist')
@@ -425,7 +432,7 @@ const resolvers = {
425432
const prevTeamName = team.name
426433
const teamCohort = team?.cohort
427434
const cohortProgram = team?.cohort?.program as ProgramType
428-
const cohortOrg = cohortProgram.organization as OrganizationType
435+
const cohortOrg = cohortProgram?.organization as OrganizationType
429436
const org = await checkLoggedInOrganization(orgToken)
430437

431438
if (!team) {
@@ -450,8 +457,10 @@ const resolvers = {
450457

451458
if (role !== RoleOfUser.SUPER_ADMIN) {
452459
const org = await checkLoggedInOrganization(orgToken)
453-
454-
if (cohortOrg.id.toString() !== org.id.toString()) {
460+
console.log('>>>>>>>>>>>>>')
461+
console.log(cohortOrg)
462+
console.log('>>>>>>>>>>>>>')
463+
if (cohortOrg?.id.toString() !== org.id.toString()) {
455464
throw new GraphQLError(
456465
`Team with id "${team?.id}" doesn't exist in this organization`,
457466
{

src/resolvers/ticket.resolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,4 +614,4 @@ const resolvers = {
614614
},
615615
}
616616

617-
export default resolvers
617+
export default resolvers

src/utils/templates/eventInvitationTemplates.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,4 @@ export function invitationCancellationTemplate(eventTitle: string): string {
116116
</tr>
117117
</tbody>
118118
</table>`
119-
}
119+
}

0 commit comments

Comments
 (0)