const { LogCollection } = require('../../resources/superadmin/log/LogCollection.js');
const logService = require('../../services/superadmin/LogService.js');
const { PaginationParam } = require('../../utils/PaginationParams.js');
const { errorResponse } = require('../../utils/Response.js');

exports.getAllLogs = async (req, res) => {
    try {
        const { page, limit, search, sortBy, orderBy } = PaginationParam(req);

        const { logs, total } = await logService.getAllLogsService({
            page, limit, search, sortBy, orderBy
        });

        return LogCollection(req, res, logs, total, page, limit, 'Logs data successfully retrieved');
    } catch (err) {
        return errorResponse(res, err);
    }
};