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/materiais_atividade/materiais_atividadeSlice';
import { useAppDispatch } from '../../stores/hooks';
import { useRouter } from 'next/router';
import moment from 'moment';

const initialValues = {
  quantidade_prevista: '',

  unidade_medida: '',

  tolerancia_estoque: '',

  comentarios: '',

  estrutura: '',

  clientes: '',
};

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

  const handleSubmit = async (data) => {
    await dispatch(create(data));
    await router.push('/materiais_atividade/materiais_atividade-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='QuantidadePrevista'>
                <Field
                  type='number'
                  name='quantidade_prevista'
                  placeholder='QuantidadePrevista'
                />
              </FormField>

              <FormField label='UnidadedeMedida'>
                <Field name='unidade_medida' placeholder='UnidadedeMedida' />
              </FormField>

              <FormField label='TolerânciadeEstoque'>
                <Field
                  type='number'
                  name='tolerancia_estoque'
                  placeholder='TolerânciadeEstoque'
                />
              </FormField>

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

              <FormField label='Estrutura' labelFor='estrutura'>
                <Field
                  name='estrutura'
                  id='estrutura'
                  component={SelectField}
                  options={[]}
                  itemRef={'estrutura_projeto'}
                ></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('/materiais_atividade/materiais_atividade-list')
                  }
                />
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  );
};

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

export default Materiais_atividadeNew;
