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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ai_task: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ai_gateway: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'queued',
    
    
    
    
    
    
    
    
    
    
    
    
    requested_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    completed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    prompt_tokens: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    completion_tokens: '',
    
    
    
    
    
    
    
    
    
    
    
    
    estimated_cost: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    model_used: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    error_message: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    contains_private_data: false,
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="AITask" labelFor="ai_task">
      <Field name="ai_task" id="ai_task" component={SelectField} options={[]} itemRef={'ai_tasks'}></Field>
  </FormField>



























  <FormField label="AIGateway" labelFor="ai_gateway">
      <Field name="ai_gateway" id="ai_gateway" component={SelectField} options={[]} itemRef={'ai_gateways'}></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="blocked">blocked</option>
      
      </Field>
  </FormField>























  <FormField
      label="RequestedAt"
  >
      <Field
          type="datetime-local"
          name="requested_at"
          placeholder="RequestedAt"
      />
  </FormField>



























  <FormField
      label="CompletedAt"
  >
      <Field
          type="datetime-local"
          name="completed_at"
          placeholder="CompletedAt"
      />
  </FormField>























    <FormField
        label="PromptTokens"
    >
        <Field
            type="number"
            name="prompt_tokens"
            placeholder="PromptTokens"
        />
    </FormField>



























    <FormField
        label="CompletionTokens"
    >
        <Field
            type="number"
            name="completion_tokens"
            placeholder="CompletionTokens"
        />
    </FormField>



























    <FormField
        label="EstimatedCost"
    >
        <Field
            type="number"
            name="estimated_cost"
            placeholder="EstimatedCost"
        />
    </FormField>





















  <FormField
      label="ModelUsed"
  >
      <Field
          name="model_used"
          placeholder="ModelUsed"
      />
  </FormField>





























    <FormField label="ErrorMessage" hasTextareaHeight>
        <Field name="error_message" as="textarea" placeholder="ErrorMessage" />
    </FormField>









































  <FormField label='ContainsPrivateData' labelFor='contains_private_data'>
      <Field
          name='contains_private_data'
          id='contains_private_data'
          component={SwitchField}
      ></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_requests/ai_requests-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Ai_requestsNew
