import { Injectable } from '@angular/core';
import { TableColumnConfig } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { PermissionsMapping } from '@red/domain';
import { PermissionsConfigurationMapService } from '@services/entity-permissions/permissions-configuration-map.service';
import { permissionsTranslations } from '@translations/permissions-translations';

@Injectable()
export class ConfigService {
    constructor(private readonly _permissionsConfigurationMapService: PermissionsConfigurationMapService) {}

    tableConfig(targetObject: string): TableColumnConfig<PermissionsMapping>[] {
        const columns = this._permissionsConfigurationMapService.getMappedPermissions(targetObject).map(p => ({
            label: permissionsTranslations.mapped[p],
            class: 'flex-center',
        }));

        return [{ label: _('permissions-screen.table-col-names.permission') }, ...columns];
    }
}
