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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    license_customer: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    product: '',
    
    
    
    
    license_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    license_type: 'software_lock',
    
    
    
    
    
    
    
    
    
    
    
    
    issued_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    expires_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'active',
    
    
    
    
    
    
    
    hardware_fingerprint: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    server_fingerprint: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    db_fingerprint: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    allowed_clients: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    allow_updates: false,
    
    
    
    
    
    
    
    
    
    
    last_error_message: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="Product" labelFor="product">
      <Field name="product" id="product" component={SelectField} options={[]} itemRef={'license_products'}></Field>
  </FormField>









  <FormField
      label="LicenseCode"
  >
      <Field
          name="license_code"
          placeholder="LicenseCode"
      />
  </FormField>









































  <FormField label="LicenseType" labelFor="license_type">
      <Field name="license_type" id="license_type" component="select">
      
        <option value="software_lock">software_lock</option>
      
        <option value="network_dongle">network_dongle</option>
      
      </Field>
  </FormField>























  <FormField
      label="IssuedAt"
  >
      <Field
          type="datetime-local"
          name="issued_at"
          placeholder="IssuedAt"
      />
  </FormField>



























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































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="active">active</option>
      
        <option value="revoked">revoked</option>
      
        <option value="expired">expired</option>
      
      </Field>
  </FormField>













  <FormField
      label="HardwareFingerprint"
  >
      <Field
          name="hardware_fingerprint"
          placeholder="HardwareFingerprint"
      />
  </FormField>



























  <FormField
      label="ServerFingerprint"
  >
      <Field
          name="server_fingerprint"
          placeholder="ServerFingerprint"
      />
  </FormField>



























  <FormField
      label="DatabaseFingerprint"
  >
      <Field
          name="db_fingerprint"
          placeholder="DatabaseFingerprint"
      />
  </FormField>

































    <FormField
        label="AllowedClients"
    >
        <Field
            type="number"
            name="allowed_clients"
            placeholder="AllowedClients"
        />
    </FormField>





































  <FormField label='AllowUpdates' labelFor='allow_updates'>
      <Field
          name='allow_updates'
          id='allow_updates'
          component={SwitchField}
      ></Field>
  </FormField>













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

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

export default License_keysNew
