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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    incident: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    playbook: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    action_type: 'isolate_host',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'queued',
    
    
    
    
    
    
    
    
    
    
    
    
    requested_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    executed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requested_by: '',
    
    
    
    
    target: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    action_result: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    automated: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField label="Playbook" labelFor="playbook">
      <Field name="playbook" id="playbook" component={SelectField} options={[]} itemRef={'response_playbooks'}></Field>
  </FormField>























  <FormField label="ActionType" labelFor="action_type">
      <Field name="action_type" id="action_type" component="select">
      
        <option value="isolate_host">isolate_host</option>
      
        <option value="block_ip">block_ip</option>
      
        <option value="block_domain">block_domain</option>
      
        <option value="disable_user">disable_user</option>
      
        <option value="reset_credentials">reset_credentials</option>
      
        <option value="quarantine_file">quarantine_file</option>
      
        <option value="kill_process">kill_process</option>
      
        <option value="revoke_token">revoke_token</option>
      
        <option value="rotate_keys">rotate_keys</option>
      
        <option value="patch">patch</option>
      
        <option value="restore_backup">restore_backup</option>
      
        <option value="notify">notify</option>
      
        <option value="create_ticket">create_ticket</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="queued">queued</option>
      
        <option value="running">running</option>
      
        <option value="succeeded">succeeded</option>
      
        <option value="failed">failed</option>
      
        <option value="canceled">canceled</option>
      
        <option value="requires_approval">requires_approval</option>
      
      </Field>
  </FormField>























  <FormField
      label="RequestedAt"
  >
      <Field
          type="datetime-local"
          name="requested_at"
          placeholder="RequestedAt"
      />
  </FormField>



























  <FormField
      label="ExecutedAt"
  >
      <Field
          type="datetime-local"
          name="executed_at"
          placeholder="ExecutedAt"
      />
  </FormField>



































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









  <FormField
      label="Target"
  >
      <Field
          name="target"
          placeholder="Target"
      />
  </FormField>





























    <FormField label="ActionResult" hasTextareaHeight>
        <Field name="action_result" as="textarea" placeholder="ActionResult" />
    </FormField>









































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

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

export default Response_actionsNew
