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';
import { CommercialWorkbenchPage } from './pages/CommercialWorkbenchPage';

export const router = createBrowserRouter([
  { path: '/login', element: <LoginPage /> },
  {
    path: '/',
    element: <AppLayout />,
    children: [
      { index: true, element: <DashboardPage /> },
      { path: 'tenants', element: <CommercialWorkbenchPage workbenchKey="onboarding" /> },
      { path: 'subscriptions', element: <CommercialWorkbenchPage workbenchKey="receivables" /> },
      { path: 'billing', element: <Navigate to="/subscriptions" replace /> },
      { path: 'usage', element: <BusinessPage pageKey="usage" /> },
      { path: 'dunning', element: <CommercialWorkbenchPage workbenchKey="dunning" /> },
      { path: 'refunds', element: <CommercialWorkbenchPage workbenchKey="refunds" /> },
      { 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: 'operations', element: <BusinessPage pageKey="operations" /> },
    ],
  },
  { path: '*', element: <Navigate to="/" replace /> },
]);
