Skip to content

Feature/booking system - #49

Merged
Umeshinduranga merged 10 commits into
mainfrom
feature/booking-system
Mar 20, 2026
Merged

Feature/booking system#49
Umeshinduranga merged 10 commits into
mainfrom
feature/booking-system

Conversation

@Umeshinduranga

Copy link
Copy Markdown
Collaborator

This pull request introduces several new features and improvements to the backend of the recovery system, mainly focused on counselor and booking functionality, as well as enhancements to user authentication and seeding scripts. The most significant changes include new endpoints for booking counseling sessions, expanded counselor query capabilities, a custom sign-up endpoint for testing, and a script to seed counselor data. Minor improvements were also made to response handling for consistency.

Counselor and Booking Functionality

  • Added a comprehensive booking controller (booking.controller.ts) with endpoints for creating, retrieving, and cancelling bookings, as well as managing counselor availability slots. This enables users to book sessions and counselors to manage their schedules.
  • Expanded counselor controller (Counselor.controller.ts) with endpoints to fetch all counselors (with filters) and retrieve individual counselor profiles, supporting more flexible queries and improved data access.

Authentication and User Management

  • Added a custom sign-up endpoint (signUp) in auth.controller.ts and registered it in app.ts, allowing user registration for testing purposes. [1] [2] [3]
  • Improved response consistency in auth.controller.ts by ensuring all responses use return res.json(...) for clarity and maintainability. [1] [2] [3]

Data Seeding

  • Introduced a new script (seed-counselors.ts) to seed the database with test counselors, their profiles, and available slots, facilitating development and testing.

Minor Improvements

  • Updated journal controller responses to use return res.status(...).json(...) for consistency. [1] [2]

Routing Enhancements

  • Registered new booking routes in app.ts to enable the booking endpoints.

These changes collectively enhance the backend's support for counseling and booking workflows, improve developer experience, and ensure more robust and consistent API responses.

iukumarasiri-dev and others added 10 commits March 20, 2026 00:04
- Fixed Counselor.ts: Changed ref from 'User' to 'users'
- Fixed Booking.ts: Changed ref from 'User' to 'users'
- Fixed Progress.ts: Changed ref from 'User' to 'users'
- Fixed Reminder.ts: Changed ref from 'User' to 'users'
- Fixed Journal.ts: Changed ref from 'User' to 'users'

These fixes ensure proper MongoDB population by using the correct registered model name.
- Modified getBookingById(): First find booking, then check ownership separately
- Returns 403 Forbidden if user doesn't own the booking
- Returns 404 Not Found if booking doesn't exist
- Updated booking controller to handle 403 status code
- Added same access control to cancelBooking()

This ensures proper distinction between 'not found' and 'access denied' scenarios.
- Modified cancelBooking() to fetch booking without populate first
- Checks ownership before attempting cancellation
- Calls markSlotAsAvailable() with raw counselorId string
- Returns populated booking in response for client context
- Improved error handling in slot marking methods
- Enhanced markSlotAsBooked() and markSlotAsAvailable() with try-catch

This ensures slots are properly freed when bookings are cancelled.
- Added custom signUp endpoint for testing (POST /api/auth/register)
- Generates base64-encoded JSON tokens: {id, email, name, role}
- Updated isAuth middleware to support dual auth modes
- Tries BetterAuth sessions first, falls back to base64 tokens
- Decodes and validates base64 tokens against database user
- Registered /api/auth/register route in app.ts

This allows testing without BetterAuth while maintaining production compatibility.
- Added User model import for potential future use
- Fixed specialty filter to use MongoDB  operator
- Specialty filter now correctly matches array elements
- Improved error logging for debugging
- Handles both 'specializations' and 'specialty' query parameters
- Filter supports both single values and comma-separated lists

This ensures specialty filtering works correctly across all counselor queries.
- Add responsive grid layout: 1 column on mobile, 2 on tablet+
- Make BookingModal fully responsive with stacked layout on mobile
- Improve CounselorCard footer layout for mobile screens
- Add responsive padding and text sizing across components
- Hide filter sidebar on mobile, show on desktop (lg breakpoint)
- Fix time slot grid to 2 columns on mobile, 3 on tablet+
- Update page container with mobile-first padding scheme
- Enhance success toast responsiveness with better sizing
@vercel

vercel Bot commented Mar 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
re-life-website Ignored Ignored Mar 20, 2026 6:32am

@Umeshinduranga Umeshinduranga left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewe

@Umeshinduranga
Umeshinduranga merged commit fd8946d into main Mar 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants