"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.ConfigurationsController = void 0;
const common_1 = require("@nestjs/common");
const permission_request_util_1 = require("../../common/access-control/permission-request.util");
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 configurations_dto_1 = require("./configurations.dto");
const configurations_service_1 = require("./configurations.service");
let ConfigurationsController = class ConfigurationsController {
    constructor(configurationsService) {
        this.configurationsService = configurationsService;
    }
    async createDefaultConfiguration(owner_id, res) {
        await this.configurationsService.createDefaultConfiguration(owner_id);
        return res.status(common_1.HttpStatus.CREATED).json({
            data: null,
            message: 'Default configuration created successfully',
            status: common_1.HttpStatus.CREATED,
            details: null,
        });
    }
    async getCompanyInfo(owner_id, req, res) {
        const result = await this.configurationsService.getCompanyInfo(owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async getWorkSchedule(owner_id, req, res) {
        const result = await this.configurationsService.getWorkSchedule(owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async getLeavePolicy(owner_id, req, res) {
        const result = await this.configurationsService.getLeavePolicy(owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async updateCompanyInfo(id, owner_id, data, req, res) {
        const result = await this.configurationsService.updateCompanyInfo(id, owner_id, data, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async updateWorkSchedule(id, owner_id, data, req, res) {
        const result = await this.configurationsService.updateWorkSchedule(id, owner_id, data, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async updateLeavePolicy(id, owner_id, data, req, res) {
        const result = await this.configurationsService.updateLeavePolicy(id, owner_id, data, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async getWorkDaySchedules(owner_id, req, res) {
        const result = await this.configurationsService.getWorkDaySchedules(owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async updateWorkDaySchedules(owner_id, body, req, res) {
        const result = await this.configurationsService.updateWorkDaySchedules(owner_id, body, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async getAttendanceValidationSettings(owner_id, req, res) {
        const result = await this.configurationsService.getAttendanceValidationSettings(owner_id, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async updateAttendanceValidationSettings(owner_id, body, req, res) {
        const result = await this.configurationsService.updateAttendanceValidationSettings(owner_id, body, (0, permission_request_util_1.getPermissionContext)(req.user));
        return res.status(common_1.HttpStatus.OK).json(result);
    }
};
exports.ConfigurationsController = ConfigurationsController;
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Post)('create-default'),
    __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)
], ConfigurationsController.prototype, "createDefaultConfiguration", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('company-info'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Req)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, Object]),
    __metadata("design:returntype", Promise)
], ConfigurationsController.prototype, "getCompanyInfo", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('work-schedule'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Req)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, Object]),
    __metadata("design:returntype", Promise)
], ConfigurationsController.prototype, "getWorkSchedule", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('leave-policy'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Req)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, Object]),
    __metadata("design:returntype", Promise)
], ConfigurationsController.prototype, "getLeavePolicy", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(configurations_dto_1.updateCompanyInfoSchema)),
    (0, common_1.Patch)('company-info/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Body)()),
    __param(3, (0, common_1.Req)()),
    __param(4, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object, Object, Object]),
    __metadata("design:returntype", Promise)
], ConfigurationsController.prototype, "updateCompanyInfo", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(configurations_dto_1.updateWorkScheduleSchema)),
    (0, common_1.Patch)('work-schedule/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Body)()),
    __param(3, (0, common_1.Req)()),
    __param(4, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object, Object, Object]),
    __metadata("design:returntype", Promise)
], ConfigurationsController.prototype, "updateWorkSchedule", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(configurations_dto_1.updataLeavePolicySchema)),
    (0, common_1.Patch)('leave-policy/:id'),
    __param(0, (0, common_1.Param)('id')),
    __param(1, (0, current_user_decorator_1.CurrentUser)()),
    __param(2, (0, common_1.Body)()),
    __param(3, (0, common_1.Req)()),
    __param(4, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String, Object, Object, Object]),
    __metadata("design:returntype", Promise)
], ConfigurationsController.prototype, "updateLeavePolicy", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('work-day-schedules'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Req)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, Object]),
    __metadata("design:returntype", Promise)
], ConfigurationsController.prototype, "getWorkDaySchedules", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Patch)('work-day-schedules'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, Object, Object]),
    __metadata("design:returntype", Promise)
], ConfigurationsController.prototype, "updateWorkDaySchedules", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('attendance-validation'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Req)()),
    __param(2, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, Object]),
    __metadata("design:returntype", Promise)
], ConfigurationsController.prototype, "getAttendanceValidationSettings", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(configurations_dto_1.updateAttendanceValidationSettingsSchema)),
    (0, common_1.Patch)('attendance-validation'),
    __param(0, (0, current_user_decorator_1.CurrentUser)()),
    __param(1, (0, common_1.Body)()),
    __param(2, (0, common_1.Req)()),
    __param(3, (0, common_1.Res)()),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, Object, Object, Object]),
    __metadata("design:returntype", Promise)
], ConfigurationsController.prototype, "updateAttendanceValidationSettings", null);
exports.ConfigurationsController = ConfigurationsController = __decorate([
    (0, common_1.Controller)('configurations'),
    __metadata("design:paramtypes", [configurations_service_1.ConfigurationsService])
], ConfigurationsController);
//# sourceMappingURL=configurations.controller.js.map