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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    program: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    province: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    budget_line: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    project_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    implementing_entity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    objectives: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    start_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    end_date: '',
    
    
    
    
    
    
    
    
    
    
    planned_budget: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    currency: 'CDF',
    
    
    
    
    
    
    
    
    
    
    completion_percent: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    risk_level: 'low',
    
    
    
    
    
    
    
    reporting_cycle: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    last_reported_at: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="Program" labelFor="program">
      <Field name="program" id="program" component={SelectField} options={[]} itemRef={'programs'}></Field>
  </FormField>



























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



























  <FormField label="BudgetLine" labelFor="budget_line">
      <Field name="budget_line" id="budget_line" component={SelectField} options={[]} itemRef={'budget_lines'}></Field>
  </FormField>









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



























  <FormField
      label="ProjectCode"
  >
      <Field
          name="project_code"
          placeholder="ProjectCode"
      />
  </FormField>



























  <FormField
      label="ImplementingEntity"
  >
      <Field
          name="implementing_entity"
          placeholder="ImplementingEntity"
      />
  </FormField>































      <FormField label='Objectives' hasTextareaHeight>
          <Field
              name='objectives'
              id='objectives'
              component={RichTextField}
          ></Field>
      </FormField>

































  <FormField
      label="StartDate"
  >
      <Field
          type="datetime-local"
          name="start_date"
          placeholder="StartDate"
      />
  </FormField>



























  <FormField
      label="EndDate"
  >
      <Field
          type="datetime-local"
          name="end_date"
          placeholder="EndDate"
      />
  </FormField>























    <FormField
        label="PlannedBudget"
    >
        <Field
            type="number"
            name="planned_budget"
            placeholder="PlannedBudget"
        />
    </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="CompletionPercent"
    >
        <Field
            type="number"
            name="completion_percent"
            placeholder="CompletionPercent"
        />
    </FormField>



































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="submitted">submitted</option>
      
        <option value="approved">approved</option>
      
        <option value="active">active</option>
      
        <option value="on_hold">on_hold</option>
      
        <option value="completed">completed</option>
      
        <option value="closed">closed</option>
      
      </Field>
  </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="ReportingCycle"
  >
      <Field
          name="reporting_cycle"
          placeholder="ReportingCycle"
      />
  </FormField>





































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

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

export default ProjectsNew
