"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.ProbationController = 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 probation_dto_1 = require("./probation.dto");
const probation_service_1 = require("./probation.service");
let ProbationController = class ProbationController {
    constructor(service) {
        this.service = service;
    }
    async createProbation(data, owner_id, res) {
        const result = await this.service.createProbation(data, owner_id);
        return res.status(common_1.HttpStatus.CREATED).json(result);
    }
    async getProbationsByFilter(query, owner_id, res) {
        const result = await this.service.getProbationsByFilter(query, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async getProbationById(id, owner_id, res) {
        const result = await this.service.getProbationById(id, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async reviewProbation(id, data, owner_id, req, res) {
        const reviewerId = req.user?.sub || req.user?.id;
        const result = await this.service.reviewProbation(id, data, reviewerId, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
};
exports.ProbationController = ProbationController;
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(probation_dto_1.createProbationSchema)),
    (0, common_1.Post)(),
    __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)
], ProbationController.prototype, "createProbation", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(probation_dto_1.filterProbationSchema)),
    (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)
], ProbationController.prototype, "getProbationsByFilter", 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)
], ProbationController.prototype, "getProbationById", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(probation_dto_1.reviewProbationSchema)),
    (0, common_1.Post)(':id/review'),
    __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.Req)()),
    __param(4, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, String, Object, Object]),
    __metadata("design:returntype", Promise)
], ProbationController.prototype, "reviewProbation", null);
exports.ProbationController = ProbationController = __decorate([
    (0, common_1.Controller)('probation'),
    __metadata("design:paramtypes", [probation_service_1.ProbationService])
], ProbationController);
//# sourceMappingURL=probation.controller.js.map