import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { Feature } from '@msfa-enums/feature.enum';
import { environment } from '@msfa-environment';

const activeFeatures: Feature[] = environment.activeFeatures;

const routes: Routes = [
  {
    path: '',
    data: { title: 'Deltagareinformation' },
    loadChildren: () => import('./pages/deltagare-card/deltagare-card.module').then(m => m.DeltagareCardModule),
  },
  {
    path: 'avvikelserapport',
    data: { title: 'Skapa Avvikelserapport (Avvikelse)' },
    loadChildren: () =>
      import('./pages/report-forms/avvikelse-report-form/avvikelse-report-form.module').then(
        m => m.AvvikelseReportFormModule
      ),
  },
  {
    path: 'avvikelserapport/:handlingId',
    data: { title: 'Avvikelserapport (avvikelse)' },
    loadChildren: () =>
      import('./pages/report-views/avvikelse-report-view/avvikelse-report-view.module').then(
        m => m.AvvikelseReportViewModule
      ),
  },
  {
    path: 'franvarorapport',
    data: { title: 'Skapa Avvikelserapport (frånvaro)' },
    loadChildren: () =>
      import('./pages/report-forms/franvaro-report-form/franvaro-report-form.module').then(
        m => m.FranvaroReportFormModule
      ),
  },
  {
    path: 'franvarorapport/:handlingId',
    data: { title: 'Avvikelserapport (frånvaro)' },
    loadChildren: () =>
      import('./pages/report-views/franvaro-report-view/franvaro-report-view.module').then(
        m => m.FranvaroReportViewModule
      ),
  },
  {
    path: 'gemensam-planering',
    data: { title: 'Skapa Gemensam planering' },
    loadChildren: () =>
      import('./pages/report-forms/gemensam-planering-form/gemensam-planering-form.module').then(
        m => m.GemensamPlaneringFormModule
      ),
  },
  {
    path: 'gemensam-planering/:handlingId',
    data: { title: 'Gemensam planering' },
    loadChildren: () =>
      import('./pages/report-views/gemensam-planering-view/gemensam-planering-view.module').then(
        m => m.GemensamPlaneringViewModule
      ),
  },
];

activeFeatures.forEach(feature => {
  switch (feature) {
    case Feature.REPORTING_PERIODISK_REDOVISNING:
      routes.push(
        {
          path: 'periodisk-redovisning',
          data: { title: 'Skapa Periodisk redovisning' },
          loadChildren: () =>
            import('./pages/report-forms/periodisk-redovisning-form/periodisk-redovisning-form.module').then(
              m => m.PeriodiskRedovisningFormModule
            ),
        },
        {
          path: 'periodisk-redovisning/:handlingId',
          data: { title: 'Periodisk redovisning' },
          loadChildren: () =>
            import('./pages/report-views/periodisk-redovisning-view/periodisk-redovisning-view.module').then(
              m => m.PeriodiskRedovisningViewModule
            ),
        }
      );
      break;
    case Feature.REPORTING_SIGNAL:
      routes.push(
        {
          path: 'signal',
          data: { title: 'Skapa signal om arbete eller studier' },
          loadChildren: () =>
            import('./pages/report-forms/signal-form/signal-form.module').then(m => m.SignalFormModule),
        },
        {
          path: 'signal/:handlingId',
          data: { title: 'Signal om arbete eller studier' },
          loadChildren: () =>
            import('./pages/report-views/signal-view/signal-view.module').then(m => m.SignalViewModule),
        }
      );
      break;
    case Feature.REPORTING_INFORMATIV_RAPPORT:
      routes.push(
        {
          path: 'informativ-rapport',
          data: { title: 'Skapa Informativ rapport' },
          loadChildren: () =>
            import('./pages/report-forms/informativ-rapport-form/informativ-rapport-form.module').then(
              m => m.InformativRapportFormModule
            ),
        },
        {
          path: 'informativ-rapport/:handlingId',
          data: { title: 'Informativ rapport' },
          loadChildren: () =>
            import('./pages/report-views/informativ-rapport-view/informativ-rapport-view.module').then(
              m => m.InformativRapportViewModule
            ),
        }
      );
      break;
    case Feature.REPORTING_SLUTREDOVISNING:
      routes.push(
        {
          path: 'slutredovisning',
          data: { title: 'Skapa slutredovisning' },
          loadChildren: () =>
            import('./pages/report-forms/slutredovisning-form/slutredovisning-form.module').then(
              m => m.SlutredovisningFormModule
            ),
        },
        {
          path: 'slutredovisning/:handlingId',
          data: { title: 'Slutredovisning' },
          loadChildren: () =>
            import('./pages/report-views/slutredovisning-view/slutredovisning-view.module').then(
              m => m.SlutredovisningViewModule
            ),
        }
      );
      break;
    default:
      break;
  }
});

@NgModule({
  imports: [RouterModule.forChild(routes)],
})
export class DeltagareDetailsModule {}
