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 = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    company: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    customer: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    site: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    assigned_to: '',
    
    
    
    
    project_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    stage: 'lead',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    priority: 'low',
    
    
    
    
    
    
    
    
    
    
    
    
    requested_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    target_installation_from: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    target_installation_to: '',
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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="Company" labelFor="company">
      <Field name="company" id="company" component={SelectField} options={[]} itemRef={'companies'}></Field>
  </FormField>



























  <FormField label="Customer" labelFor="customer">
      <Field name="customer" id="customer" component={SelectField} options={[]} itemRef={'customers'}></Field>
  </FormField>



























  <FormField label="Site" labelFor="site">
      <Field name="site" id="site" component={SelectField} options={[]} itemRef={'sites'}></Field>
  </FormField>



























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









  <FormField
      label="Projectnumber"
  >
      <Field
          name="project_number"
          placeholder="Projectnumber"
      />
  </FormField>



























  <FormField
      label="Title"
  >
      <Field
          name="title"
          placeholder="Title"
      />
  </FormField>









































  <FormField label="Stage" labelFor="stage">
      <Field name="stage" id="stage" component="select">
      
        <option value="lead">lead</option>
      
        <option value="site_visit">site_visit</option>
      
        <option value="quotation">quotation</option>
      
        <option value="won">won</option>
      
        <option value="lost">lost</option>
      
        <option value="installation">installation</option>
      
        <option value="completed">completed</option>
      
      </Field>
  </FormField>



























  <FormField label="Priority" labelFor="priority">
      <Field name="priority" id="priority" component="select">
      
        <option value="low">low</option>
      
        <option value="normal">normal</option>
      
        <option value="high">high</option>
      
        <option value="urgent">urgent</option>
      
      </Field>
  </FormField>























  <FormField
      label="Requestedat"
  >
      <Field
          type="datetime-local"
          name="requested_at"
          placeholder="Requestedat"
      />
  </FormField>



























  <FormField
      label="Targetinstallationfrom"
  >
      <Field
          type="datetime-local"
          name="target_installation_from"
          placeholder="Targetinstallationfrom"
      />
  </FormField>



























  <FormField
      label="Targetinstallationto"
  >
      <Field
          type="datetime-local"
          name="target_installation_to"
          placeholder="Targetinstallationto"
      />
  </FormField>



















    <FormField label="Description" hasTextareaHeight>
        <Field name="description" as="textarea" placeholder="Description" />
    </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('/projects/projects-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default ProjectsNew
