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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    data_source: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    asset: '',
    
    
    
    
    
    
    
    
    
    observed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    event_type: 'auth',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    severity: 'informational',
    
    
    
    
    
    
    
    summary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    raw_payload: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    hash: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    flagged: false,
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="DataSource" labelFor="data_source">
      <Field name="data_source" id="data_source" component={SelectField} options={[]} itemRef={'data_sources'}></Field>
  </FormField>



























  <FormField label="Asset" labelFor="asset">
      <Field name="asset" id="asset" component={SelectField} options={[]} itemRef={'assets'}></Field>
  </FormField>



















  <FormField
      label="ObservedAt"
  >
      <Field
          type="datetime-local"
          name="observed_at"
          placeholder="ObservedAt"
      />
  </FormField>































  <FormField label="EventType" labelFor="event_type">
      <Field name="event_type" id="event_type" component="select">
      
        <option value="auth">auth</option>
      
        <option value="process">process</option>
      
        <option value="network">network</option>
      
        <option value="dns">dns</option>
      
        <option value="http">http</option>
      
        <option value="email">email</option>
      
        <option value="file">file</option>
      
        <option value="cloud">cloud</option>
      
        <option value="kubernetes">kubernetes</option>
      
        <option value="iam">iam</option>
      
        <option value="vulnerability">vulnerability</option>
      
        <option value="threat_feed">threat_feed</option>
      
        <option value="dark_web">dark_web</option>
      
      </Field>
  </FormField>



























  <FormField label="Severity" labelFor="severity">
      <Field name="severity" id="severity" component="select">
      
        <option value="informational">informational</option>
      
        <option value="low">low</option>
      
        <option value="medium">medium</option>
      
        <option value="high">high</option>
      
        <option value="critical">critical</option>
      
      </Field>
  </FormField>













  <FormField
      label="Summary"
  >
      <Field
          name="summary"
          placeholder="Summary"
      />
  </FormField>





























    <FormField label="RawPayload" hasTextareaHeight>
        <Field name="raw_payload" as="textarea" placeholder="RawPayload" />
    </FormField>

























  <FormField
      label="EventHash"
  >
      <Field
          name="hash"
          placeholder="EventHash"
      />
  </FormField>











































  <FormField label='Flagged' labelFor='flagged'>
      <Field
          name='flagged'
          id='flagged'
          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('/telemetry_events/telemetry_events-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Telemetry_eventsNew
