import { AXPSessionService } from '@acorex/platform/auth';
import { AXPEntityDefinitionRegistryService } from '@acorex/platform/layout/entity';
import * as i0 from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { Router } from '@angular/router';

class AXPShowProfileCommand {
    constructor() {
        this.entityService = inject(AXPEntityDefinitionRegistryService);
        this.sessionService = inject(AXPSessionService);
        this.router = inject(Router);
    }
    async execute(input) {
        try {
            const user = this.sessionService.user;
            const application = this.sessionService.application;
            const entity = await this.entityService.resolve('HumanCapitalManagement', 'Employee');
            const listQuery = entity.queries.list?.execute;
            const result = await listQuery({
                filter: {
                    field: 'userId',
                    operator: {
                        type: 'equal',
                    },
                    value: user?.id,
                },
                take: 1,
                skip: 0,
            });
            const employeeId = result.items[0]?.id;
            if (employeeId) {
                this.router.navigate([`/${application?.name}/m/HumanCapitalManagement/e/Employee`, employeeId, 'new-view']);
            }
            else {
                throw new Error('Employee not found');
            }
        }
        catch (error) {
            console.error(error);
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPShowProfileCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPShowProfileCommand, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPShowProfileCommand, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

export { AXPShowProfileCommand };
//# sourceMappingURL=acorex-modules-auth-show-profile-command-BxzGxvJt.mjs.map
