"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.archiveApplication = void 0;
const drizzle_orm_1 = require("drizzle-orm");
const database_1 = require("../../../database");
const tables_1 = require("../../../database/tables");
const logger_1 = __importDefault(require("../../../logger"));
const archiveApplication = async (req, res) => {
    try {
        const { applicationId } = req.params;
        const db = await (0, database_1.getDb)();
        console.log('applicationId', applicationId);
        const [result] = await db
            .update(tables_1.applicationsTable)
            .set({
            is_archived: true,
            updatedAt: new Date()
        })
            .where((0, drizzle_orm_1.eq)(tables_1.applicationsTable.id, applicationId))
            .returning({
            id: tables_1.applicationsTable.id,
            is_archived: tables_1.applicationsTable.is_archived,
        });
        if (!result) {
            res.status(404).json({
                success: false,
                message: 'Application not found',
            });
            return;
        }
        logger_1.default.info(`Archived application ${applicationId}`);
        res.json({
            success: true,
            message: 'Application archived successfully',
            data: {},
        });
    }
    catch (error) {
        logger_1.default.error(`Error archiving application: ${error}`);
        res.status(500).json({
            success: false,
            message: 'Failed to archive application',
        });
    }
};
exports.archiveApplication = archiveApplication;
//# sourceMappingURL=archive-application.js.map