import { NgModule } from '@angular/core';
import { RouterModule, Router, NavigationEnd } from '@angular/router';
import { OrderStatusTypeComponent } from './order-management/order-status-types/order-status-type.component';
import { TagTypeComponent } from './order-management/tag-types/tag-type.component';
import { OrderComponent } from './order-management/orders/order.component';
import { RoutesComponent } from './routes/routes.component';
import { RoutesTemplateComponent } from './routes-template/routestemplate.component';
import { RouteTemplateTypesComponent } from './route-template-types/route-template-types.component';
import { TimeZonesComponent } from './location-management/timezones/timezones.component';
import { ProximityComponent } from './location-management/proximity/proximity.component';
import { LocationsComponent } from './location-management/locations/location.component';
import { VehicleLocationComponent } from './location-management/vehicle-location/vehicle-location.component';
import { UserLocationComponent } from './location-management/user-location/user-location.component';
import { CreateUpdateLocationComponent } from './location-management/locations/create-update-location.component';
import { EditLocationComponent } from './location-management/locations/edit-location.component';
import { IncidentComponent } from './incident/incident.component';
import { FleetsComponent } from './fleet-management/fleet/fleets.component';
import { AddressTypeComponent } from './contact-management/address-types/address-types.component';
import { ContactComponent } from './contact-management/contacts/contacts.component';
import { PackageTypeComponent } from './package-management/package-types/package-type.component';
import { DriverIncidentsComponent } from './employees/driver-incident/driver-incidents.component';
import { EmployeeReviewComponent } from './employees/reviews/employee-review.component';
import { VehiclesComponent } from './fleet-management/vehicle/vehicles.component';
import { TimeSheetComponent } from './employees/timesheets/timesheet.component';
import { AddressComponent } from './contact-management/addresses/address.component';
import { EmailComponent } from './contact-management/emails/email.component';
import { DriversComponent } from './fleet-management/drivers/drivers.component';
import { VendorsComponent } from './vendor-management/vendors/vendors.component';
import { TagComponent } from './order-management/tags/tag.component';
import { OrderPackageComponent } from './order-management/order-package/order-package.component';
import { OrderStatusComponent } from './order-management/order-status/order-status.component';
import { CreateDriverComponent } from './fleet-management/drivers/create-driver.component';
import { EditDriverComponent } from './fleet-management/drivers/edit-driver.component';
import { UpdateOrderComponent } from './order-management/orders/update-order.component';
import { CreateOrderComponent } from './order-management/orders/create-order.component';
import { CreateVendorComponent } from './vendor-management/vendors/create-vendor.component';
import { EditVendorComponent } from './vendor-management/vendors/edit-vendor.component';
import { CreateContactComponent } from './contact-management/contacts/create-contact.component';
import { EditContactComponent } from './contact-management/contacts/edit-contact.component';
import { PostalCodesComponent } from './contact-management/postal-codes/postal-codes.component';
import { CRoutesComponent } from './controller/routes/croutes.component';
import { RouteDetailComponent } from './controller/route-detail/route-detail.component';

@NgModule({
    imports: [
        RouterModule.forChild([
            {
                path: '',
                children: [
                     { path: 'status-type', component: OrderStatusTypeComponent, data: { permission: 'Pages.Orders.OrderStatusTypes' } },
                     { path: 'tag-type', component: TagTypeComponent, data: { permission: 'Pages.Orders.TagTypes' } },
                     { path: 'order', component: OrderComponent, data: { permission: 'Pages.Orders' } },
                     { path: 'package-order', component: OrderPackageComponent, data: { permission: 'Pages.Orders.Package' } },
                     { path: 'status-order', component: OrderStatusComponent, data: { permission: 'Pages.Orders.Status' } },
                     { path: 'order-update/:id', component: UpdateOrderComponent, data: { permission: 'Pages.Orders' } },
                     { path: 'order-create', component: CreateOrderComponent, data: { permission: 'Pages.Orders' } },
                     { path: 'tags', component: TagComponent, data: { permission: 'Pages.Orders.Tags' } },
                     { path: 'routes', component: RoutesComponent, data: { permission: 'Pages.Shipping.Routes' } },
                     { path: 'routes-template', component: RoutesTemplateComponent, data: { permission: 'Pages.Shipping.RoutesTemplate' } },
                     { path: 'routes-template-types', component: RouteTemplateTypesComponent, data: { permission: 'Pages.Shipping.RouteTemplateTypes' } },
                     { path: 'fleets', component: FleetsComponent, data: { permission: 'Pages.Shipping.Fleets' } },
                     { path: 'drivers', component: DriversComponent, data: { permission: 'Pages.Administration.Users' } },
                     { path: 'vehicle', component: VehiclesComponent, data: { permission: 'Pages.Shipping.Vehicles' } },
                     { path: 'address-types', component: AddressTypeComponent, data: { permission: 'Pages.Shipping.Contacts.AddressTypes' } },
                     { path: 'addresses', component: AddressComponent, data: { permission: 'Pages.Shipping.Contacts.Address' } },
                     { path: 'contacts', component: ContactComponent, data: { permission: 'Pages.Shipping.Contacts' } },
                     { path: 'timezones', component: TimeZonesComponent, data: { permission: 'Pages.Administration.TimeZones' } },
                     { path: 'proximity', component: ProximityComponent, data: { permission: 'Pages.Administration.Proximities' } },
                     { path: 'location-create-update/:id', component: CreateUpdateLocationComponent, data: { permission: 'Pages.Administration.Locations' } },
                     { path: 'location-edit/:id', component: EditLocationComponent, data: { permission: 'Pages.Administration.Locations' } },
                     { path: 'locations', component: LocationsComponent, data: { permission: 'Pages.Administration.Locations' } },
                     { path: 'locationvehicle', component: VehicleLocationComponent, data: { permission: 'Pages.Administration.VehicleLocations' } },
                     { path: 'user-location', component: UserLocationComponent, data: { permission: 'Pages.Administration.UserLocations' } },
                     { path: 'package-types', component: PackageTypeComponent, data : { permission: 'Pages.Shipping.Package.PackageType'} },
                     { path: 'employees/timesheets', component: TimeSheetComponent, data: { permission: 'Pages.Administration.Employees.TimeSheet' } },
                     { path: 'employees/reviews', component: EmployeeReviewComponent, data: { permission: 'Pages.Administration.Employees.EmployeeReview' } },
                     { path: 'employees/driver-incidents', component: DriverIncidentsComponent, data: { permission: 'Pages.Administration.Employees.DriverIncidents' } },
                     { path: 'emails', component: EmailComponent, data: { permission: 'Pages.Shipping.Contacts.Emails' } },
                     { path: 'incidents', component: IncidentComponent, data: { permission: 'Pages.Administration.Employees.Incidents' } },
                     { path: 'vendors', component: VendorsComponent, data: { permission: 'Pages.Administration.Users' } },
                     { path: 'create-driver', component: CreateDriverComponent, data: { permission: 'Pages.Administration.Users' } },
                     { path: 'edit-driver/:id', component: EditDriverComponent, data: { permission: 'Pages.Administration.Users' } },
                     { path: 'create-vendor', component: CreateVendorComponent, data: { permission: 'Pages.Administration.Users' } },
                     { path: 'contact-create', component: CreateContactComponent, data: { permission: 'Pages.Administration.Users' } },
                     { path: 'contact-edit/:id', component: EditContactComponent, data: { permission: 'Pages.Administration.Users' } },
                     { path: 'edit-vendor/:id', component: EditVendorComponent, data: { permission: 'Pages.Administration.Users' } },
                     { path: 'postal-codes', component: PostalCodesComponent, data: { permission: 'Pages.Shipping.Contacts.PostalCodes' } },
                     { path: 'controller-routes', component: CRoutesComponent, data: {} },
                     { path: 'controller-routes-details/:id', component: RouteDetailComponent, data: {} }
                    ]
            }
        ])
    ],
    exports: [
        RouterModule
    ]
})
export class SprintShipRoutingModule { 
    constructor(
        private router: Router
    ) {
        router.events.subscribe((event) => {
            if (event instanceof NavigationEnd) {
                window.scroll(0, 0);
            }
        });
    }

}
