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

const initialValues = {
    
    
    title_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    abstract_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    journal: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    published_at: '',
    
    
    
    
    
    
    
    
    
    
    doi: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    keywords: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    validation_status: 'pending',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    validated_by_user: '',
    
    
    
    
    
    
    validation_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    pdf_file: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    accounts: '',
    
    
    
}


const Scientific_articlesNew = () => {
  const router = useRouter()
  const dispatch = useAppDispatch()

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/scientific_articles/scientific_articles-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="Title"
  >
      <Field
          name="title_text"
          placeholder="Title"
      />
  </FormField>































      <FormField label='Abstract' hasTextareaHeight>
          <Field
              name='abstract_text'
              id='abstract_text'
              component={RichTextField}
          ></Field>
      </FormField>























  <FormField
      label="Journal"
  >
      <Field
          name="journal"
          placeholder="Journal"
      />
  </FormField>





































  <FormField
      label="Publishedat"
  >
      <Field
          type="datetime-local"
          name="published_at"
          placeholder="Publishedat"
      />
  </FormField>

















  <FormField
      label="DOI"
  >
      <Field
          name="doi"
          placeholder="DOI"
      />
  </FormField>



























  <FormField
      label="URL"
  >
      <Field
          name="url"
          placeholder="URL"
      />
  </FormField>





























    <FormField label="Keywords" hasTextareaHeight>
        <Field name="keywords" as="textarea" placeholder="Keywords" />
    </FormField>







































  <FormField label="Validationstatus" labelFor="validation_status">
      <Field name="validation_status" id="validation_status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="validated">validated</option>
      
        <option value="rejected">rejected</option>
      
      </Field>
  </FormField>































  <FormField label="Validatedbyuser" labelFor="validated_by_user">
      <Field name="validated_by_user" id="validated_by_user" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>













      <FormField label='Validationnotes' hasTextareaHeight>
          <Field
              name='validation_notes'
              id='validation_notes'
              component={RichTextField}
          ></Field>
      </FormField>














































  <FormField>
      <Field
          label='PDFfile'
          color='info'
          icon={mdiUpload}
          path={'scientific_articles/pdf_file'}
          name='pdf_file'
          id='pdf_file'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>






















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

Scientific_articlesNew.getLayout = function getLayout(page: ReactElement) {
  return (
      <LayoutAuthenticated
        
          permission={'CREATE_SCIENTIFIC_ARTICLES'}
        
      >
          {page}
      </LayoutAuthenticated>
  )
}

export default Scientific_articlesNew
