"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateScheduleJob = void 0;
const logger_1 = __importDefault(require("../../../logger"));
const scheduleJobsService_1 = require("../../services/scheduleJobsService");
const updateScheduleJob = async (req, res) => {
    try {
        const { scheduleJobId } = req.params;
        const { startDate, runTime, timeZone, repeatEvery, repeatUnit, repeatOnDays, endsOn, endsDate, endsAfter, status, projectId, } = req.body;
        if (!scheduleJobId || !projectId) {
            res.status(400).json({
                success: false,
                message: 'Missing required parameters: scheduleJobId, projectId',
            });
            return;
        }
        const updatedJob = await scheduleJobsService_1.scheduleJobsService.updateScheduleJob(scheduleJobId, projectId, {
            startDate,
            runTime,
            timeZone,
            repeatEvery,
            repeatUnit,
            repeatOnDays,
            endsOn,
            endsDate,
            endsAfter,
            status,
        });
        if (!updatedJob) {
            res.status(404).json({
                success: false,
                message: 'Schedule job not found',
            });
            return;
        }
        res.json({
            success: true,
            data: updatedJob,
        });
    }
    catch (error) {
        logger_1.default.error(`Error updating schedule job: ${error}`);
        res.status(500).json({
            success: false,
            message: 'Failed to update schedule job',
            error: error.message,
        });
    }
};
exports.updateScheduleJob = updateScheduleJob;
//# sourceMappingURL=update-schedule-job.js.map