const { getAllAreaByUserService } = require("../../services/sales/AreaService.js");
const { ListResponse } = require("../../utils/ListResponse");
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 ListResponse({ req, res, data: areas, page, limit, total, message: 'Area city successfully retrieved' });
    } catch (err) {
        return errorResponse(res, err);
    }
};