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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    request_type: 'quote',
    
    
    
    
    
    
    
    full_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    company_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    phone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    customer_type: 'architect',
    
    
    
    
    
    
    
    
    message_ar: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    interested_stone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    interested_service: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    related_project: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    reference_files: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    lead_status: 'new',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    assigned_to: '',
    
    
    
    
    
    
    
    
    
    preferred_contact_time: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    last_contacted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    internal_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/lead_requests/lead_requests-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="RequestType" labelFor="request_type">
      <Field name="request_type" id="request_type" component="select">
      
        <option value="quote">quote</option>
      
        <option value="callback">callback</option>
      
        <option value="information">information</option>
      
        <option value="appointment">appointment</option>
      
        <option value="custom_order">custom_order</option>
      
      </Field>
  </FormField>













  <FormField
      label="FullName"
  >
      <Field
          name="full_name"
          placeholder="FullName"
      />
  </FormField>



























  <FormField
      label="CompanyName"
  >
      <Field
          name="company_name"
          placeholder="CompanyName"
      />
  </FormField>



























  <FormField
      label="Email"
  >
      <Field
          name="email"
          placeholder="Email"
      />
  </FormField>



























  <FormField
      label="Phone"
  >
      <Field
          name="phone"
          placeholder="Phone"
      />
  </FormField>









































  <FormField label="CustomerType" labelFor="customer_type">
      <Field name="customer_type" id="customer_type" component="select">
      
        <option value="architect">architect</option>
      
        <option value="interior_designer">interior_designer</option>
      
        <option value="contractor">contractor</option>
      
        <option value="developer">developer</option>
      
        <option value="individual">individual</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>















    <FormField label="MessageArabic" hasTextareaHeight>
        <Field name="message_ar" as="textarea" placeholder="MessageArabic" />
    </FormField>











































  <FormField label="InterestedStone" labelFor="interested_stone">
      <Field name="interested_stone" id="interested_stone" component={SelectField} options={[]} itemRef={'stones'}></Field>
  </FormField>



























  <FormField label="InterestedService" labelFor="interested_service">
      <Field name="interested_service" id="interested_service" component={SelectField} options={[]} itemRef={'services'}></Field>
  </FormField>



























  <FormField label="RelatedProject" labelFor="related_project">
      <Field name="related_project" id="related_project" component={SelectField} options={[]} itemRef={'projects'}></Field>
  </FormField>
































  <FormField>
      <Field
          label='ReferenceFiles'
          color='info'
          icon={mdiUpload}
          path={'lead_requests/reference_files'}
          name='reference_files'
          id='reference_files'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>


















  <FormField label="LeadStatus" labelFor="lead_status">
      <Field name="lead_status" id="lead_status" component="select">
      
        <option value="new">new</option>
      
        <option value="qualified">qualified</option>
      
        <option value="in_progress">in_progress</option>
      
        <option value="quoted">quoted</option>
      
        <option value="won">won</option>
      
        <option value="lost">lost</option>
      
        <option value="closed">closed</option>
      
      </Field>
  </FormField>































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



















  <FormField
      label="PreferredContactTime"
  >
      <Field
          type="datetime-local"
          name="preferred_contact_time"
          placeholder="PreferredContactTime"
      />
  </FormField>



























  <FormField
      label="LastContactedAt"
  >
      <Field
          type="datetime-local"
          name="last_contacted_at"
          placeholder="LastContactedAt"
      />
  </FormField>



















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

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

export default Lead_requestsNew
