import { routeLastSegment } from '@/lib/route';
import { Award, Book, Briefcase, CassetteTape, CreditCard, LayoutDashboard, Newspaper, Receipt, School, Settings, Users } from 'lucide-react';

const label = (value: unknown, fallback: string): string => (typeof value === 'string' && value.length ? value : fallback);

export default function getDashboardRoutes(translate: LanguageTranslations): DashboardRoute[] {
   const { button, settings } = translate;

   return [
      {
         title: label(button.main_menu, 'Main Menu'),
         slug: 'main-menu',
         pages: [
         {
            Icon: LayoutDashboard,
            name: label(button.dashboard, 'Dashboard'),
            path: route('dashboard'),
            slug: routeLastSegment(route('dashboard')),
            active: true,
            access: ['admin', 'instructor', 'collaborative', 'administrative'],
            children: [],
         },
         {
            Icon: School,
            name: label(button.courses, 'Courses'),
            path: '',
            slug: 'courses',
            active: true,
            access: ['admin', 'instructor', 'collaborative', 'administrative'],
            children: [
               {
                  name: label(button.categories, 'Categories'),
                  path: route('categories.index'),
                  slug: routeLastSegment(route('categories.index')),
                  access: ['admin', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.manage_courses, 'Manage Courses'),
                  slug: routeLastSegment(route('courses.index')),
                  path: route('courses.index'),
                  access: ['admin', 'instructor', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.create_course, 'Create Course'),
                  slug: routeLastSegment(route('courses.create')),
                  path: route('courses.create'),
                  access: ['admin', 'instructor', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.course_coupons, 'Course Coupons'),
                  slug: routeLastSegment(route('course-coupons.index')),
                  path: route('course-coupons.index'),
                  access: ['admin', 'instructor', 'collaborative', 'administrative'],
               },
            ],
         },
         {
            Icon: Book,
            name: label(button.exams, 'Exams'),
            path: '',
            slug: 'exams',
            active: true,
            access: ['admin', 'instructor', 'collaborative', 'administrative'],
            children: [
               {
                  name: label(button.categories, 'Categories'),
                  slug: routeLastSegment(route('exam-categories.index')),
                  path: route('exam-categories.index'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.manage_exams, 'Manage Exams'),
                  slug: routeLastSegment(route('exams.index')),
                  path: route('exams.index'),
                  access: ['admin', 'instructor', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.create_exam, 'Create Exam'),
                  slug: routeLastSegment(route('exams.create')),
                  path: route('exams.create'),
                  access: ['admin', 'instructor', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.exam_coupons, 'Exam Coupons'),
                  slug: routeLastSegment(route('exam-coupons.index')),
                  path: route('exam-coupons.index'),
                  access: ['admin', 'instructor', 'collaborative', 'administrative'],
               },
            ],
         },
         {
            Icon: CassetteTape,
            name: label(button.enrollments, 'Enrollments'),
            path: '',
            slug: 'enrollments',
            active: true,
            access: ['admin', 'instructor', 'collaborative', 'administrative'],
            children: [
               {
                  name: label(button.course_enrollments, 'Course Enrollments'),
                  slug: routeLastSegment(route('course-enrollments.index')),
                  path: route('course-enrollments.index'),
                  access: ['admin', 'instructor', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.exam_enrollments, 'Exam Enrollments'),
                  slug: routeLastSegment(route('exam-enrollments.index')),
                  path: route('exam-enrollments.index'),
                  access: ['admin', 'instructor', 'collaborative', 'administrative'],
               },
            ],
         },
         {
            Icon: Users,
            name: label(button.instructors, 'Instructors'),
            path: '',
            slug: 'instructors',
            active: true,
            access: ['admin', 'collaborative'],
            children: [
               {
                  name: label(button.manage_instructors, 'Manage Instructors'),
                  slug: routeLastSegment(route('instructors.index')),
                  path: route('instructors.index'),
                  access: ['admin', 'collaborative'],
               },
               {
                  name: label(button.create_instructor, 'Create Instructor'),
                  slug: routeLastSegment(route('instructors.create')),
                  path: route('instructors.create'),
                  access: ['admin', 'collaborative'],
               },
               {
                  name: label(button.applications, 'Applications'),
                  slug: routeLastSegment(route('instructors.applications')),
                  path: route('instructors.applications', {
                     status: 'pending',
                  }),
                  access: ['admin', 'collaborative'],
               },
            ],
         },
         {
            Icon: Receipt,
            name: label(button.payouts, 'Payouts'),
            path: '',
            slug: 'payouts',
            active: true,
            access: ['instructor', 'collaborative'],
            children: [
               {
                  name: label(button.withdraw, 'Withdraw'),
                  slug: routeLastSegment(route('payouts.index')),
                  path: route('payouts.index'),
                  access: ['instructor', 'collaborative'],
               },
               {
                  name: label(button.settings, 'Settings'),
                  slug: routeLastSegment(route('payouts.settings.index')),
                  path: route('payouts.settings.index'),
                  access: ['instructor', 'collaborative'],
               },
            ],
         },
         {
            Icon: Receipt,
            name: label(button.payout_report, 'Payout Report'),
            path: '',
            slug: 'payouts',
            active: true,
            access: ['admin', 'collaborative'],
            children: [
               {
                  name: label(button.payout_request, 'Payout Request'),
                  slug: routeLastSegment(route('payouts.request.index')),
                  path: route('payouts.request.index'),
                  access: ['admin', 'collaborative'],
               },
               {
                  name: label(button.payout_history, 'Payout History'),
                  slug: routeLastSegment(route('payouts.history.index')),
                  path: route('payouts.history.index'),
                  access: ['admin', 'collaborative'],
               },
            ],
         },
         {
            Icon: CreditCard,
            name: label(button.payment_report, 'Payment Report'),
            path: '',
            slug: 'payment-reports',
            active: true,
            access: ['admin', 'collaborative', 'administrative'],
            children: [
               {
                  name: label(button.online_payments, 'Online Payments'),
                  slug: routeLastSegment(route('payment-reports.online.index')),
                  path: route('payment-reports.online.index'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.offline_payments, 'Offline Payments'),
                  slug: routeLastSegment(route('payment-reports.offline.index')),
                  path: route('payment-reports.offline.index'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
            ],
         },
         {
            Icon: Briefcase,
            name: label(button.job_circulars, 'Job Circulars'),
            path: '',
            slug: 'job-circulars',
            active: true,
            access: ['admin', 'collaborative', 'administrative'],
            children: [
               {
                  name: label(button.all_jobs, 'All Jobs'),
                  slug: routeLastSegment(route('job-circulars.index')),
                  path: route('job-circulars.index'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.create_job, 'Create Job'),
                  slug: routeLastSegment(route('job-circulars.create')),
                  path: route('job-circulars.create'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
            ],
         },
         {
            Icon: Book,
            name: label(button.blogs, 'Blogs'),
            path: '',
            slug: 'blogs',
            active: true,
            access: ['admin', 'instructor', 'collaborative', 'administrative'],
            children: [
               {
                  name: label(button.categories, 'Categories'),
                  slug: routeLastSegment(route('blogs.categories.index')),
                  path: route('blogs.categories.index'),
                  access: ['admin', 'instructor', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.create_blog, 'Create Blog'),
                  slug: routeLastSegment(route('blogs.create')),
                  path: route('blogs.create'),
                  access: ['admin', 'instructor', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.manage_blog, 'Manage Blog'),
                  slug: routeLastSegment(route('blogs.index')),
                  path: route('blogs.index'),
                  access: ['admin', 'instructor', 'collaborative', 'administrative'],
               },
            ],
         },
         {
            Icon: Newspaper,
            name: label(button.newsletters, 'Newsletters'),
            path: route('newsletters.index'),
            slug: routeLastSegment(route('newsletters.index')),
            active: true,
            access: ['admin', 'collaborative', 'administrative'],
            children: [],
         },
         {
            Icon: Users,
            name: label(button.all_users, 'All Users'),
            path: route('users.index'),
            slug: routeLastSegment(route('users.index')),
            active: true,
            access: ['admin', 'collaborative', 'administrative'],
            children: [],
         },
         {
            Icon: Award,
            name: label(button.certificates, 'Certificates'),
            path: '',
            slug: 'certification',
            active: true,
            access: ['admin', 'collaborative', 'administrative'],
            children: [
               {
                  name: label(button.certificate, 'Certificate'),
                  slug: routeLastSegment(route('certificate.templates.index')),
                  path: route('certificate.templates.index'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.marksheet, 'Marksheet'),
                  slug: routeLastSegment(route('marksheet.templates.index')),
                  path: route('marksheet.templates.index'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
            ],
         },
         {
            Icon: Settings,
            name: label(button.settings, 'Settings'),
            path: '',
            slug: 'settings',
            active: true,
            access: ['admin', 'instructor', 'collaborative', 'administrative'],
            children: [
               {
                  name: label(button.account, 'Account'),
                  slug: routeLastSegment(route('settings.account')),
                  path: route('settings.account'),
                  access: ['admin', 'instructor', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.system, 'System'),
                  slug: routeLastSegment(route('settings.system')),
                  path: route('settings.system'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.pages, 'Pages'),
                  slug: routeLastSegment(route('settings.pages')),
                  path: route('settings.pages'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.storage, 'Storage'),
                  slug: routeLastSegment(route('settings.storage')),
                  path: route('settings.storage'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.payment, 'Payment'),
                  slug: routeLastSegment(route('settings.payment')),
                  path: route('settings.payment'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.smtp, 'SMTP'),
                  slug: routeLastSegment(route('settings.smtp')),
                  path: route('settings.smtp'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.auth0, 'Auth'),
                  slug: routeLastSegment(route('settings.auth0')),
                  path: route('settings.auth0'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
               {
                  name: label(button.live_class, 'Live Class'),
                  slug: routeLastSegment(route('settings.live-class')),
                  path: route('settings.live-class'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
               {
                  name: label(settings.translation_settings, 'Translation'),
                  slug: routeLastSegment(route('language.index')),
                  path: route('language.index'),
                  access: ['admin', 'collaborative', 'administrative'],
               },
            ],
         },
      ],
      },
   ];
}
