diff --git a/src/modules/plan/plan.service.ts b/src/modules/plan/plan.service.ts index 55b795c..7350ad6 100644 --- a/src/modules/plan/plan.service.ts +++ b/src/modules/plan/plan.service.ts @@ -21,7 +21,15 @@ export class PlanService { private readonly configService: ConfigService, ) {} - async getPlan(user: User): Promise { + async getPlan({ id }: User): Promise { + const user = await this.prisma.user.findUnique({ + where: { + id: id, + }, + }); + + if (!user) throw new HttpException('User not found', HttpStatus.NOT_FOUND); + const plan = await this.prisma.plan.findFirst({ where: { users: { @@ -100,7 +108,7 @@ export class PlanService { } async createPlan({ id }: User, dto: CreatePlanDTO) { - if (DateTime.fromISO(dto.date).diffNow('minutes').minutes >= -30) + if (DateTime.fromISO(dto.date).diffNow('minutes').minutes <= -30) throw new HttpException('Invalid date', HttpStatus.BAD_REQUEST); const user = await this.prisma.user.findUnique({ diff --git a/src/modules/user/user.controller.ts b/src/modules/user/user.controller.ts index 316f440..3903a42 100644 --- a/src/modules/user/user.controller.ts +++ b/src/modules/user/user.controller.ts @@ -100,11 +100,7 @@ export class UserController { @ApiOkResponse({ description: 'User deleted', type: ResponseDTO }) @ApiUnauthorizedResponse({ description: 'Unauthorized' }) async deleteUser(@CurrentUser() user: User) { - try { - await this.userService.deleteUserById(user.id); - return { status: 'success', data: null }; - } catch (error) { - return { status: 'error', data: null }; - } + await this.userService.deleteUserById(user.id); + return { status: 'success', data: null }; } }