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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    checklist: '',
    
    
    
    
    item_title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sequence_order: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    item_type: 'paperwork',
    
    
    
    
    
    
    
    
    
    instructions: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    attachment_files: [],
    
    
    
    
    
    
    link_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_required: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









  <FormField
      label="ItemTitle"
  >
      <Field
          name="item_title"
          placeholder="ItemTitle"
      />
  </FormField>

































    <FormField
        label="SequenceOrder"
    >
        <Field
            type="number"
            name="sequence_order"
            placeholder="SequenceOrder"
        />
    </FormField>



































  <FormField label="ItemType" labelFor="item_type">
      <Field name="item_type" id="item_type" component="select">
      
        <option value="paperwork">paperwork</option>
      
        <option value="video">video</option>
      
        <option value="read">read</option>
      
        <option value="form">form</option>
      
        <option value="acknowledgement">acknowledgement</option>
      
        <option value="meeting">meeting</option>
      
      </Field>
  </FormField>

















      <FormField label='Instructions' hasTextareaHeight>
          <Field
              name='instructions'
              id='instructions'
              component={RichTextField}
          ></Field>
      </FormField>














































  <FormField>
      <Field
          label='AttachmentFiles'
          color='info'
          icon={mdiUpload}
          path={'checklist_items/attachment_files'}
          name='attachment_files'
          id='attachment_files'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>




  <FormField
      label="LinkURL"
  >
      <Field
          name="link_url"
          placeholder="LinkURL"
      />
  </FormField>











































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

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

export default Checklist_itemsNew
