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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    kms_type: 'internal',
    
    
    
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    key_uri: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    kms_status: 'active',
    
    
    
    
    
    
    
    
    
    
    
    
    last_rotated_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    auto_rotate_enabled: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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























  <FormField label="KMSType" labelFor="kms_type">
      <Field name="kms_type" id="kms_type" component="select">
      
        <option value="internal">internal</option>
      
        <option value="aws_kms">aws_kms</option>
      
        <option value="gcp_kms">gcp_kms</option>
      
        <option value="azure_key_vault">azure_key_vault</option>
      
        <option value="customer_hsm">customer_hsm</option>
      
      </Field>
  </FormField>













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



























  <FormField
      label="KeyURI"
  >
      <Field
          name="key_uri"
          placeholder="KeyURI"
      />
  </FormField>









































  <FormField label="KMSStatus" labelFor="kms_status">
      <Field name="kms_status" id="kms_status" component="select">
      
        <option value="active">active</option>
      
        <option value="disabled">disabled</option>
      
        <option value="error">error</option>
      
      </Field>
  </FormField>























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

































  <FormField label='AutoRotateEnabled' labelFor='auto_rotate_enabled'>
      <Field
          name='auto_rotate_enabled'
          id='auto_rotate_enabled'
          component={SwitchField}
      ></Field>
  </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('/kms_configs/kms_configs-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Kms_configsNew
