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

const initialValues = {
    
    
    
    
    
    
    
    event_time: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    project: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    action: 'create',
    
    
    
    
    
    
    
    entity_type: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    entity_key: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    old_value_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    new_value_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    change_summary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ip_address: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    user_agent: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    session_key: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    checksum: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    previous_checksum: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/audit_logs/audit_logs-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="EventTime"
  >
      <Field
          type="datetime-local"
          name="event_time"
          placeholder="EventTime"
      />
  </FormField>



































  <FormField label="Organization" labelFor="organization">
      <Field name="organization" id="organization" component={SelectField} options={[]} itemRef={'organizations'}></Field>
  </FormField>



























  <FormField label="Project" labelFor="project">
      <Field name="project" id="project" component={SelectField} options={[]} itemRef={'projects'}></Field>
  </FormField>



























  <FormField label="User" labelFor="user">
      <Field name="user" id="user" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>























  <FormField label="Action" labelFor="action">
      <Field name="action" id="action" component="select">
      
        <option value="create">create</option>
      
        <option value="update">update</option>
      
        <option value="delete">delete</option>
      
        <option value="approve">approve</option>
      
        <option value="reject">reject</option>
      
        <option value="export">export</option>
      
        <option value="import">import</option>
      
        <option value="login">login</option>
      
        <option value="logout">logout</option>
      
        <option value="download">download</option>
      
      </Field>
  </FormField>













  <FormField
      label="EntityType"
  >
      <Field
          name="entity_type"
          placeholder="EntityType"
      />
  </FormField>



























  <FormField
      label="EntityKey"
  >
      <Field
          name="entity_key"
          placeholder="EntityKey"
      />
  </FormField>





























    <FormField label="OldValueJSON" hasTextareaHeight>
        <Field name="old_value_json" as="textarea" placeholder="OldValueJSON" />
    </FormField>



























    <FormField label="NewValueJSON" hasTextareaHeight>
        <Field name="new_value_json" as="textarea" placeholder="NewValueJSON" />
    </FormField>



























    <FormField label="ChangeSummary" hasTextareaHeight>
        <Field name="change_summary" as="textarea" placeholder="ChangeSummary" />
    </FormField>

























  <FormField
      label="IPAddress"
  >
      <Field
          name="ip_address"
          placeholder="IPAddress"
      />
  </FormField>





























    <FormField label="UserAgent" hasTextareaHeight>
        <Field name="user_agent" as="textarea" placeholder="UserAgent" />
    </FormField>

























  <FormField
      label="SessionKey"
  >
      <Field
          name="session_key"
          placeholder="SessionKey"
      />
  </FormField>



























  <FormField
      label="Checksum"
  >
      <Field
          name="checksum"
          placeholder="Checksum"
      />
  </FormField>



























  <FormField
      label="PreviousChecksum"
  >
      <Field
          name="previous_checksum"
          placeholder="PreviousChecksum"
      />
  </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('/audit_logs/audit_logs-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Audit_logsNew
