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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    severity: 'low',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    category: 'missing_approval',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    linked_workflow: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    linked_control_requirement: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    linked_artifact: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    linked_packet: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    owner_user: '',
    
    
    
    
    
    
    
    
    
    due_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'open',
    
    
    
    
    
    
    
    
    remediation_plan: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    completed_at: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/remediation_items/remediation_items-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="Title"
  >
      <Field
          name="title"
          placeholder="Title"
      />
  </FormField>





























    <FormField label="Description" hasTextareaHeight>
        <Field name="description" as="textarea" placeholder="Description" />
    </FormField>







































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



























  <FormField label="Category" labelFor="category">
      <Field name="category" id="category" component="select">
      
        <option value="missing_approval">missing_approval</option>
      
        <option value="missing_timestamp">missing_timestamp</option>
      
        <option value="no_hr_trigger">no_hr_trigger</option>
      
        <option value="no_group_removal_proof">no_group_removal_proof</option>
      
        <option value="mfa_gap">mfa_gap</option>
      
        <option value="log_retention_gap">log_retention_gap</option>
      
        <option value="manual_process">manual_process</option>
      
        <option value="unclear_source_of_truth">unclear_source_of_truth</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>































  <FormField label="LinkedWorkflow" labelFor="linked_workflow">
      <Field name="linked_workflow" id="linked_workflow" component={SelectField} options={[]} itemRef={'identity_workflows'}></Field>
  </FormField>



























  <FormField label="LinkedControlRequirement" labelFor="linked_control_requirement">
      <Field name="linked_control_requirement" id="linked_control_requirement" component={SelectField} options={[]} itemRef={'control_requirements'}></Field>
  </FormField>



























  <FormField label="LinkedArtifact" labelFor="linked_artifact">
      <Field name="linked_artifact" id="linked_artifact" component={SelectField} options={[]} itemRef={'artifacts'}></Field>
  </FormField>



























  <FormField label="LinkedPacket" labelFor="linked_packet">
      <Field name="linked_packet" id="linked_packet" component={SelectField} options={[]} itemRef={'proof_packets'}></Field>
  </FormField>



























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



















  <FormField
      label="DueDate"
  >
      <Field
          type="datetime-local"
          name="due_date"
          placeholder="DueDate"
      />
  </FormField>































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="open">open</option>
      
        <option value="in_progress">in_progress</option>
      
        <option value="blocked">blocked</option>
      
        <option value="completed">completed</option>
      
        <option value="accepted_risk">accepted_risk</option>
      
      </Field>
  </FormField>















    <FormField label="RemediationPlan" hasTextareaHeight>
        <Field name="remediation_plan" as="textarea" placeholder="RemediationPlan" />
    </FormField>



































  <FormField
      label="CompletedAt"
  >
      <Field
          type="datetime-local"
          name="completed_at"
          placeholder="CompletedAt"
      />
  </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('/remediation_items/remediation_items-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Remediation_itemsNew
