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

const initialValues = {
  data_alteracao: '',

  tipo_alteracao: '',

  descricao_anterior: '',

  descricao_nova: '',

  motivo_alteracao: '',

  responsavel_alteracao: '',

  comentarios: '',

  estrutura: '',

  clientes: '',
};

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

  const handleSubmit = async (data) => {
    await dispatch(create(data));
    await router.push(
      '/historico_alteracoes_projeto/historico_alteracoes_projeto-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='DatadaAlteração'>
                <Field
                  type='datetime-local'
                  name='data_alteracao'
                  placeholder='DatadaAlteração'
                />
              </FormField>

              <FormField label='TipodeAlteração'>
                <Field name='tipo_alteracao' placeholder='TipodeAlteração' />
              </FormField>

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

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

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

              <FormField label='ResponsávelpelaAlteração'>
                <Field
                  name='responsavel_alteracao'
                  placeholder='ResponsávelpelaAlteração'
                />
              </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(
                      '/historico_alteracoes_projeto/historico_alteracoes_projeto-list',
                    )
                  }
                />
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  );
};

Historico_alteracoes_projetoNew.getLayout = function getLayout(
  page: ReactElement,
) {
  return (
    <LayoutAuthenticated permission={'CREATE_HISTORICO_ALTERACOES_PROJETO'}>
      {page}
    </LayoutAuthenticated>
  );
};

export default Historico_alteracoes_projetoNew;
