Skip to content

Commit

Permalink
Refactor: Separate Monthly Checking Services and Controllers
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
mayura-andrew committed Sep 29, 2024
1 parent d738745 commit 368a7f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/schemas/mentee-routes.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
7 changes: 1 addition & 6 deletions src/services/monthlyChecking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
}
Expand All @@ -81,7 +77,6 @@ export const addMonthlyCheckInByMentee = async (
mentee
})

console.log(newCheckIn)
await checkInRepository.save(newCheckIn)

return { statusCode: 200, message: 'monthly checking inserted' }
Expand Down Expand Up @@ -126,7 +121,7 @@ export const fetchMonthlyCheckIns = async (
order: { checkInDate: 'DESC' }
})

if (checkIns.length === 0) {
if (checkIns.length === 0 || !checkIns) {
return {
statusCode: 404,
checkIns: [],
Expand Down

0 comments on commit 368a7f9

Please sign in to comment.