import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {PartialsModule} from '../../partials/partials.module';
import {CoreModule} from '../../../core/core.module';
import {RouterModule} from '@angular/router';
import {
	MAT_DIALOG_DEFAULT_OPTIONS,
	MatAutocompleteModule,
	MatButtonModule,
	MatCardModule,
	MatCheckboxModule,
	MatDatepickerModule,
	MatDialogModule,
	MatExpansionModule,
	MatFormFieldModule,
	MatIconModule,
	MatInputModule,
	MatMenuModule,
	MatNativeDateModule,
	MatPaginatorModule,
	MatProgressBarModule,
	MatProgressSpinnerModule,
	MatRadioModule,
	MatSelectModule,
	MatSnackBarModule,
	MatSortModule,
	MatTableModule,
	MatTabsModule,
	MatTooltipModule
} from '@angular/material';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {NgxPermissionsGuard, NgxPermissionsModule} from 'ngx-permissions';
import {HttpUtilsService, InterceptService, LayoutUtilsService, TypesUtilsService} from '../../../core/_base/crud';
import {HTTP_INTERCEPTORS} from '@angular/common/http';
import {ActionNotificationComponent, DeleteEntityDialogComponent} from '../../partials/content/crud';
import { UsuariosListComponent } from './usuarios/usuarios-list/usuarios-list.component';
import { UsuariosEditComponent } from './usuarios/usuarios-edit/usuarios-edit.component';
import { RolesListComponent } from './roles/roles-list/roles-list.component';
import { RolesEditComponent } from './roles/roles-edit/roles-edit.component';
import { ClientesListComponent } from './clientes/clientes-list/clientes-list.component';
import { ClientesEditComponent } from './clientes/clientes-edit/clientes-edit.component';
import { EstadosServicioListComponent } from './estados-servicio/estados-servicio-list/estados-servicio-list.component';
import { EstadosServicioEditComponent } from './estados-servicio/estados-servicio-edit/estados-servicio-edit.component';
import { FormasPagoListComponent } from './formas-pago/formas-pago-list/formas-pago-list.component';
import { FormasPagoEditComponent } from './formas-pago/formas-pago-edit/formas-pago-edit.component';
import { TiposServicioListComponent } from './tipos-servicio/tipos-servicio-list/tipos-servicio-list.component';
import { TiposServicioEditComponent } from './tipos-servicio/tipos-servicio-edit/tipos-servicio-edit.component';
import { ServiciosListComponent } from './servicios/servicios-list/servicios-list.component';
import { ServiciosEditComponent } from './servicios/servicios-edit/servicios-edit.component';
import { TiposVehiculoListComponent } from './tipos-vehiculo/tipos-vehiculo-list/tipos-vehiculo-list.component';
import { TiposVehiculoEditComponent } from './tipos-vehiculo/tipos-vehiculo-edit/tipos-vehiculo-edit.component';
import { VehiculosListComponent } from './vehiculos/vehiculos-list/vehiculos-list.component';
import { VehiculosEditComponent } from './vehiculos/vehiculos-edit/vehiculos-edit.component';
import { SucursalesListComponent } from './sucursales/sucursales-list/sucursales-list.component';
import { SucursalesEditComponent } from './sucursales/sucursales-edit/sucursales-edit.component';
import { PermisosComponent } from './roles/permisos/permisos.component';
import { NgxMatSelectSearchModule } from 'ngx-mat-select-search';
import { ClientesDomiciliosEditComponent } from './clientes/clientes-domicilios-edit/clientes-domicilios-edit.component';
import { ClientesDomiciliosListComponent } from './clientes/clientes-domicilios-list/clientes-domicilios-list.component';

@NgModule({
	declarations: [PermisosComponent, UsuariosListComponent, UsuariosEditComponent, RolesEditComponent, RolesListComponent, ClientesListComponent, ClientesEditComponent, EstadosServicioListComponent, EstadosServicioEditComponent, FormasPagoListComponent, FormasPagoEditComponent, TiposServicioListComponent, TiposServicioEditComponent, ServiciosListComponent, ServiciosEditComponent, TiposVehiculoListComponent, TiposVehiculoEditComponent, VehiculosListComponent, VehiculosEditComponent, SucursalesListComponent, SucursalesEditComponent, ClientesDomiciliosListComponent, ClientesDomiciliosEditComponent],
	imports: [
		CommonModule,
		PartialsModule,
		CoreModule,
		RouterModule.forChild([
			{
				path: 'usuarios',
				component: UsuariosListComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.usuarios.index'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'usuarios/add',
				component: UsuariosEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.usuarios.store'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'usuarios/edit/:id',
				component: UsuariosEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.usuarios.show'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'roles',
				component: RolesListComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.roles.index'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'roles/add',
				component: RolesEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.roles.store'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'roles/edit/:id',
				component: RolesEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.roles.show'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'clientes',
				component: ClientesListComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.clientes.index'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'clientes/add',
				component: ClientesEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.clientes.store'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'clientes/edit/:id',
				component: ClientesEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.clientes.show'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'clientes-domicilios/add/:clienteDomicilioID',
				component: ClientesDomiciliosEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.clientes.domicilios.store'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'clientes-domicilios/edit/:id/:clienteDomicilioID',
				component: ClientesDomiciliosEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.clientes.domicilios.show'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'clientes-domicilios/:id',
				component: ClientesDomiciliosListComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.clientes.domicilios.index'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'estados-servicio',
				component: EstadosServicioListComponent
			},
			{
				path: 'estados-servicio/add',
				component: EstadosServicioEditComponent
			},
			{
				path: 'estados-servicio/edit/:id',
				component: EstadosServicioEditComponent
			},
			{
				path: 'formas-pago',
				component: FormasPagoListComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.formas_pagos.index'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'formas-pago/add',
				component: FormasPagoEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.formas_pagos.store'],
						redirectTo: '/'
					}
				}				
			},
			{
				path: 'formas-pago/edit/:id',
				component: FormasPagoEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.formas_pagos.show'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'servicios',
				component: ServiciosListComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.servicios.index'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'servicios/add',
				component: ServiciosEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.servicios.store'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'servicios/edit/:id',
				component: ServiciosEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.servicios.show'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'sucursales',
				component: SucursalesListComponent
			},
			{
				path: 'sucursales/add',
				component: SucursalesEditComponent
			},
			{
				path: 'sucursales/edit/:id',
				component: SucursalesEditComponent
			},
			{
				path: 'tipos-servicio',
				component: TiposServicioListComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.tipos_servicios.index'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'tipos-servicio/add',
				component: TiposServicioEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.tipos_servicios.store'],
						redirectTo: '/'
					}
				}				
			},
			{
				path: 'tipos-servicio/edit/:id',
				component: TiposServicioEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.tipos_servicios.show'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'tipos-vehiculo',
				component: TiposVehiculoListComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.tipos_vehiculos.index'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'tipos-vehiculo/add',
				component: TiposVehiculoEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.tipos_vehiculos.store'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'tipos-vehiculo/edit/:id',
				component: TiposVehiculoEditComponent,
				canActivate: [NgxPermissionsGuard],
				data: {
					permissions: {
						only: ['administrador.tipos_vehiculos.show'],
						redirectTo: '/'
					}
				}
			},
			{
				path: 'vehiculos',
				component: VehiculosListComponent
			},
			{
				path: 'vehiculos/add',
				component: VehiculosEditComponent
			},
			{
				path: 'vehiculos/edit/:id',
				component: VehiculosEditComponent
			},
		]),
		MatButtonModule,
		MatTooltipModule,
		MatFormFieldModule,
		MatInputModule,
		MatSelectModule,
		MatIconModule,
		MatTableModule,
		MatMenuModule,
		MatCheckboxModule,
		MatSortModule,
		MatProgressSpinnerModule,
		MatPaginatorModule,
		FormsModule,
		ReactiveFormsModule,
		MatAutocompleteModule,
		MatRadioModule,
		MatNativeDateModule,
		MatProgressBarModule,
		MatDatepickerModule,
		MatCardModule,
		MatSnackBarModule,
		MatExpansionModule,
		MatTabsModule,
		MatDialogModule,
		NgxPermissionsModule.forChild(),
		MatSelectModule,
		NgxMatSelectSearchModule
	],
	providers: [
		InterceptService,
		{
			provide: HTTP_INTERCEPTORS,
			useClass: InterceptService,
			multi: true
		},
		{
			provide: MAT_DIALOG_DEFAULT_OPTIONS,
			useValue: {
				hasBackdrop: true,
				panelClass: 'kt-mat-dialog-container__wrapper',
				height: 'auto',
				width: '900px'
			}
		},
		HttpUtilsService,
		TypesUtilsService,
		LayoutUtilsService,
	],
	entryComponents: [
		DeleteEntityDialogComponent,
		ActionNotificationComponent,
		PermisosComponent
	]
})
export class CatalogosModule {
}
