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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    grant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    province: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    beneficiary_type: 'ngo',
    
    
    
    
    
    
    
    registration_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    contact_email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    contact_phone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approved_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    currency: 'CDF',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'applicant',
    
    
    
    
    
    
    
    
    
    
    
    
    approved_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField label="Province" labelFor="province">
      <Field name="province" id="province" component={SelectField} options={[]} itemRef={'provinces'}></Field>
  </FormField>









  <FormField
      label="BeneficiaryName"
  >
      <Field
          name="name"
          placeholder="BeneficiaryName"
      />
  </FormField>









































  <FormField label="BeneficiaryType" labelFor="beneficiary_type">
      <Field name="beneficiary_type" id="beneficiary_type" component="select">
      
        <option value="ngo">ngo</option>
      
        <option value="school">school</option>
      
        <option value="community_center">community_center</option>
      
        <option value="local_government">local_government</option>
      
        <option value="public_institution">public_institution</option>
      
        <option value="operator">operator</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>













  <FormField
      label="RegistrationNumber"
  >
      <Field
          name="registration_number"
          placeholder="RegistrationNumber"
      />
  </FormField>



























  <FormField
      label="ContactEmail"
  >
      <Field
          name="contact_email"
          placeholder="ContactEmail"
      />
  </FormField>



























  <FormField
      label="ContactPhone"
  >
      <Field
          name="contact_phone"
          placeholder="ContactPhone"
      />
  </FormField>

































    <FormField
        label="ApprovedAmount"
    >
        <Field
            type="number"
            name="approved_amount"
            placeholder="ApprovedAmount"
        />
    </FormField>



































  <FormField label="Currency" labelFor="currency">
      <Field name="currency" id="currency" component="select">
      
        <option value="CDF">CDF</option>
      
        <option value="USD">USD</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="applicant">applicant</option>
      
        <option value="under_review">under_review</option>
      
        <option value="approved">approved</option>
      
        <option value="rejected">rejected</option>
      
        <option value="active">active</option>
      
        <option value="suspended">suspended</option>
      
        <option value="closed">closed</option>
      
      </Field>
  </FormField>























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

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

export default BeneficiariesNew
