import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { BreadcrumbTypes, DOSSIER_ID, FILE_ID } from '@red/domain';
import { ArchivedDossiersScreenComponent } from './screens/archived-dossiers-screen/archived-dossiers-screen.component';
import { CompositeRouteGuard } from '@iqser/common-ui';
import { ARCHIVED_DOSSIERS_SERVICE } from '../../tokens';
import { DossierFilesGuard } from '@guards/dossier-files-guard';

const routes: Routes = [
    {
        path: '',
        pathMatch: 'full',
        component: ArchivedDossiersScreenComponent,
        canActivate: [CompositeRouteGuard],
        data: {
            routeGuards: [DossierFilesGuard],
            breadcrumbs: [BreadcrumbTypes.dossierTemplate],
            reuse: true,
            dossiersService: ARCHIVED_DOSSIERS_SERVICE,
        },
    },
    {
        path: `:${DOSSIER_ID}`,
        canActivate: [CompositeRouteGuard],
        data: {
            routeGuards: [DossierFilesGuard],
            breadcrumbs: [BreadcrumbTypes.dossierTemplate, BreadcrumbTypes.dossier],
            dossiersService: ARCHIVED_DOSSIERS_SERVICE,
            skeleton: 'dossier',
        },
        loadChildren: () => import('../dossier-overview/dossier-overview.module').then(m => m.DossierOverviewModule),
    },
    {
        path: `:${DOSSIER_ID}/file/:${FILE_ID}`,
        canActivate: [CompositeRouteGuard],
        data: {
            routeGuards: [DossierFilesGuard],
            breadcrumbs: [BreadcrumbTypes.dossierTemplate, BreadcrumbTypes.dossier, BreadcrumbTypes.file],
            dossiersService: ARCHIVED_DOSSIERS_SERVICE,
        },
        loadChildren: () => import('../file-preview/file-preview.module').then(m => m.FilePreviewModule),
    },
];

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