"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.OnboardingController = 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 onboarding_dto_1 = require("./onboarding.dto");
const onboarding_service_1 = require("./onboarding.service");
let OnboardingController = class OnboardingController {
    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 resetDefaultTemplates(owner_id, res) {
        const result = await this.service.resetDefaultTemplates(owner_id);
        return res.status(common_1.HttpStatus.OK).json({
            data: result,
            status: common_1.HttpStatus.OK,
            message: 'Default onboarding templates reset and seeded successfully',
        });
    }
    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 updateTemplate(id, data, owner_id, res) {
        const result = await this.service.updateTemplate(id, data, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async deleteTemplate(id, owner_id, res) {
        const result = await this.service.deleteTemplate(id, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async setDefaultTemplate(id, owner_id, res) {
        const result = await this.service.setDefaultTemplate(id, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async getDashboardStats(owner_id, res) {
        const result = await this.service.getDashboardStats(owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async getMyPortal(req, owner_id, res) {
        const memberId = req.user?.sub || req.user?.id;
        const result = await this.service.getMyWelcomePortal(memberId, owner_id);
        return res.status(common_1.HttpStatus.OK).json({
            data: result,
            status: common_1.HttpStatus.OK,
            message: 'My onboarding portal retrieved successfully',
        });
    }
    async getMyWelcomePortal(req, owner_id, res) {
        const memberId = req.user?.sub || req.user?.id;
        const result = await this.service.getMyWelcomePortal(memberId, owner_id);
        return res.status(common_1.HttpStatus.OK).json({
            data: result,
            status: common_1.HttpStatus.OK,
            message: 'Welcome portal retrieved successfully',
        });
    }
    async createCase(data, owner_id, res) {
        const result = await this.service.createCase(data, owner_id);
        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 deleteCase(id, owner_id, res) {
        const result = await this.service.deleteCase(id, owner_id);
        return res.status(common_1.HttpStatus.OK).json({
            data: result,
            status: common_1.HttpStatus.OK,
            message: 'Onboarding case deleted successfully',
        });
    }
    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 signDocument(documentId, data, owner_id, req, res) {
        const memberId = req.user?.sub || req.user?.id;
        const result = await this.service.signDocument(documentId, data, memberId, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async addProvisioningItem(caseId, data, owner_id, res) {
        const result = await this.service.addProvisioningItem(caseId, data, owner_id);
        return res.status(common_1.HttpStatus.CREATED).json(result);
    }
    async updateProvisioningItem(itemId, data, owner_id, res) {
        const result = await this.service.updateProvisioningItem(itemId, data, owner_id);
        return res.status(common_1.HttpStatus.OK).json(result);
    }
    async assignBuddy(caseId, data, owner_id, req, res) {
        const memberId = req.user?.sub || req.user?.id;
        const result = await this.service.assignBuddy(caseId, data, memberId, owner_id);
        return res.status(common_1.HttpStatus.CREATED).json(result);
    }
};
exports.OnboardingController = OnboardingController;
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(onboarding_dto_1.createOnboardingTemplateSchema)),
    (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)
], OnboardingController.prototype, "createTemplate", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Post)('templates/reset-defaults'),
    __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)
], OnboardingController.prototype, "resetDefaultTemplates", 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)
], OnboardingController.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)
], OnboardingController.prototype, "getTemplateById", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(onboarding_dto_1.updateOnboardingTemplateSchema)),
    (0, common_1.Patch)('templates/: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)
], OnboardingController.prototype, "updateTemplate", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Delete)('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)
], OnboardingController.prototype, "deleteTemplate", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Patch)('templates/:id/set-default'),
    __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)
], OnboardingController.prototype, "setDefaultTemplate", 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)
], OnboardingController.prototype, "getDashboardStats", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('my-portal'),
    __param(0, (0, common_1.Req)()),
    __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)
], OnboardingController.prototype, "getMyPortal", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Get)('me/welcome'),
    __param(0, (0, common_1.Req)()),
    __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)
], OnboardingController.prototype, "getMyWelcomePortal", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(onboarding_dto_1.createOnboardingCaseSchema)),
    (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)
], OnboardingController.prototype, "createCase", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(onboarding_dto_1.filterOnboardingCaseSchema)),
    (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)
], OnboardingController.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)
], OnboardingController.prototype, "getCaseById", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(onboarding_dto_1.updateOnboardingCaseSchema)),
    (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)
], OnboardingController.prototype, "updateCase", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.Delete)(':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)
], OnboardingController.prototype, "deleteCase", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(onboarding_dto_1.createOnboardingTaskSchema)),
    (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)
], OnboardingController.prototype, "addTask", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(onboarding_dto_1.updateOnboardingTaskSchema)),
    (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)
], OnboardingController.prototype, "updateTask", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(onboarding_dto_1.signOnboardingDocumentSchema)),
    (0, common_1.Post)('documents/:documentId/sign'),
    __param(0, (0, common_1.Param)('documentId')),
    __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)
], OnboardingController.prototype, "signDocument", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(onboarding_dto_1.createProvisioningItemSchema)),
    (0, common_1.Post)(':id/provisioning'),
    __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)
], OnboardingController.prototype, "addProvisioningItem", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(onboarding_dto_1.updateProvisioningItemSchema)),
    (0, common_1.Patch)('provisioning/:itemId'),
    __param(0, (0, common_1.Param)('itemId')),
    __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)
], OnboardingController.prototype, "updateProvisioningItem", null);
__decorate([
    (0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
    (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(onboarding_dto_1.assignBuddySchema)),
    (0, common_1.Post)(':id/buddy'),
    __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)
], OnboardingController.prototype, "assignBuddy", null);
exports.OnboardingController = OnboardingController = __decorate([
    (0, common_1.Controller)('onboarding'),
    __metadata("design:paramtypes", [onboarding_service_1.OnboardingService])
], OnboardingController);
//# sourceMappingURL=onboarding.controller.js.map