import { Card, Grid } from '@mui/material';
import { useParams } from 'react-router-dom';
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
import Page from '../../../components/Page';
import useSettings from '../../../hooks/useSettings';
import CorporateTabNavigations from '../CorporateTabNavigations';
import List from './List';

import { useContext, useEffect, useState } from 'react';
import { ConfiguredCorporateContext } from '@/contexts/ConfiguredCorporateContext';
import { Corporate } from '@/@types/corporates';

export default function Divisions() {
  const { themeStretch } = useSettings();

  const { corporate_id } = useParams();
  const [corporate, setCorporate] = useState<Corporate | null>();
  const [plans, setPlans] = useState<any[]>([]);

  const configuredCorporateContext = useContext(ConfiguredCorporateContext);

  useEffect(() => {
    setCorporate(configuredCorporateContext.currentCorporate);
    setPlans(configuredCorporateContext.currentCorporate?.plans ?? []);
  }, [configuredCorporateContext]);

  const pageTitle = 'Diagnosis Exclusion';
  return (
    <Page title={pageTitle}>
      <HeaderBreadcrumbs
        heading={pageTitle}
        links={[
          {
            name: 'Corporates',
            href: '/corporates',
          },
          {
            name: corporate?.name ?? '-',
            href: '/corporates/' + corporate_id,
          },
          {
            name: 'Diagnosis Exclusion',
            href: '/corporates/' + corporate_id + '/diagnosis-exclusions',
          },
        ]}
      />

      <Card>
        <CorporateTabNavigations position={'diagnosis-exclusions'} />
        <List data={plans} />
      </Card>
    </Page>
  );
}
