feat: add waitlist module, quick payment/transaction edit, and catering fee deduction from professor share
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
// /components/waitlist/waitlistController.js
|
||||
'use strict';
|
||||
|
||||
const catchAsync = require('../../utils/catchAsync');
|
||||
const waitlistService = require('./waitlistService');
|
||||
const { successResponse, listResponse } = require('../../utils/apiResponse');
|
||||
|
||||
exports.getAll = catchAsync(async (req, res) => {
|
||||
const { data, meta } = await waitlistService.getAll(req.query);
|
||||
return listResponse(res, 200, data, meta);
|
||||
});
|
||||
|
||||
exports.getOne = catchAsync(async (req, res) => {
|
||||
const item = await waitlistService.getOne(req.params.id);
|
||||
return successResponse(res, 200, 'Waitlist item retrieved successfully', item);
|
||||
});
|
||||
|
||||
exports.create = catchAsync(async (req, res) => {
|
||||
const actorId = req.user?._id;
|
||||
const item = await waitlistService.create(req.body, actorId);
|
||||
return successResponse(res, 201, 'Student added to waitlist successfully', item);
|
||||
});
|
||||
|
||||
exports.update = catchAsync(async (req, res) => {
|
||||
const actorId = req.user?._id;
|
||||
const item = await waitlistService.update(req.params.id, req.body, actorId);
|
||||
return successResponse(res, 200, 'Waitlist item updated successfully', item);
|
||||
});
|
||||
|
||||
exports.assignClass = catchAsync(async (req, res) => {
|
||||
const actorId = req.user?._id;
|
||||
const item = await waitlistService.assignToClass(req.params.id, req.body, actorId);
|
||||
return successResponse(res, 200, 'Student assigned to class successfully', item);
|
||||
});
|
||||
|
||||
exports.revert = catchAsync(async (req, res) => {
|
||||
const actorId = req.user?._id;
|
||||
const item = await waitlistService.revert(req.params.id, req.body, actorId);
|
||||
return successResponse(res, 200, 'Waitlist registration reverted successfully', item);
|
||||
});
|
||||
|
||||
exports.cancel = catchAsync(async (req, res) => {
|
||||
const actorId = req.user?._id;
|
||||
const item = await waitlistService.cancel(req.params.id, req.body, actorId);
|
||||
return successResponse(res, 200, 'Waitlist registration cancelled successfully', item);
|
||||
});
|
||||
|
||||
exports.delete = catchAsync(async (req, res) => {
|
||||
await waitlistService.remove(req.params.id);
|
||||
return successResponse(res, 200, 'Waitlist item deleted successfully');
|
||||
});
|
||||
|
||||
exports.getStats = catchAsync(async (req, res) => {
|
||||
const stats = await waitlistService.getStats();
|
||||
return successResponse(res, 200, 'Waitlist stats retrieved successfully', stats);
|
||||
});
|
||||
Reference in New Issue
Block a user