import { createBrowserRouter, Navigate } from 'react-router';
import { AppLayout } from './layout/AppLayout';
import { DashboardPage } from './pages/DashboardPage';
import { LoginPage } from './pages/LoginPage';
import { BusinessPage } from './pages/BusinessPage';
import { QuestionBankPage } from './pages/QuestionBankPage';

export const router = createBrowserRouter([
  { path: '/login', element: <LoginPage /> },
  {
    path: '/',
    element: <AppLayout />,
    children: [
      { index: true, element: <DashboardPage /> },
      { path: 'tenants', element: <BusinessPage pageKey="tenants" /> },
      { path: 'subscriptions', element: <BusinessPage pageKey="subscriptions" /> },
      { path: 'billing', element: <BusinessPage pageKey="billing" /> },
      { path: 'usage', element: <BusinessPage pageKey="usage" /> },
      { path: 'dunning', element: <BusinessPage pageKey="dunning" /> },
      { path: 'question-banks', element: <QuestionBankPage /> },
      { path: 'crm', element: <BusinessPage pageKey="crm" /> },
      { path: 'sms', element: <BusinessPage pageKey="sms" /> },
      { path: 'payments', element: <BusinessPage pageKey="payments" /> },
      { path: 'staff', element: <BusinessPage pageKey="staff" /> },
      { path: 'audit', element: <BusinessPage pageKey="audit" /> },
      { path: 'alerts', element: <BusinessPage pageKey="alerts" /> },
    ],
  },
  { path: '*', element: <Navigate to="/" replace /> },
]);
