import { GENEALOGY as URL_PREFIX, GENEALOGY_PLACEMENT_TREE, SPONSOR_DOWNLINE_LISTING } from '@/config/url-prefix'
import ContentTemplate from './components/templates/ContentTemplate'
import AppSettings from '@/config/app-settings'

const ibsRouting = [
  {
    path: URL_PREFIX,
    component: () => import('@/elements/templates/screens/SidebarFluid'),
    name: 'Genealogy',
    redirect: URL_PREFIX + '/sponsornetworktree',
    meta: {
      dashboardMenu: {
        displayName: 'Genealogy.Title', // this is the sidebar title
        priority: 9,
        icon: 'sidebar-geneology',
      },
      policy: {
        genealogy: 'view',
      },
    },
    children: [
      {
        path: URL_PREFIX + '/sponsornetworktree',
        component: () => import('./components/SponsorNetworkTree'),
        name: 'GenealogySponsorNetworkTree',
        meta: {
          dashboardMenu: {
            displayName: 'Genealogy.SponsorNetworkTree.Title', // this is the sidebar title
            priority: 9,
          },
        },
      },
      {
        path: URL_PREFIX + '/placementnetworktree',
        component: () => import('./components/PlacementNetworkTree'),
        name: 'GenealogyPlacementNetworkTree',
        meta: {
          dashboardMenu: {
            displayName: 'Genealogy.PlacementNetworkTree.Title', // this is the sidebar title
            priority: 9,
          },
          template: {
            content: ContentTemplate,
          },
        },
      },
      {
        path: URL_PREFIX + '/placementnetworkperformance',
        component: () => import('./components/PlacementNetworkPerformance'),
        name: 'GenealogyPlacementNetworkPerformance',
        meta: {
          dashboardMenu: {
            displayName: 'Genealogy.PlacementNetworkPerformance.Title', // this is the sidebar title
            priority: 9,
          },
        },
      },
      {
        path: URL_PREFIX + '/sponsordownlinelisting',
        component: () => import('./components/IbsSponsorDownlineListing'),
        name: 'GenealogySponsorDownlineListing',
        meta: {
          dashboardMenu: {
            displayName: 'Genealogy.SponsorDownlineListing.Title', // this is the sidebar title
            priority: 9,
          },
        },
      },
    ],
  },
  {
    path: GENEALOGY_PLACEMENT_TREE,
    component: () => import('./components/PlacementNetworkTree'),
    name: 'GenealogyPlacementTree',
    props: route => ({
      userIdData: parseInt(route.query.userid),
      token: route.query.token,
      depth: route.query.depth,
      selectedId: route.query.selectedid,
      showOuter: route.query.showouter,
    }),
    meta: {
      menuItem: false,
      screen: 'webview-screen',
    },
  },
]

const evoRouting = [
  {
    path: URL_PREFIX,
    component: () => import('@/elements/templates/screens/SidebarFluid'),
    name: 'Genealogy',
    redirect: { name: 'evoSponsorDownLineListing' },
    meta: {
      dashboardMenu: {
        displayName: 'Genealogy.SponsorDownlineListing.Title', // this is the sidebar title
        priority: 9,
        icon: 'sidebar-geneology',
      },
      policy: {
        genealogy: 'view',
      },
    },
    children: [
      {
        path: SPONSOR_DOWNLINE_LISTING,
        component: () => import('./components/EvoSponsorDownlineListing'),
        name: 'evoSponsorDownLineListing',
        meta: {
          title: 'Genealogy.SponsorDownlineListing.Title',
        },
      },
    ],
  },
]

export default AppSettings.evo.enable ? evoRouting : ibsRouting
