import { NgModule } from '@angular/core'
import { Routes, RouterModule } from '@angular/router'

import { AdminComponent } from './admin.component'
import { AdminAccessComponent } from './admin-manage/access/users-roles.component'
import { AdminListComponent } from './admin-list/admin-list.component'
import { AdminDetailComponent } from './admin-detail/admin-detail.component'
import { AdminBasketComponent } from './admin-basket/basket.component'
import { AdminPointsByOrigIdComponent } from './admin-manage/points-by-orig-id/points-by-orig-id.component'
import { AdminResolver } from './admin-resolver.service'
import { DetailResolver } from './admin-detail/admin-detail-resolver.service'
import { BasketResolver } from './admin-basket/admin-basket-resolver.service'
import { CategoryComponent } from './admin-manage/category/category.component'
import { CategoryResolver } from './admin-manage/category/category-resolver.service'
import { ProjectComponent } from './admin-manage/project/project.component'
import { ProjectResolver } from './admin-manage/project/project-resolver.service'
import { AdminIntegrityComponent } from './admin-manage/integrity/integrity.component'
import { AdminMaintenanceComponent } from './admin-manage/maintenance/maintenance.component'
import { AdminSchedulerJobsComponent } from './admin-scheduler/jobs.component'
import { AdminSchedulerMessagesComponent } from './admin-scheduler/messages.component'

const routes: Routes = [
    {
        path: '',
        component: AdminComponent,
        children: [
            {
                path: 'basket/:name',
                component: AdminBasketComponent,
                resolve: {
                    basket: BasketResolver,
                },
                data: {

                }
            },
            {
                path: 'manage/access',
                component: AdminAccessComponent,
            },
            {
                path: 'survey/categories',
                component: CategoryComponent,
                resolve: {
                    categories: CategoryResolver
                }
            },
            {
                path: 'scheduler/jobs',
                component: AdminSchedulerJobsComponent,
            },
            {
                path: 'scheduler/messages',
                component: AdminSchedulerMessagesComponent,
            },
            {
                path: 'manage/projects',
                component: ProjectComponent,
                resolve: {
                    projects: ProjectResolver
                }
            },
            {
                path: 'manage/integrity',
                component: AdminIntegrityComponent,
            },
            {
                path: 'manage/maintenance',
                component: AdminMaintenanceComponent,
            },
            {
                path: 'manage/points-by-orig-id',
                component: AdminPointsByOrigIdComponent,
            },
            {
                path: 'model/:modelName',
                component: AdminListComponent,
            },
            {
                path: 'model/:modelName/:pk',
                component: AdminDetailComponent,
                resolve: {
                    item: DetailResolver
                }
            },
        ],
        resolve: {
            item: AdminResolver
        }
    }
]

@NgModule({
    imports: [RouterModule.forChild(routes)],
    exports: [RouterModule],
    providers: [
        AdminResolver,
        //AdminAccessResolver,
        BasketResolver,
        CategoryResolver,
        ProjectResolver,
        DetailResolver,
    ]
})
export class AdminRoutingModule { }
