"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OffboardingController = void 0;
const common_1 = require("@nestjs/common");
const current_user_decorator_1 = require("../../common/decorators/current-user.decorator");
const zod_validation_pipe_1 = require("../../common/pipes/zod-validation.pipe");
const jwt_guard_1 = require("../owner/guards/jwt.guard");
const offboarding_dto_1 = require("./offboarding.dto");
const offboarding_service_1 = require("./offboarding.service");
let OffboardingController = class OffboardingController {
    constructor(service) {
        this.service = service;
    }
    async createTemplate(data, owner_id, res) {
        const result = await this.service.createTemplate(data, owner_id);
        return res.status(common_1.HttpStatus.CREATED).json(result);
    }
    async getTemplates(owner_id, res) {
        const result = await this.service.getTemplates(owner_id);
        return res.status(common_1.HttpStatus.OK).json({
            data: result,
            status: common_1.HttpStatus.OK,
            message: 'Templates retrieved successfully',
        });
    }
    async getTemplateById(id, owner_id, res) {
        const result = await this.service.getTemplateById(id, owner_id);
        return res.status(common_1.HttpStatus.OK).json({
            data: result,
            status: common_1.HttpStatus.OK,
            message: 'Template retrieved successfully',
        });
    }
    async getDashboardStats(owner_id, res) {
        const result = await this.service.getDashboardStats(owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async getTurnoverAnalytics(owner_id, res) {
        const result = await this.service.getTurnoverAnalytics(owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async createCase(data, owner_id, req, res) {
        const initiatedById = req.user?.sub || req.user?.id;
        const result = await this.service.createCase(data, owner_id, initiatedById);
        return res.status(common_1.HttpStatus.CREATED).json(result);
    }
    async getCasesByFilter(query, owner_id, res) {
        const result = await this.service.getCasesByFilter(query, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async getCaseById(id, owner_id, res) {
        const result = await this.service.getCaseById(id, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async updateCase(id, data, owner_id, res) {
        const result = await this.service.updateCase(id, data, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async addTask(caseId, data, owner_id, res) {
        const result = await this.service.addTask(caseId, data, owner_id);
        return res.status(common_1.HttpStatus.CREATED).json(result);
    }
    async updateTask(taskId, data, owner_id, req, res) {
        const memberId = req.user?.sub || req.user?.id;
        const result = await this.service.updateTask(taskId, data, owner_id, memberId);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async addEquipmentReturn(caseId, data, owner_id, res) {
        const result = await this.service.addEquipmentReturn(caseId, data, owner_id);
        return res.status(common_1.HttpStatus.CREATED).json(result);
    }
    async updateEquipmentReturn(returnId, data, owner_id, req, res) {
        const receiverId = req.user?.sub || req.user?.id;
        const result = await this.service.updateEquipmentReturn(returnId, data, owner_id, receiverId);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async createExitTemplate(data, owner_id, res) {
        const result = await this.service.createExitTemplate(data, owner_id);
        return res.status(common_1.HttpStatus.CREATED).json(result);
    }
    async getExitTemplates(owner_id, res) {
        const result = await this.service.getExitTemplates(owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async submitExitInterview(caseId, data, owner_id, res) {
        const result = await this.service.submitExitInterview(caseId, data, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async calculateFinalSettlement(caseId, data, owner_id, res) {
        const result = await this.service.calculateFinalSettlement(caseId, data, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async approveFinalSettlement(settlementId, owner_id, req, res) {
        const approverId = req.user?.sub || req.user?.id;
        const result = await this.service.approveFinalSettlement(settlementId, owner_id, approverId);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
};
exports.OffboardingController = OffboardingController;
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(offboarding_dto_1.createOffboardingTemplateSchema)),
    (0, common_1.Post)('templates'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "createTemplate", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('templates'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "getTemplates", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('templates/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "getTemplateById", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('stats'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "getDashboardStats", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('analytics/turnover'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "getTurnoverAnalytics", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(offboarding_dto_1.createOffboardingCaseSchema)),
    (0, common_1.Post)(),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "createCase", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(offboarding_dto_1.filterOffboardingCaseSchema)),
    (0, common_1.Get)('filter'),
    __param(0, (0, common_1.Query)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "getCasesByFilter", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)(':id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "getCaseById", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(offboarding_dto_1.updateOffboardingCaseSchema)),
    (0, common_1.Patch)(':id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "updateCase", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(offboarding_dto_1.createOffboardingTaskSchema)),
    (0, common_1.Post)(':id/tasks'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "addTask", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(offboarding_dto_1.updateOffboardingTaskSchema)),
    (0, common_1.Patch)('tasks/:taskId'),
    __param(0, (0, common_1.Param)('taskId')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __param(3, (0, common_1.Req)()),
    __param(4, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "updateTask", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(offboarding_dto_1.addEquipmentReturnSchema)),
    (0, common_1.Post)(':id/equipment'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "addEquipmentReturn", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(offboarding_dto_1.updateEquipmentReturnSchema)),
    (0, common_1.Patch)('equipment/:returnId'),
    __param(0, (0, common_1.Param)('returnId')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __param(3, (0, common_1.Req)()),
    __param(4, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "updateEquipmentReturn", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(offboarding_dto_1.createExitInterviewTemplateSchema)),
    (0, common_1.Post)('exit-templates'),
    __param(0, (0, common_1.Body)()),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "createExitTemplate", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('exit-templates'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "getExitTemplates", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(offboarding_dto_1.submitExitInterviewSchema)),
    (0, common_1.Post)(':id/exit-interview'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "submitExitInterview", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(offboarding_dto_1.calculateFinalSettlementSchema)),
    (0, common_1.Post)(':id/final-settlement/calculate'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, current_user_decorator_1.CurrentUser)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "calculateFinalSettlement", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Post)('final-settlement/:settlementId/approve'),
    __param(0, (0, common_1.Param)('settlementId')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object, Object]),
    __metadata("design:returntype", Promise)
], OffboardingController.prototype, "approveFinalSettlement", null);
exports.OffboardingController = OffboardingController = __decorate([
    (0, common_1.Controller)('offboarding'),
    __metadata("design:paramtypes", [offboarding_service_1.OffboardingService])
], OffboardingController);
//# sourceMappingURL=offboarding.controller.js.map