From 368a7f9f6a59dc61e6f2f1a19c926ec248f684e0 Mon Sep 17 00:00:00 2001 From: mayura-andrew Date: Sun, 29 Sep 2024 15:34:02 +0530 Subject: [PATCH] Refactor: Separate Monthly Checking Services and Controllers - Moved monthly checking service functions to a dedicated service file (monthlyChecking.service.ts). - Moved monthly checking controller functions to a dedicated controller file (monthlyChecking.controller.ts). - Updated import paths and references to reflect the new file structure. - Improved code organization and maintainability by separating concerns. --- src/schemas/mentee-routes.schemas.ts | 4 ++-- src/services/monthlyChecking.service.ts | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/schemas/mentee-routes.schemas.ts b/src/schemas/mentee-routes.schemas.ts index 6cf53cc..072e7a1 100644 --- a/src/schemas/mentee-routes.schemas.ts +++ b/src/schemas/mentee-routes.schemas.ts @@ -34,12 +34,12 @@ export const postMonthlyCheckInSchema = z.object({ .min(1, 'Please provide a valid progress report'), mediaContentLinks: z .array(z.string()) - .min(3, 'Please provide at least 3 media content links') + .min(1, 'Please provide at least 1 media content links') }) export const addFeedbackMonthlyCheckInSchema = z.object({ menteeId: z.string(), checkInId: z.string(), - mentorFeedback: z.string().min(1, 'Please provide a valid feedback'), + mentorFeedback: z.string().min(5, 'Please provide a valid feedback'), isCheckedByMentor: z.boolean() }) diff --git a/src/services/monthlyChecking.service.ts b/src/services/monthlyChecking.service.ts index b7d9ab3..2ae67a1 100644 --- a/src/services/monthlyChecking.service.ts +++ b/src/services/monthlyChecking.service.ts @@ -58,16 +58,12 @@ export const addMonthlyCheckInByMentee = async ( const menteeRepository = dataSource.getRepository(Mentee) const checkInRepository = dataSource.getRepository(MonthlyCheckIn) - console.log(menteeId) - const mentee = await menteeRepository.findOne({ where: { uuid: menteeId } }) - console.log(mentee) - if (!mentee) { return { statusCode: 404, message: 'Mentee not found' } } @@ -81,7 +77,6 @@ export const addMonthlyCheckInByMentee = async ( mentee }) - console.log(newCheckIn) await checkInRepository.save(newCheckIn) return { statusCode: 200, message: 'monthly checking inserted' } @@ -126,7 +121,7 @@ export const fetchMonthlyCheckIns = async ( order: { checkInDate: 'DESC' } }) - if (checkIns.length === 0) { + if (checkIns.length === 0 || !checkIns) { return { statusCode: 404, checkIns: [],