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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    company: '',
    
    
    
    
    branch_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    address_line1: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    address_line2: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    city: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    state: 'andaman_and_nicobar_islands',
    
    
    
    
    
    
    
    pincode: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    gst_registration_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_head_office: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









  <FormField
      label="BranchName"
  >
      <Field
          name="branch_name"
          placeholder="BranchName"
      />
  </FormField>



























  <FormField
      label="AddressLine1"
  >
      <Field
          name="address_line1"
          placeholder="AddressLine1"
      />
  </FormField>



























  <FormField
      label="AddressLine2"
  >
      <Field
          name="address_line2"
          placeholder="AddressLine2"
      />
  </FormField>



























  <FormField
      label="City"
  >
      <Field
          name="city"
          placeholder="City"
      />
  </FormField>









































  <FormField label="State" labelFor="state">
      <Field name="state" id="state" component="select">
      
        <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="Pincode"
  >
      <Field
          name="pincode"
          placeholder="Pincode"
      />
  </FormField>



























  <FormField
      label="GSTRegistrationNumber"
  >
      <Field
          name="gst_registration_number"
          placeholder="GSTRegistrationNumber"
      />
  </FormField>











































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

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

export default BranchesNew
