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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    workspace: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    source: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    job_type: 'summarize',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'queued',
    
    
    
    
    
    
    
    provider: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    model: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    cost_estimate: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    error_details: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    started_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    finished_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField label="Source" labelFor="source">
      <Field name="source" id="source" component={SelectField} options={[]} itemRef={'sources'}></Field>
  </FormField>























  <FormField label="JobType" labelFor="job_type">
      <Field name="job_type" id="job_type" component="select">
      
        <option value="summarize">summarize</option>
      
        <option value="explain">explain</option>
      
        <option value="concept_map">concept_map</option>
      
        <option value="study_guide">study_guide</option>
      
        <option value="qa_index">qa_index</option>
      
        <option value="key_concepts">key_concepts</option>
      
        <option value="generate_flashcards">generate_flashcards</option>
      
        <option value="generate_quiz">generate_quiz</option>
      
        <option value="generate_test">generate_test</option>
      
        <option value="generate_open_questions">generate_open_questions</option>
      
        <option value="generate_exercises">generate_exercises</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="queued">queued</option>
      
        <option value="running">running</option>
      
        <option value="succeeded">succeeded</option>
      
        <option value="failed">failed</option>
      
        <option value="canceled">canceled</option>
      
      </Field>
  </FormField>













  <FormField
      label="Provider"
  >
      <Field
          name="provider"
          placeholder="Provider"
      />
  </FormField>



























  <FormField
      label="Model"
  >
      <Field
          name="model"
          placeholder="Model"
      />
  </FormField>

































    <FormField
        label="CostEstimate"
    >
        <Field
            type="number"
            name="cost_estimate"
            placeholder="CostEstimate"
        />
    </FormField>























    <FormField label="ErrorDetails" hasTextareaHeight>
        <Field name="error_details" as="textarea" placeholder="ErrorDetails" />
    </FormField>



































  <FormField
      label="StartedAt"
  >
      <Field
          type="datetime-local"
          name="started_at"
          placeholder="StartedAt"
      />
  </FormField>



























  <FormField
      label="FinishedAt"
  >
      <Field
          type="datetime-local"
          name="finished_at"
          placeholder="FinishedAt"
      />
  </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('/ai_jobs/ai_jobs-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Ai_jobsNew
