import { Routes } from '@angular/router';

import {
    AeronefsComponent, CalculatorComponent, CanopiesComponent, CredentialsComponent,
    HerowarsComponent, HerowarsGuildraidComponent, HerowarsGuildwarComponent,
    DashboardComponent, DemoComponent, DropzonesComponent, JumpComponent, JumpsComponent,
    LogbookComponent, PageComponent, PagesComponent, ProductComponent, ProductsComponent, ProfileComponent, QcmComponent, SettingsComponent
} from '@components';
import { authGuard, adminGuard } from '@guards';
import {
    aeronefsPageResolver, articleResolver, articlesResolver, authResolver, canopiesPageResolver, dropZonesPageResolver,
    jumpResolver, jumpsPageResolver, lastjumpResolver, productResolver, productsResolver, profileResolver, qcmResolver
} from '@resolvers';

export const AUTH_ROUTES: Routes = [
    {
        path: 'aeronefs',
        component: AeronefsComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            aeronefsPageData: aeronefsPageResolver
        }
    },
    {
        path: 'calculator',
        component: CalculatorComponent,
        canActivate: [ authGuard ],
        resolve: {
            isAuthenticated: authResolver
        }
    },
    {
        path: 'canopies',
        component: CanopiesComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            canopiesPageData: canopiesPageResolver
        }
    },
    {
        path: 'dashboard',
        component: DashboardComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            isAuthenticated: authResolver
        }
    },
    {
        path: 'demo',
        component: DemoComponent,
        canActivate: [ authGuard ]
    },
    {
        path: 'dropzones',
        component: DropzonesComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            dropZonesPageData: dropZonesPageResolver
        }
    },
    {
        path: 'herowars',
        component: HerowarsComponent,
        canActivate: [ authGuard ]
    },
    {
        path: 'herowars/guildwar',
        component: HerowarsGuildwarComponent,
        canActivate: [ authGuard ]
    },
    {
        path: 'herowars/guildraid',
        component: HerowarsGuildraidComponent,
        canActivate: [ authGuard ]
    },
    {
        path: 'jumps',
        component: JumpsComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            pageData: jumpsPageResolver
        }
    },
    {
        path: 'jump/:slug',
        component: JumpComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            pageData: jumpResolver
        }
    },
    {
        path: 'logbook',
        component: LogbookComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            isAuthenticated: authResolver,
            lastjump: lastjumpResolver
        }
    },
    {
        path: 'page/:slug',
        component: PageComponent,
        canActivate: [ authGuard ],
        resolve: {
            pageData: articleResolver
        }
    },
    {
        path: 'pages',
        component: PagesComponent,
        canActivate: [ authGuard ],
        resolve: {
            pageData: articlesResolver
        }
    },
    {
        path: 'product/:slug',
        component: ProductComponent,
        canActivate: [ authGuard ],
        resolve: {
            pageData: productResolver
        }
    },
    {
        path: 'products/:category',
        component: ProductsComponent,
        canActivate: [ authGuard ],
        resolve: {
            pageData: productsResolver
        }
    },
    {
        path: 'products',
        component: ProductsComponent,
        canActivate: [ authGuard ],
        resolve: {
            pageData: productsResolver
        }
    },
    {
        path: 'profile',
        component: ProfileComponent,
        canActivate: [ authGuard ],
        children: [
            {
                path: ':username',
                component: ProfileComponent,
                canActivate: [ authGuard ],
                resolve: {
                    profile: profileResolver
                }
            }
        ]
    },
    {
        path: 'qcm/:type',
        component: QcmComponent,
        canActivate: [ authGuard ],
        resolve: {
            qcm: qcmResolver
        }
    },
    {
        path: 'settings',
        component: SettingsComponent,
        canActivate: [ authGuard ]
    },
    {
        path: 'settings/credentials',
        component: CredentialsComponent,
        canActivate: [ authGuard ]
    }
];