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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    inquiry_type: 'contact_message',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'new',
    
    
    
    
    
    
    
    full_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    phone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    company_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    country: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    buyer_type: 'roaster',
    
    
    
    
    
    
    
    
    
    message: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requested_region: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requested_lot: '',
    
    
    
    
    target_volume_kg: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    incoterm: 'fob',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    preferred_contact_method: 'email',
    
    
    
    
    
    
    
    
    
    
    
    
    submitted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    assigned_to: '',
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/inquiries/inquiries-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="InquiryType" labelFor="inquiry_type">
      <Field name="inquiry_type" id="inquiry_type" component="select">
      
        <option value="contact_message">contact_message</option>
      
        <option value="request_samples">request_samples</option>
      
        <option value="get_a_quote">get_a_quote</option>
      
        <option value="partner_with_us">partner_with_us</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="new">new</option>
      
        <option value="in_progress">in_progress</option>
      
        <option value="replied">replied</option>
      
        <option value="qualified">qualified</option>
      
        <option value="closed">closed</option>
      
      </Field>
  </FormField>













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



























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



























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



























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



























  <FormField
      label="Country"
  >
      <Field
          name="country"
          placeholder="Country"
      />
  </FormField>









































  <FormField label="BuyerType" labelFor="buyer_type">
      <Field name="buyer_type" id="buyer_type" component="select">
      
        <option value="roaster">roaster</option>
      
        <option value="importer">importer</option>
      
        <option value="distributor">distributor</option>
      
        <option value="specialty_buyer">specialty_buyer</option>
      
        <option value="wholesaler">wholesaler</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>

















      <FormField label='Message' hasTextareaHeight>
          <Field
              name='message'
              id='message'
              component={RichTextField}
          ></Field>
      </FormField>









































  <FormField label="RequestedRegion" labelFor="requested_region">
      <Field name="requested_region" id="requested_region" component={SelectField} options={[]} itemRef={'coffee_regions'}></Field>
  </FormField>



























  <FormField label="RequestedLot" labelFor="requested_lot">
      <Field name="requested_lot" id="requested_lot" component={SelectField} options={[]} itemRef={'coffee_lots'}></Field>
  </FormField>















    <FormField
        label="TargetVolume(kg)"
    >
        <Field
            type="number"
            name="target_volume_kg"
            placeholder="TargetVolume(kg)"
        />
    </FormField>



































  <FormField label="Incoterm" labelFor="incoterm">
      <Field name="incoterm" id="incoterm" component="select">
      
        <option value="fob">fob</option>
      
        <option value="cif">cif</option>
      
        <option value="cfr">cfr</option>
      
        <option value="exw">exw</option>
      
        <option value="dap">dap</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



























  <FormField label="PreferredContactMethod" labelFor="preferred_contact_method">
      <Field name="preferred_contact_method" id="preferred_contact_method" component="select">
      
        <option value="email">email</option>
      
        <option value="phone">phone</option>
      
        <option value="whatsapp">whatsapp</option>
      
      </Field>
  </FormField>























  <FormField
      label="SubmittedAt"
  >
      <Field
          type="datetime-local"
          name="submitted_at"
          placeholder="SubmittedAt"
      />
  </FormField>



































  <FormField label="AssignedTo" labelFor="assigned_to">
      <Field name="assigned_to" id="assigned_to" component={SelectField} options={[]} itemRef={'users'}></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('/inquiries/inquiries-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default InquiriesNew
