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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    company: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    agreement: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    billing_frequency: 'daily',
    
    
    
    
    
    
    
    rate: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    next_run_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    last_run_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    active_flag: false,
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="Agreement" labelFor="agreement">
      <Field name="agreement" id="agreement" component={SelectField} options={[]} itemRef={'agreements'}></Field>
  </FormField>























  <FormField label="BillingFrequency" labelFor="billing_frequency">
      <Field name="billing_frequency" id="billing_frequency" component="select">
      
        <option value="daily">daily</option>
      
        <option value="weekly">weekly</option>
      
        <option value="monthly">monthly</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Rate"
    >
        <Field
            type="number"
            name="rate"
            placeholder="Rate"
        />
    </FormField>































  <FormField
      label="NextRunDate"
  >
      <Field
          type="datetime-local"
          name="next_run_date"
          placeholder="NextRunDate"
      />
  </FormField>



























  <FormField
      label="LastRunDate"
  >
      <Field
          type="datetime-local"
          name="last_run_date"
          placeholder="LastRunDate"
      />
  </FormField>

































  <FormField label='Active' labelFor='active_flag'>
      <Field
          name='active_flag'
          id='active_flag'
          component={SwitchField}
      ></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('/recurring_invoice_templates/recurring_invoice_templates-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Recurring_invoice_templatesNew
