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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    event: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    model: '',
    
    
    
    
    
    
    
    
    
    detected_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    detection_type: 'anomaly',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'new',
    
    
    
    
    
    
    
    confidence: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    risk_score: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    evidence: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requires_response: false,
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="AIModel" labelFor="model">
      <Field name="model" id="model" component={SelectField} options={[]} itemRef={'ai_models'}></Field>
  </FormField>



















  <FormField
      label="DetectedAt"
  >
      <Field
          type="datetime-local"
          name="detected_at"
          placeholder="DetectedAt"
      />
  </FormField>































  <FormField label="DetectionType" labelFor="detection_type">
      <Field name="detection_type" id="detection_type" component="select">
      
        <option value="anomaly">anomaly</option>
      
        <option value="malware">malware</option>
      
        <option value="phishing">phishing</option>
      
        <option value="ransomware">ransomware</option>
      
        <option value="lateral_movement">lateral_movement</option>
      
        <option value="data_exfiltration">data_exfiltration</option>
      
        <option value="policy_violation">policy_violation</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="new">new</option>
      
        <option value="triaged">triaged</option>
      
        <option value="confirmed">confirmed</option>
      
        <option value="false_positive">false_positive</option>
      
        <option value="suppressed">suppressed</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Confidence"
    >
        <Field
            type="number"
            name="confidence"
            placeholder="Confidence"
        />
    </FormField>



























    <FormField
        label="RiskScore"
    >
        <Field
            type="number"
            name="risk_score"
            placeholder="RiskScore"
        />
    </FormField>





















  <FormField
      label="Title"
  >
      <Field
          name="title"
          placeholder="Title"
      />
  </FormField>





























    <FormField label="Evidence" hasTextareaHeight>
        <Field name="evidence" as="textarea" placeholder="Evidence" />
    </FormField>









































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

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

export default DetectionsNew
