const { UserAreaCollection } = require("../../resources/sales/area/UserAreaCollection.js");
const { getAllAreaByUserService } = require("../../services/sales/AreaService.js");
const { PaginationParam } = require("../../utils/PaginationParams");
const { errorResponse } = require("../../utils/Response");

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

        const { areas, total } = await getAllAreaByUserService({ page, limit, search, sortBy, orderBy }, req);

        return UserAreaCollection(req, res, areas, total, page, limit, 'Area data successfully retrieved');
    } catch (err) {
        return errorResponse(res, err);
    }
};