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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    provider: '',
    
    
    
    
    label: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    key_fingerprint: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    key_status: 'active',
    
    
    
    
    
    
    
    
    
    
    
    
    last_rotated_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    expires_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_primary: false,
    
    
    
    
    
    
    
    
    
    
    
    
    requests_per_minute_limit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    daily_request_limit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









  <FormField
      label="Label"
  >
      <Field
          name="label"
          placeholder="Label"
      />
  </FormField>



























  <FormField
      label="KeyFingerprint"
  >
      <Field
          name="key_fingerprint"
          placeholder="KeyFingerprint"
      />
  </FormField>









































  <FormField label="KeyStatus" labelFor="key_status">
      <Field name="key_status" id="key_status" component="select">
      
        <option value="active">active</option>
      
        <option value="disabled">disabled</option>
      
        <option value="rate_limited">rate_limited</option>
      
        <option value="compromised">compromised</option>
      
      </Field>
  </FormField>























  <FormField
      label="LastRotatedAt"
  >
      <Field
          type="datetime-local"
          name="last_rotated_at"
          placeholder="LastRotatedAt"
      />
  </FormField>



























  <FormField
      label="ExpiresAt"
  >
      <Field
          type="datetime-local"
          name="expires_at"
          placeholder="ExpiresAt"
      />
  </FormField>

































  <FormField label='IsPrimary' labelFor='is_primary'>
      <Field
          name='is_primary'
          id='is_primary'
          component={SwitchField}
      ></Field>
  </FormField>

















    <FormField
        label="RequestsPerMinuteLimit"
    >
        <Field
            type="number"
            name="requests_per_minute_limit"
            placeholder="RequestsPerMinuteLimit"
        />
    </FormField>



























    <FormField
        label="DailyRequestLimit"
    >
        <Field
            type="number"
            name="daily_request_limit"
            placeholder="DailyRequestLimit"
        />
    </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('/llm_api_keys/llm_api_keys-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Llm_api_keysNew
