import {
  mdiAccount,
  mdiChartTimelineVariant,
  mdiMail,
  mdiUpload,
} from '@mdi/js';
import Head from 'next/head';
import React, { ReactElement } from 'react';
import CardBox from '../../components/CardBox';
import LayoutAuthenticated from '../../layouts/Authenticated';
import SectionMain from '../../components/SectionMain';
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
import { getPageTitle } from '../../config';

import { Field, Form, Formik } from 'formik';
import FormField from '../../components/FormField';
import BaseDivider from '../../components/BaseDivider';
import BaseButtons from '../../components/BaseButtons';
import BaseButton from '../../components/BaseButton';
import FormCheckRadio from '../../components/FormCheckRadio';
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup';
import FormFilePicker from '../../components/FormFilePicker';
import FormImagePicker from '../../components/FormImagePicker';
import { SwitchField } from '../../components/SwitchField';

import { SelectField } from '../../components/SelectField';
import { SelectFieldMany } from '../../components/SelectFieldMany';
import { RichTextField } from '../../components/RichTextField';

import { create } from '../../stores/modelos_bim_asbuilt/modelos_bim_asbuiltSlice';
import { useAppDispatch } from '../../stores/hooks';
import { useRouter } from 'next/router';
import moment from 'moment';

const initialValues = {
  nome_modelo: '',

  descricao: '',

  arquivo_modelo: '',

  formato: '',

  plataforma_origem: '',

  data_modelagem: '',
  dateData_modelagem: '',

  responsavel_modelagem: '',

  nivel_detalhamento: '',

  coordenacao_com_outros_modelos: false,

  comentarios: '',

  obra: '',

  clientes: '',
};

const Modelos_bim_asbuiltNew = () => {
  const router = useRouter();
  const dispatch = useAppDispatch();

  const handleSubmit = async (data) => {
    await dispatch(create(data));
    await router.push('/modelos_bim_asbuilt/modelos_bim_asbuilt-list');
  };
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton
          icon={mdiChartTimelineVariant}
          title='New Item'
          main
        >
          {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={initialValues}
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>
              <FormField label='NomedoModelo'>
                <Field name='nome_modelo' placeholder='NomedoModelo' />
              </FormField>

              <FormField label='Descrição' hasTextareaHeight>
                <Field name='descricao' as='textarea' placeholder='Descrição' />
              </FormField>

              <FormField label='ArquivodoModelo'>
                <Field name='arquivo_modelo' placeholder='ArquivodoModelo' />
              </FormField>

              <FormField label='Formato'>
                <Field name='formato' placeholder='Formato' />
              </FormField>

              <FormField label='PlataformadeOrigem'>
                <Field
                  name='plataforma_origem'
                  placeholder='PlataformadeOrigem'
                />
              </FormField>

              <FormField label='DatadeModelagem'>
                <Field
                  type='date'
                  name='data_modelagem'
                  placeholder='DatadeModelagem'
                />
              </FormField>

              <FormField label='ResponsávelpelaModelagem'>
                <Field
                  name='responsavel_modelagem'
                  placeholder='ResponsávelpelaModelagem'
                />
              </FormField>

              <FormField label='NíveldeDetalhamento'>
                <Field
                  name='nivel_detalhamento'
                  placeholder='NíveldeDetalhamento'
                />
              </FormField>

              <FormField
                label='CoordenaçãocomOutrosModelos'
                labelFor='coordenacao_com_outros_modelos'
              >
                <Field
                  name='coordenacao_com_outros_modelos'
                  id='coordenacao_com_outros_modelos'
                  component={SwitchField}
                ></Field>
              </FormField>

              <FormField label='Comentários' hasTextareaHeight>
                <Field
                  name='comentarios'
                  as='textarea'
                  placeholder='Comentários'
                />
              </FormField>

              <FormField label='Obra' labelFor='obra'>
                <Field
                  name='obra'
                  id='obra'
                  component={SelectField}
                  options={[]}
                  itemRef={'obras'}
                ></Field>
              </FormField>

              <FormField label='clientes' labelFor='clientes'>
                <Field
                  name='clientes'
                  id='clientes'
                  component={SelectField}
                  options={[]}
                  itemRef={'clientes'}
                ></Field>
              </FormField>

              <BaseDivider />
              <BaseButtons>
                <BaseButton type='submit' color='info' label='Submit' />
                <BaseButton type='reset' color='info' outline label='Reset' />
                <BaseButton
                  type='reset'
                  color='danger'
                  outline
                  label='Cancel'
                  onClick={() =>
                    router.push('/modelos_bim_asbuilt/modelos_bim_asbuilt-list')
                  }
                />
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  );
};

Modelos_bim_asbuiltNew.getLayout = function getLayout(page: ReactElement) {
  return (
    <LayoutAuthenticated permission={'CREATE_MODELOS_BIM_ASBUILT'}>
      {page}
    </LayoutAuthenticated>
  );
};

export default Modelos_bim_asbuiltNew;
