import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AuthGuard } from '@shared/auth/auth.guard';
import { SettingsGeneralComponent } from './settings-general/settings-general.component';
import { NewTosComponent } from './new-tos/new-tos.component';
import { EditTosComponent } from './edit-tos/edit-tos.component';
import { IRouteConfig } from '@shared/ui-api/interfaces/route-config/route-config';
import { TosResolver } from '@fleio-api/core/tos.resolver';
import {
  Saml2IdentityProviderCreateComponent
} from './saml2-identity-provider-create/saml2-identity-provider-create.component';
import {
  Saml2IdentityProviderEditComponent
} from './saml2-identity-provider-edit/saml2-identity-provider-edit.component';
import { Saml2IdentityProviderResolver } from '@fleio-api/core/saml2-identity-provider.resolver';

const routes: Routes = [
  {
    path: '',
    component: SettingsGeneralComponent,
    canActivate: [AuthGuard],
    data: {
      config: {
        feature: 'settings.general'
      }
    }
  },
  {
    path: 'new-tos',
    component: NewTosComponent,
    canActivate: [AuthGuard],
    data: {
      config: {
        feature: 'settings.general',
        getBreadCrumbDetail: () => $localize`Create terms of service`
      } as IRouteConfig
    }
  },
  {
    path: 'edit-tos/:id',
    component: EditTosComponent,
    canActivate: [AuthGuard],
    resolve: {
      tos: TosResolver,
    },
    data: {
      config: {
        feature: 'settings.general',
        getBreadCrumbDetail: () => $localize`Edit terms of service`
      } as IRouteConfig
    }
  },
  {
    path: 'saml2-identity-providers/create',
    component: Saml2IdentityProviderCreateComponent,
    canActivate: [AuthGuard],
    data: {
      config: {
        feature: 'settings.general.single-sign-on',
        getBreadCrumbDetail: () => $localize`Create new SAML 2 identity provider`
      } as IRouteConfig
    }
  },
  {
    path: 'saml2-identity-providers/:id/edit',
    component: Saml2IdentityProviderEditComponent,
    canActivate: [AuthGuard],
    resolve: {
      saml2IdentityProvider: Saml2IdentityProviderResolver,
    },
    data: {
      config: {
        feature: 'settings.general.single-sign-on',
        getBreadCrumbDetail: () => $localize`Edit SAML 2 identity provider`
      } as IRouteConfig
    }
  }
];

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