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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    knowledge_graph_item: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    external_integration: '',
    
    
    
    
    external_task_key: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    task_status: 'queued',
    
    
    
    
    
    
    
    
    
    
    
    
    created_at_remote: '',
    
    
    
    
    
    
    
    
    
    
    
    failure_reason: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField label="ExternalIntegration" labelFor="external_integration">
      <Field name="external_integration" id="external_integration" component={SelectField} options={[]} itemRef={'external_integrations'}></Field>
  </FormField>









  <FormField
      label="ExternalTaskKey"
  >
      <Field
          name="external_task_key"
          placeholder="ExternalTaskKey"
      />
  </FormField>



























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





























    <FormField label="Description" hasTextareaHeight>
        <Field name="description" as="textarea" placeholder="Description" />
    </FormField>







































  <FormField label="TaskStatus" labelFor="task_status">
      <Field name="task_status" id="task_status" component="select">
      
        <option value="queued">queued</option>
      
        <option value="created">created</option>
      
        <option value="failed">failed</option>
      
        <option value="closed">closed</option>
      
      </Field>
  </FormField>























  <FormField
      label="CreatedAt(Remote)"
  >
      <Field
          type="datetime-local"
          name="created_at_remote"
          placeholder="CreatedAt(Remote)"
      />
  </FormField>



















    <FormField label="FailureReason" hasTextareaHeight>
        <Field name="failure_reason" as="textarea" placeholder="FailureReason" />
    </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('/tasks/tasks-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default TasksNew
