const vendorService = require('../../services/sales/VendorService.js');
const { ListResponse } = require('../../utils/ListResponse.js');
const { PaginationParam } = require('../../utils/PaginationParams.js');
const { errorResponse, successResponse, messageSuccessResponse } = require('../../utils/Response.js');

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

        const { vendors, total } = await vendorService.getAllVendorService({
            page, limit, search, sortBy, orderBy
        }, req);

        return ListResponse({ req, res, data: vendors, page, limit, total, message: 'Vendor data sales successfully retrieved' });
    } catch (err) {
        return errorResponse(res, err);
    }
};

// exports.showVendor = async (req, res) => {
//     try {
//         const id = req.params.id;
//         const data = await vendorService.showVendorService(id);
//         return successResponse(res, data, 'Success show vendor');
//     } catch (err) {
//         return errorResponse(res, err);
//     }
// };

// exports.storeVendor = async (req, res) => {
//     try {
//         const validatedData = validateStoreVendorRequest(req.body);
//         await vendorService.storeVendorService(validatedData, req);
//         return messageSuccessResponse(res, 'Success added vendor', 201);
//     } catch (err) {
//         return errorResponse(res, err);
//     }
// }

// exports.updateVendor = async (req, res) => {
//     try {
//         const id = req.params.id;
//         const validatedData = validateStoreVendorRequest(req.body);
//         await vendorService.updateVendorService(validatedData, id, req);
//         return messageSuccessResponse(res, 'Success update vendor');
//     } catch (err) {
//         return errorResponse(res, err);
//     }
// }

// exports.deleteVendor = async (req, res) => {
//     try {
//         const id = req.params.id;
//         await vendorService.deleteVendorService(id, req);
//         return messageSuccessResponse(res, 'Success delete vendor');
//     } catch (err) {
//         return errorResponse(res, err);
//     }
// };