Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/modules/appointments/appointment.controller.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import * as appointmentService from './appointment.service.js';
import { asyncHandler, ApiResponse } from '../../shared/utils/helpers.js';

// Controller functions for appointment routes
export const createAppointment = asyncHandler(async (req, res) => {
const result = await appointmentService.createAppointment(req.body);
res.status(201).json(ApiResponse.success(result, 'Appointment created successfully', 201));
});

// Get all appointments with optional filters (date range, provider, user)
export const getAllAppointments = asyncHandler(async (req, res) => {
const result = await appointmentService.getAllAppointments(req.query);
res.status(200).json(ApiResponse.success(result, 'Appointments retrieved successfully'));
});

// Get appointment by ID
export const getAppointmentById = asyncHandler(async (req, res) => {
const result = await appointmentService.getAppointmentById(req.params.appointmentId);
res.status(200).json(ApiResponse.success(result, 'Appointment retrieved successfully'));
});

// Get appointments for a specific user
export const getUserAppointments = asyncHandler(async (req, res) => {
const result = await appointmentService.getAppointmentsByUser(req.params.userId, req.query);
res.status(200).json(ApiResponse.success(result, 'User appointments retrieved successfully'));
});

// Get appointments for a specific provider
export const getProviderAppointments = asyncHandler(async (req, res) => {
const result = await appointmentService.getAppointmentsByProvider(req.params.providerId, req.query);
res.status(200).json(ApiResponse.success(result, 'Provider appointments retrieved successfully'));
Expand Down
Loading