import { MemoryRouter, Route, createMemoryHistory } from '@solidjs/router';
import type { Meta, StoryObj } from 'storybook-solidjs-vite';

import '../../app.css';
import AdminHomePage from '../../routes/admin/index';
import ApprovalPage from '../../routes/admin/approval';
import VerificationPage from '../../routes/admin/verification';
import EmployeesPage from '../../routes/admin/employees';
import InternalDashboardManagementPage from '../../routes/admin/internal-dashboard-management';
import ExternalDashboardManagementPage from '../../routes/admin/external-dashboard-management';
// Onboarding management uses onboarding-schemas route
import OnboardingManagementPage from '../../routes/admin/onboarding-schemas/index';

const meta = {
  title: 'Admin/Pages',
  parameters: {
    layout: 'fullscreen',
    backgrounds: { disable: true },
  },
} satisfies Meta;

export default meta;
type Story = StoryObj<typeof meta>;

function renderRoute(path: string, component: any) {
  const history = createMemoryHistory();
  history.set({ value: `${path}?_preview=1`, replace: true, scroll: false });

  return (
    <MemoryRouter history={history}>
      <Route path={path} component={component} />
    </MemoryRouter>
  );
}

export const Dashboard: Story = {
  render: () => renderRoute('/admin', AdminHomePage),
};

export const Verification: Story = {
  render: () => renderRoute('/admin/verification', VerificationPage),
};

export const Approval: Story = {
  render: () => renderRoute('/admin/approval', ApprovalPage),
};

export const EmployeeManagement: Story = {
  render: () => renderRoute('/admin/employees', EmployeesPage),
};

export const InternalDashboardManagement: Story = {
  render: () => renderRoute('/admin/internal-dashboard-management', InternalDashboardManagementPage),
};

export const ExternalDashboardManagement: Story = {
  render: () => renderRoute('/admin/external-dashboard-management', ExternalDashboardManagementPage),
};

export const ExternalOnboardingManagement: Story = {
  render: () => renderRoute('/admin/onboarding-management', OnboardingManagementPage),
};
