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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    project: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    phase_type: 'exploration_scoping',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'not_started',
    
    
    
    
    
    
    
    
    
    
    
    
    start_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    target_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approved_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approved_by: '',
    
    
    
    
    
    
    gate_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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























  <FormField label="PhaseType" labelFor="phase_type">
      <Field name="phase_type" id="phase_type" component="select">
      
        <option value="exploration_scoping">exploration_scoping</option>
      
        <option value="pre_feasibility">pre_feasibility</option>
      
        <option value="feasibility">feasibility</option>
      
        <option value="detailed_engineering">detailed_engineering</option>
      
        <option value="construction">construction</option>
      
        <option value="commissioning">commissioning</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="not_started">not_started</option>
      
        <option value="in_progress">in_progress</option>
      
        <option value="on_hold">on_hold</option>
      
        <option value="completed">completed</option>
      
        <option value="approved">approved</option>
      
      </Field>
  </FormField>























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



























  <FormField
      label="TargetDate"
  >
      <Field
          type="datetime-local"
          name="target_date"
          placeholder="TargetDate"
      />
  </FormField>



























  <FormField
      label="ApprovedAt"
  >
      <Field
          type="datetime-local"
          name="approved_at"
          placeholder="ApprovedAt"
      />
  </FormField>



































  <FormField label="ApprovedBy" labelFor="approved_by">
      <Field name="approved_by" id="approved_by" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>













      <FormField label='GateNotes' hasTextareaHeight>
          <Field
              name='gate_notes'
              id='gate_notes'
              component={RichTextField}
          ></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('/project_phases/project_phases-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Project_phasesNew
