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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    category: '',
    
    
    
    
    template_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    frequency: 'one_time',
    
    
    
    
    
    
    
    
    
    
    due_day_of_month: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    due_month_of_year: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    grace_days: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    applies_to_business_type: 'any',
    
    
    
    
    
    
    
    applies_to_industry: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    applies_to_state: 'any',
    
    
    
    
    
    
    
    
    
    
    min_employee_count: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    max_employee_count: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    risk_level: 'low',
    
    
    
    
    
    
    
    legal_reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    instructions: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_active: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









  <FormField
      label="TemplateName"
  >
      <Field
          name="template_name"
          placeholder="TemplateName"
      />
  </FormField>



























  <FormField
      label="Code"
  >
      <Field
          name="code"
          placeholder="Code"
      />
  </FormField>









































  <FormField label="Frequency" labelFor="frequency">
      <Field name="frequency" id="frequency" component="select">
      
        <option value="one_time">one_time</option>
      
        <option value="monthly">monthly</option>
      
        <option value="quarterly">quarterly</option>
      
        <option value="half_yearly">half_yearly</option>
      
        <option value="yearly">yearly</option>
      
        <option value="event_based">event_based</option>
      
      </Field>
  </FormField>



















    <FormField
        label="DueDayOfMonth"
    >
        <Field
            type="number"
            name="due_day_of_month"
            placeholder="DueDayOfMonth"
        />
    </FormField>



























    <FormField
        label="DueMonthOfYear"
    >
        <Field
            type="number"
            name="due_month_of_year"
            placeholder="DueMonthOfYear"
        />
    </FormField>



























    <FormField
        label="GraceDays"
    >
        <Field
            type="number"
            name="grace_days"
            placeholder="GraceDays"
        />
    </FormField>



































  <FormField label="AppliesToBusinessType" labelFor="applies_to_business_type">
      <Field name="applies_to_business_type" id="applies_to_business_type" component="select">
      
        <option value="any">any</option>
      
        <option value="proprietorship">proprietorship</option>
      
        <option value="partnership">partnership</option>
      
        <option value="llp">llp</option>
      
        <option value="private_limited">private_limited</option>
      
        <option value="public_limited">public_limited</option>
      
        <option value="opc">opc</option>
      
        <option value="huf">huf</option>
      
        <option value="trust">trust</option>
      
        <option value="society">society</option>
      
        <option value="ngo">ngo</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>













  <FormField
      label="AppliesToIndustry"
  >
      <Field
          name="applies_to_industry"
          placeholder="AppliesToIndustry"
      />
  </FormField>









































  <FormField label="AppliesToState" labelFor="applies_to_state">
      <Field name="applies_to_state" id="applies_to_state" component="select">
      
        <option value="any">any</option>
      
        <option value="andaman_and_nicobar_islands">andaman_and_nicobar_islands</option>
      
        <option value="andhra_pradesh">andhra_pradesh</option>
      
        <option value="arunachal_pradesh">arunachal_pradesh</option>
      
        <option value="assam">assam</option>
      
        <option value="bihar">bihar</option>
      
        <option value="chandigarh">chandigarh</option>
      
        <option value="chhattisgarh">chhattisgarh</option>
      
        <option value="dadra_and_nagar_haveli_and_daman_and_diu">dadra_and_nagar_haveli_and_daman_and_diu</option>
      
        <option value="delhi">delhi</option>
      
        <option value="goa">goa</option>
      
        <option value="gujarat">gujarat</option>
      
        <option value="haryana">haryana</option>
      
        <option value="himachal_pradesh">himachal_pradesh</option>
      
        <option value="jammu_and_kashmir">jammu_and_kashmir</option>
      
        <option value="jharkhand">jharkhand</option>
      
        <option value="karnataka">karnataka</option>
      
        <option value="kerala">kerala</option>
      
        <option value="ladakh">ladakh</option>
      
        <option value="lakshadweep">lakshadweep</option>
      
        <option value="madhya_pradesh">madhya_pradesh</option>
      
        <option value="maharashtra">maharashtra</option>
      
        <option value="manipur">manipur</option>
      
        <option value="meghalaya">meghalaya</option>
      
        <option value="mizoram">mizoram</option>
      
        <option value="nagaland">nagaland</option>
      
        <option value="odisha">odisha</option>
      
        <option value="puducherry">puducherry</option>
      
        <option value="punjab">punjab</option>
      
        <option value="rajasthan">rajasthan</option>
      
        <option value="sikkim">sikkim</option>
      
        <option value="tamil_nadu">tamil_nadu</option>
      
        <option value="telangana">telangana</option>
      
        <option value="tripura">tripura</option>
      
        <option value="uttar_pradesh">uttar_pradesh</option>
      
        <option value="uttarakhand">uttarakhand</option>
      
        <option value="west_bengal">west_bengal</option>
      
      </Field>
  </FormField>



















    <FormField
        label="MinEmployeeCount"
    >
        <Field
            type="number"
            name="min_employee_count"
            placeholder="MinEmployeeCount"
        />
    </FormField>



























    <FormField
        label="MaxEmployeeCount"
    >
        <Field
            type="number"
            name="max_employee_count"
            placeholder="MaxEmployeeCount"
        />
    </FormField>



































  <FormField label="RiskLevel" labelFor="risk_level">
      <Field name="risk_level" id="risk_level" 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="LegalReference"
  >
      <Field
          name="legal_reference"
          placeholder="LegalReference"
      />
  </FormField>































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







































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

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

export default Compliance_templatesNew
