import { Router } from 'express';
import { DataSource } from 'typeorm';
import { DashboardService } from './services';
import { DashboardController } from './controllers';

export interface DashboardModuleOptions {
  dataSource: DataSource;
  basePath?: string;
}

export class DashboardModule {
  public router: Router;
  public dashboardService: DashboardService;
  private dataSource: DataSource;
  private basePath: string;

  constructor(options: DashboardModuleOptions) {
    this.dataSource = options.dataSource;
    this.basePath = options.basePath || '';
    this.router = Router();
    this.initializeServices();
    this.initializeRoutes();
  }

  private initializeServices(): void {
    this.dashboardService = new DashboardService(this.dataSource);
  }

  private initializeRoutes(): void {
    const dashboardController = new DashboardController(this.dashboardService);
    this.router.use(`${this.basePath}/dashboard`, dashboardController.router);
  }

  // Dashboard module doesn't have its own entities - it uses data from other modules
  static getEntities(): Function[] {
    return [];
  }
}
