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

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

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

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