import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ComponentsTestComponent } from './components/components-test/components-test.component';
import { MainLayoutComponent } from './components/main-layout/main-layout.component';
import { DashboardComponent } from './components/main-layout/dashboard/dashboard.component';
import { BoxCalendarComponent } from './components/main-layout/box-calendar/box-calendar.component';
import { SubscriptionsComponent } from './components/main-layout/subscriptions/subscriptions.component';
import { WorkoutsComponent } from './components/main-layout/workouts/workouts.component';
import { BillingComponent } from './components/main-layout/billing/billing.component';
import { AuthComponent } from './components/auth/auth.component';
import { StartComponent } from './components/start/start.component';
import { RegisterLayoutComponent } from './components/register-layout/register-layout.component';
import { MyBusinessComponent } from './components/register-layout/my-business/my-business.component';
import { MyUserComponent } from './components/register-layout/my-user/my-user.component';
import { MyBoxComponent } from './components/register-layout/my-box/my-box.component';
import { MySubscriptionComponent } from './components/register-layout/my-subscription/my-subscription.component';
import { ForgotPasswordComponent } from './components/auth/forgot-password/forgot-password.component';
import { LoginComponent } from './components/auth/login/login.component';
import { ChangePasswordComponent } from './components/auth/change-password/change-password.component';
import { NewsComponent } from './components/main-layout/news/news.component';
import { BusinessComponent } from './components/main-layout/business/business.component';
import { DashboardGuard } from './guards/dashboard.guard';
import { SubscriptionDetailComponent } from './components/main-layout/subscriptions/subscription-detail/subscription-detail.component';
import { BillingDetailComponent } from './components/main-layout/billing/billing-detail/billing-detail.component';
import { WorkoutDetailComponent } from './components/main-layout/workouts/workout-detail/workout-detail.component';
import { BusinessHistoryRenewalsComponent } from './components/main-layout/business/business-history-renewals/business-history-renewals.component';
import { TrainingRoomsComponent } from './components/main-layout/training-rooms/training-rooms.component';
import { LegalComponent } from './components/public/legal/legal.component';


const routes: Routes = [
  { 
    path: 'admin',
    component: MainLayoutComponent,
    canActivate: [ DashboardGuard ],
    children: [
      { path: 'dashboard', component: DashboardComponent, data: { title: 'Dashboard' }},
      { path: 'calendar', component: BoxCalendarComponent, data: { title: 'Calendario' }},
      { path: 'news', component: NewsComponent, data: { title: 'Noticias' }},
      { path: 'subscriptions', component: SubscriptionsComponent, data: { title: 'Suscripciones' }},
      { path: 'subscriptions/:id', component: SubscriptionDetailComponent, data: { title: 'Editar Suscripción' }},
      { path: 'workouts', component: WorkoutsComponent, data: { title: 'Workouts' }},
      { path: 'workouts/detail', component: WorkoutDetailComponent, data: { title: 'Crear - Editar Workout' }},
      { path: 'training-rooms', component: TrainingRoomsComponent, data: { title: 'Salas de entrenamiento' }},
      { path: 'billing', component: BillingComponent, data: { title: 'Facturación' }},
      { path: 'billing/:orderId', component: BillingDetailComponent, data: { title: 'Detalle del pedido' }},
      { path: 'business', component: BusinessComponent, data: { title: 'Mi negocio' }},
      { path: 'business/history', component: BusinessHistoryRenewalsComponent, data: { title: 'Historial de renovaciones' }},
      { path: '**', pathMatch: 'full', redirectTo: 'dashboard' }
    ]
  },
  { 
    path: 'auth', 
    component: AuthComponent,
    children: [
      { path: 'login', component: LoginComponent, data: { title: 'Login' } },
      { path: 'forgot-password', component: ForgotPasswordComponent, data: { title: '¿Has olvidado tu contraseña?' } },
      { path: 'change-password', component: ChangePasswordComponent, data: { title: 'Restablece tu contraseña' } },
      { path: '**', pathMatch: 'full', redirectTo: 'login' }
    ]
  },
  { path: 'start', component: StartComponent, data: { title: 'Empieza a usar Hit a Wod' }},
  {
    path: 'register',
    component: RegisterLayoutComponent,
    children: [
      { path: 'business', component: MyBusinessComponent, data: {  title: 'Registro - Mi negocio' } },
      { path: 'user', component: MyUserComponent, data: {  title: 'Registro - Mi usuario' } },
      { path: 'box', component: MyBoxComponent, data: {  title: 'Registro - Mi box' } },
      { path: 'subscription', component: MySubscriptionComponent, data: {  title: 'Registro - Mi box' } },
      { path: '**', pathMatch: 'full', redirectTo: 'business' }
    ]
  },
  { path: 'components', component: ComponentsTestComponent },
  { path: 'politica-de-privacidad', component: LegalComponent, data: {  title: 'Aviso Legal y Privacidad' } },
  { path: '**', pathMatch: 'full', redirectTo: 'admin' }
];

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