import { BaseGroupingRenderer, IGroupingRendererConfig } from '../../core/BaseGroupingRenderer';
import { DepartmentService } from '../../storage/departments/DepartmentService';
import { IDepartment } from '../../types/CalendarTypes';

export class DepartmentRenderer extends BaseGroupingRenderer<IDepartment> {
  readonly type = 'department';

  protected readonly config: IGroupingRendererConfig = {
    elementTag: 'swp-department-header',
    idAttribute: 'departmentId',
    colspanVar: '--department-cols'
  };

  constructor(private departmentService: DepartmentService) {
    super();
  }

  protected getEntities(ids: string[]): Promise<IDepartment[]> {
    return this.departmentService.getByIds(ids);
  }

  protected getDisplayName(entity: IDepartment): string {
    return entity.name;
  }
}
