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

import { NegocioComponent } from './negocio/negocio.component';
import { NewUserComponent } from './new-user/new-user.component';
import { EditUserComponent } from './edit-user/edit-user.component';
import { SellerQuotesComponent } from './seller-quotes/seller-quotes.component';
import { AdminComponent } from './admin/index';
import { HomeComponent } from './home/index';
import { LoginComponent } from './login/index';
import { AuthGuard } from './_guards/index';
import { PricesComponent } from './prices/prices.component';
import { QuoteDetailComponent } from './quote-detail/quote-detail.component';
import { SellerQuotesDetailComponent } from './seller-quotes-detail/seller-quotes-detail.component';

const appRoutes: Routes = [
    { path: 'login', component: LoginComponent },
    { path: 'admin', component: AdminComponent, canActivate: [AuthGuard],
        children: [
            { path: 'users', component: HomeComponent},
            { path: 'negocio', component: NegocioComponent},
            { path: 'cotizaciones', component: PricesComponent},
            { path: 'quote/:id', component: QuoteDetailComponent},
            { path: 'users/create', component: NewUserComponent},
            { path: 'users/edit/:id', component: EditUserComponent},
            { path: 'seller/quotes', component: SellerQuotesComponent},
            { path: 'seller/quotes/:id', component: SellerQuotesDetailComponent}
        ]
    },

    // Otherwise redirect to home
    { path: '**', redirectTo: 'admin/cotizaciones' }
];

export const routing = RouterModule.forRoot(appRoutes, { useHash: true });