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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    budget_program: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    category: 'capex',
    
    
    
    
    
    
    
    approved_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    committed_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    disbursed_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    currency: 'CDF',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'active',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









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



























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





























    <FormField label="Description" hasTextareaHeight>
        <Field name="description" as="textarea" placeholder="Description" />
    </FormField>







































  <FormField label="Category" labelFor="category">
      <Field name="category" id="category" component="select">
      
        <option value="capex">capex</option>
      
        <option value="opex">opex</option>
      
        <option value="grant">grant</option>
      
        <option value="consulting">consulting</option>
      
        <option value="infrastructure">infrastructure</option>
      
        <option value="equipment">equipment</option>
      
        <option value="services">services</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



















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



























    <FormField
        label="CommittedAmount"
    >
        <Field
            type="number"
            name="committed_amount"
            placeholder="CommittedAmount"
        />
    </FormField>



























    <FormField
        label="DisbursedAmount"
    >
        <Field
            type="number"
            name="disbursed_amount"
            placeholder="DisbursedAmount"
        />
    </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="active">active</option>
      
        <option value="inactive">inactive</option>
      
      </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('/budget_lines/budget_lines-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Budget_linesNew
