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: 'demo',
        component: DemoComponent,
        canActivate: [ authGuard ]
    },
    {
        path: 'herowars',
        component: HerowarsComponent,
        canActivate: [ authGuard ]
    },
    {
        path: 'herowars/guildwar',
        component: HerowarsGuildwarComponent,
        canActivate: [ authGuard ]
    },
    {
        path: 'herowars/guildraid',
        component: HerowarsGuildraidComponent,
        canActivate: [ authGuard ]
    },
    {
        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 ]
    },
    {
        path: 'skydive',
        component: DemoComponent,
        canActivate: [ authGuard ]
    },
    {
        path: 'skydive/aeronefs',
        component: AeronefsComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            aeronefsPageData: aeronefsPageResolver
        }
    },
    {
        path: 'skydive/calculator',
        component: CalculatorComponent,
        canActivate: [ authGuard ],
        resolve: {
            isAuthenticated: authResolver
        }
    },
    {
        path: 'skydive/canopies',
        component: CanopiesComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            canopiesPageData: canopiesPageResolver
        }
    },
    {
        path: 'skydive/dashboard',
        component: DashboardComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            isAuthenticated: authResolver
        }
    },
    {
        path: 'skydive/dropzones',
        component: DropzonesComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            dropZonesPageData: dropZonesPageResolver
        }
    },
    {
        path: 'skydive/jumps',
        component: JumpsComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            pageData: jumpsPageResolver
        }
    },
    {
        path: 'skydive/jump/:slug',
        component: JumpComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            pageData: jumpResolver
        }
    },
    {
        path: 'skydive/logbook',
        component: LogbookComponent,
        canActivate: [ authGuard, adminGuard ],
        resolve: {
            isAuthenticated: authResolver,
            lastjump: lastjumpResolver
        }
    }
];