import AddProduct from './AddProduct';
import CreateKP from './CreateKP';
import ELT from './ELT';
import Insurance from './Insurance';
import Leasing from './Leasing';
import LeasingObject from './LeasingObject';
import Payments from './Payments';
import SupplierAgent from './SupplierAgent';
import Unlimited from './Unlimited';
import Background from '@/Components/Layout/Background';
import { useStore } from '@/stores/hooks';
import { min } from '@/styles/mq';
import styled from 'styled-components';
import { Tabs } from 'ui/elements';

const formTabs = [
  Leasing,
  Payments,
  LeasingObject,
  SupplierAgent,
  Insurance,
  ELT,
  AddProduct,
  CreateKP,
  Unlimited,
];

const Wrapper = styled(Background)`
  padding: 4px 6px;

  ${min('tablet')} {
    min-height: 790px;
  }

  ${min('laptop')} {
    padding: 4px 6px 10px;
  }
`;

const ComponentWrapper = styled.div`
  padding: 0 4px;

  ${min('laptop')} {
    padding: 0 12px;
  }
`;

export function Form() {
  const { $process } = useStore();

  const filteredTabs =
    $process.has('Unlimited') === false ? formTabs.filter((x) => x.id !== 'unlimited') : formTabs;

  return (
    <Wrapper>
      <Tabs type="card" tabBarGutter="5px">
        {filteredTabs.map(({ Component, id, title }) => (
          <Tabs.TabPane tab={title} key={id}>
            <ComponentWrapper>
              <Component />
            </ComponentWrapper>
          </Tabs.TabPane>
        ))}
      </Tabs>
    </Wrapper>
  );
}
