import { Card, Grid, Container } 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 './New/List';

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

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

  const { corporate_id } = useParams();

  const [corporate, setCorporate] = useState<Corporate | null>();

  const configuredCorporateContext = useContext(ConfiguredCorporateContext);

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

  return (
    <Page title="Corporate Formularium">
      <HeaderBreadcrumbs
        heading={'Corporate Formularium'}
        links={[
          {
            name: 'Corporates',
            href: '/corporates',
          },
          {
            name: corporate?.name ?? '-',
            href: '/corporates/' + corporate_id,
          },
          {
            name: 'Formularium',
            href: '/corporates/' + corporate_id + '/formulariums',
          },
        ]}
      />

      <Card>
        <CorporateTabNavigations position={'formulariums'} />
        <List />
      </Card>
    </Page>
  );
}
