'use strict'; const catchAsync = require('../../utils/catchAsync'); const pendingStudentService = require('./pendingStudentService'); const { successResponse, listResponse } = require('../../utils/apiResponse'); exports.getPricing = catchAsync(async (req, res) => { const preview = await pendingStudentService.getPricingPreview({ classId: req.query.classId, type: req.query.type || 'enrollment', paymentPlan: req.query.paymentPlan || 'full' }); return successResponse(res, 200, 'Pricing preview retrieved successfully', preview); }); exports.ensureUser = catchAsync(async (req, res) => { const result = await pendingStudentService.findOrCreateUser(req.body); return successResponse(res, 200, 'User ensured successfully', result); }); exports.completeAfterPayment = catchAsync(async (req, res) => { const pending = await pendingStudentService.createPendingStudentAfterPayment(req.body); return successResponse(res, 201, 'Registration request submitted successfully', pending); }); exports.getAll = catchAsync(async (req, res) => { const { data, meta } = await pendingStudentService.getAllPendingStudents(req.query); return listResponse(res, 200, data, meta); }); exports.getOne = catchAsync(async (req, res) => { const pending = await pendingStudentService.getPendingStudentById(req.params.id); return successResponse(res, 200, 'Pending student retrieved successfully', pending); }); exports.approve = catchAsync(async (req, res) => { const result = await pendingStudentService.approvePendingStudent(req.params.id, req.user._id, req.body); return successResponse(res, 200, 'Pending student approved successfully', result); }); exports.reject = catchAsync(async (req, res) => { const result = await pendingStudentService.rejectPendingStudent(req.params.id, req.user._id, req.body); return successResponse(res, 200, 'Pending student rejected successfully', result); });