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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    project: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    source_type: 'url',
    
    
    
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    attachments: [],
    
    
    
    
    
    
    
    raw_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    extracted_summary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ingestion_status: 'queued',
    
    
    
    
    
    
    
    
    
    
    
    
    ingested_at: '',
    
    
    
    
    
    
    
    
    
    
    tags: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/source_items/source_items-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="Project" labelFor="project">
      <Field name="project" id="project" component={SelectField} options={[]} itemRef={'projects'}></Field>
  </FormField>























  <FormField label="SourceType" labelFor="source_type">
      <Field name="source_type" id="source_type" component="select">
      
        <option value="url">url</option>
      
        <option value="article">article</option>
      
        <option value="pdf">pdf</option>
      
        <option value="doc">doc</option>
      
        <option value="ppt">ppt</option>
      
        <option value="text_note">text_note</option>
      
        <option value="spreadsheet">spreadsheet</option>
      
      </Field>
  </FormField>













  <FormField
      label="Title"
  >
      <Field
          name="title"
          placeholder="Title"
      />
  </FormField>



























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


















































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






    <FormField label="RawText" hasTextareaHeight>
        <Field name="raw_text" as="textarea" placeholder="RawText" />
    </FormField>





























      <FormField label='ExtractedSummary' hasTextareaHeight>
          <Field
              name='extracted_summary'
              id='extracted_summary'
              component={RichTextField}
          ></Field>
      </FormField>





































  <FormField label="IngestionStatus" labelFor="ingestion_status">
      <Field name="ingestion_status" id="ingestion_status" component="select">
      
        <option value="queued">queued</option>
      
        <option value="processing">processing</option>
      
        <option value="completed">completed</option>
      
        <option value="failed">failed</option>
      
      </Field>
  </FormField>























  <FormField
      label="IngestedAt"
  >
      <Field
          type="datetime-local"
          name="ingested_at"
          placeholder="IngestedAt"
      />
  </FormField>

















  <FormField
      label="Tags"
  >
      <Field
          name="tags"
          placeholder="Tags"
      />
  </FormField>













































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

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

export default Source_itemsNew
