const { formatISOWithoutTimezone, formatDateOnly } = require("../../../utils/FormatDate");

const formatItem = (item) => ({
    ...item,
    contract_date: formatDateOnly(item.contract_date),
    contract_expired_date: formatDateOnly(item.contract_expired_date),
    createdAt: formatISOWithoutTimezone(item.createdAt),
    updatedAt: formatISOWithoutTimezone(item.updatedAt),
});

exports.VendorHistoriResource = (res, data, message = 'Success') => {
    const formattedData = formatItem(data);

    return res.status(200).json({
        success: true,
        message,
        data: formattedData
    });
};