import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {OpenaireErrorPageComponent} from './error/errorPage.component';
import {PageURLResolverComponent} from "./openaireLibrary/utils/pageURLResolver.component";

const routes: Routes = [
  // Other Pages
  {path: '', loadChildren: () => import('./home/home.module').then(m => m.HomeModule)},
  {path: 'home', redirectTo: '', pathMatch: 'full'},
  {path: 'mail-preferences', loadChildren: () => import('./userEmailPreferences/mailPrefs.module').then(m => m.LibMailPrefsModule)},
	{path: 'sdgs', loadChildren: () => import('./sdg/sdg.module').then(m => m.LibSdgModule)},
	{path: 'fields-of-science', loadChildren: () => import('./fos/fos.module').then(m => m.LibFosModule), data: {extraOffset: 100}},
	{path: 'contact-us', loadChildren: () => import('./contact/contact.module').then(m => m.ContactModule), data: {hasQuickContact: false}},
  // ORCID Pages
  {path: 'orcid', loadChildren: () => import('./orcid/orcid.module').then(m => m.LibOrcidModule)},
  {path: 'my-orcid-links', loadChildren: () => import('./orcid/my-orcid-links/myOrcidLinks.module').then(m => m.LibMyOrcidLinksModule)},
  // Landing Pages
  {path: 'search/result', loadChildren: () => import('./landingPages/result/libResult.module').then(m => m.LibResultModule), data: {hasQuickContact: false}},
  {path: 'search/publication', loadChildren: () => import('./landingPages/publication/libPublication.module').then(m => m.LibPublicationModule), data: {hasQuickContact: false}},
  {path: 'search/dataset', loadChildren: () => import('./landingPages/dataset/libDataset.module').then(m => m.LibDatasetModule), data: {hasQuickContact: false}},
  {path: 'search/software', loadChildren: () => import('./landingPages/software/libSoftware.module').then(m => m.LibSoftwareModule), data: {hasQuickContact: false}},
  {path: 'search/other', loadChildren: () => import('./landingPages/orp/libOrp.module').then(m => m.LibOrpModule), data: {hasQuickContact: false}},
  {path: 'search/project', loadChildren: () => import('./landingPages/project/libProject.module').then(m => m.LibProjectModule), data: {hasQuickContact: false}},
  {
    path: 'search/dataprovider',
    loadChildren: () => import('././landingPages/dataProvider/libDataProvider.module').then(m => m.LibDataProviderModule),
		data: {hasQuickContact: false}
  },
  {
    path: 'search/organization',
    loadChildren: () => import('./landingPages/organization/libOrganization.module').then(m => m.LibOrganizationModule),
		data: {hasQuickContact: false}
  },
  {
    path: 'project-report',
    loadChildren: () => import('./landingPages/htmlProjectReport/libHtmlProjectReport.module').then(m => m.LibHtmlProjectReportModule)
  },
  // Search Pages
  {path: 'search/find', loadChildren: () => import('./searchPages/find/libSearch.module').then(m => m.LibMainSearchModule)},
  {
    path: 'search/find/research-outcomes',
    loadChildren: () => import('./searchPages/simple/searchResearchResults.module').then(m => m.OpenaireSearchResearchResultsModule)
  },
  {path: 'search/find/publications', component: PageURLResolverComponent},
  {path: 'search/find/datasets', component: PageURLResolverComponent},
  {path: 'search/find/software', component: PageURLResolverComponent},
  {path: 'search/find/other', component: PageURLResolverComponent},
  {path: 'search/find/projects', loadChildren: () => import('./searchPages/simple/searchProjects.module').then(m => m.LibSearchProjectsModule)},
  {
    path: 'search/find/dataproviders',
    loadChildren: () => import('./searchPages/simple/searchDataProviders.module').then(m => m.LibSearchDataProvidersModule)
  },
  {
    path: 'search/find/organizations',
    loadChildren: () => import('./searchPages/simple/searchOrganizations.module').then(m => m.LibSearchOrganizationsModule)
  },
  // Advanced Search Pages
  {
    path: 'search/advanced/research-outcomes',
    loadChildren: () => import('./searchPages/advanced/searchResearchResults.module').then(m => m.OpenaireAdvancedSearchResearchResultsModule)
  },
  {path: 'search/advanced/publications', component: PageURLResolverComponent},
  {path: 'search/advanced/datasets', component: PageURLResolverComponent},
  {path: 'search/advanced/software', component: PageURLResolverComponent},
  {path: 'search/advanced/other', component: PageURLResolverComponent},
  {
    path: 'search/advanced/organizations',
    loadChildren: () => import('./searchPages/advanced/advancedSearchOrganizations.module').then(m => m.LibAdvancedSearchOrganizationsModule)
  },
  {
    path: 'search/advanced/dataproviders',
    loadChildren: () => import('./searchPages/advanced/advancedSearchDataProviders.module').then(m => m.LibAdvancedSearchDataProvidersModule)
  },
  {
    path: 'search/advanced/projects',
    loadChildren: () => import('./searchPages/advanced/advancedSearchProjects.module').then(m => m.LibAdvancedSearchProjectsModule)
  },
  // Search Content Providers Pages
  {
    path: 'search/content-providers',
    loadChildren: () => import('./searchPages/dataProviders/compatibleDataProviders.module').then(m => m.LibCompatibleDataProvidersModule)
  },
  {path: 'search/content-providers-table', redirectTo: 'search/content-providers', pathMatch: 'full'},
  {
    path: 'search/entity-registries',
    loadChildren: () => import('./searchPages/dataProviders/entityRegistries.module').then(m => m.LibEntityRegistriesModule)
  },
  {path: 'search/entity-registries-table', redirectTo: 'search/entity-registries', pathMatch: 'full'},
  {path: 'search/journals', loadChildren: () => import('./searchPages/dataProviders/journals.module').then(m => m.LibJournalsModule)},
  {path: 'search/journals-table', redirectTo: 'search/journals', pathMatch: 'full'},
  // Deposit Pages
  {path: 'participate/deposit-datasets', redirectTo: 'participate/deposit/learn-how', pathMatch: 'full'},
  {path: 'participate/deposit-datasets-result', redirectTo: 'participate/deposit/learn-how', pathMatch: 'full'},
  {path: 'participate/deposit-subject-result', redirectTo: 'participate/deposit/learn-how', pathMatch: 'full'},
  {path: 'participate/deposit-publications', redirectTo: 'participate/deposit/learn-how', pathMatch: 'full'},
  {path: 'participate/deposit-publications-result', redirectTo: 'participate/deposit/learn-how', pathMatch: 'full'},
  {path: 'participate/deposit/learn-how', loadChildren: () => import('./deposit/deposit.module').then(m => m.LibDepositModule)},
  {
    path: 'participate/deposit/search',
    loadChildren: () => import('./deposit/searchDataprovidersToDeposit.module').then(m => m.LibSearchDataprovidersToDepositModule)
  },
  // Linking Pages
  {path: 'myclaims', loadChildren: () => import('./claims/myClaims/myClaims.module').then(m => m.LibMyClaimsModule)},
  {path: 'claims', loadChildren: () => import('./claims/claimsAdmin/claimsAdmin.module').then(m => m.LibClaimsAdminModule)},
  {path: 'participate/claim', loadChildren: () => import('./claims/linking/linkingGeneric.module').then(m => m.LibLinkingGenericModule)},
  {
    path: 'participate/direct-claim',
    loadChildren: () => import('./claims/directLinking/directLinking.module').then(m => m.LibDirectLinkingModule)
  },
  // { path: 'claims-project-manager', loadChildren: './claims/claimsByToken/claimsByToken.module#LibClaimsByTokenModule'},
  // help pages - do not exist in Admin portal/api/db
  {path: 'reload', loadChildren: () => import('./reload/libReload.module').then(m => m.LibReloadModule)},
  {path: 'user-info', loadChildren: () => import('./login/libUser.module').then(m => m.LibUserModule)},
  {path: 'error', component: OpenaireErrorPageComponent},
  {path: '**', pathMatch: 'full', component: OpenaireErrorPageComponent}
];

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