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: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    project_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    location_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    latitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    longitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    commodity: 'gold',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    start_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    target_completion_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    team_members: [],
    
    
}


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="ProjectName"
  >
      <Field
          name="name"
          placeholder="ProjectName"
      />
  </FormField>



























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



























  <FormField
      label="LocationName"
  >
      <Field
          name="location_name"
          placeholder="LocationName"
      />
  </FormField>

































    <FormField
        label="Latitude"
    >
        <Field
            type="number"
            name="latitude"
            placeholder="Latitude"
        />
    </FormField>



























    <FormField
        label="Longitude"
    >
        <Field
            type="number"
            name="longitude"
            placeholder="Longitude"
        />
    </FormField>



































  <FormField label="Commodity" labelFor="commodity">
      <Field name="commodity" id="commodity" component="select">
      
        <option value="gold">gold</option>
      
        <option value="silver">silver</option>
      
        <option value="copper">copper</option>
      
        <option value="polymetallic">polymetallic</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="active">active</option>
      
        <option value="on_hold">on_hold</option>
      
        <option value="completed">completed</option>
      
        <option value="archived">archived</option>
      
      </Field>
  </FormField>























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



























  <FormField
      label="TargetCompletionDate"
  >
      <Field
          type="datetime-local"
          name="target_completion_date"
          placeholder="TargetCompletionDate"
      />
  </FormField>





















      <FormField label='Description' hasTextareaHeight>
          <Field
              name='description'
              id='description'
              component={RichTextField}
          ></Field>
      </FormField>











































    <FormField label='TeamMembers' labelFor='team_members'>
        <Field
            name='team_members'
            id='team_members'
            itemRef={'users'}
            options={[]}
            component={SelectFieldMany}>
        </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('/projects/projects-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default ProjectsNew
