handles scenario where defaultschedule is nil (#8714)

pull/8728/head
Manish Roy 2023-05-06 13:22:54 +05:30 committed by GitHub
parent a2e2b0ed34
commit c6ab889b98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -27,7 +27,12 @@ export const getDefaultScheduleId = async (userId: number, prisma: PrismaClient)
},
});
return defaultSchedule?.id; // TODO: Handle no schedules AT ALL
if (!defaultSchedule) {
// Handle case where defaultSchedule is null by throwing an error
throw new Error("No schedules found for user");
}
return defaultSchedule.id;
};
export const hasDefaultSchedule = async (user: Partial<User>, prisma: PrismaClient) => {