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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    customer: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requester_user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    assigned_coordinator_user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    service_package: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    service_type: 'retrieval',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    timing_preference: 'asap',
    
    
    
    
    
    
    
    
    
    
    
    
    scheduled_start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    scheduled_end_at: '',
    
    
    
    
    
    
    
    
    
    
    summary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'submitted',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    priority: 'standard',
    
    
    
    
    
    
    
    estimated_total: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    final_total: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    submitted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    closed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requires_no_contact_coordination: false,
    
    
    
    
    
    
    
    
}


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

    
    

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



























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



























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



























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



























  <FormField label="ServicePackage" labelFor="service_package">
      <Field name="service_package" id="service_package" component={SelectField} options={[]} itemRef={'service_packages'}></Field>
  </FormField>























  <FormField label="ServiceType" labelFor="service_type">
      <Field name="service_type" id="service_type" component="select">
      
        <option value="retrieval">retrieval</option>
      
        <option value="coordination">coordination</option>
      
        <option value="administrative_support">administrative_support</option>
      
        <option value="concierge_assistance">concierge_assistance</option>
      
        <option value="custom_request">custom_request</option>
      
        <option value="communication_support">communication_support</option>
      
        <option value="premium_coordination">premium_coordination</option>
      
      </Field>
  </FormField>



























  <FormField label="TimingPreference" labelFor="timing_preference">
      <Field name="timing_preference" id="timing_preference" component="select">
      
        <option value="asap">asap</option>
      
        <option value="same_day">same_day</option>
      
        <option value="scheduled">scheduled</option>
      
        <option value="flexible">flexible</option>
      
      </Field>
  </FormField>























  <FormField
      label="ScheduledStartAt"
  >
      <Field
          type="datetime-local"
          name="scheduled_start_at"
          placeholder="ScheduledStartAt"
      />
  </FormField>



























  <FormField
      label="ScheduledEndAt"
  >
      <Field
          type="datetime-local"
          name="scheduled_end_at"
          placeholder="ScheduledEndAt"
      />
  </FormField>

















  <FormField
      label="RequestSummary"
  >
      <Field
          name="summary"
          placeholder="RequestSummary"
      />
  </FormField>































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





































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="submitted">submitted</option>
      
        <option value="coordinator_assigned">coordinator_assigned</option>
      
        <option value="in_progress">in_progress</option>
      
        <option value="coordination_active">coordination_active</option>
      
        <option value="review_complete">review_complete</option>
      
        <option value="successfully_closed">successfully_closed</option>
      
        <option value="cancelled">cancelled</option>
      
      </Field>
  </FormField>



























  <FormField label="Priority" labelFor="priority">
      <Field name="priority" id="priority" component="select">
      
        <option value="standard">standard</option>
      
        <option value="rush_priority">rush_priority</option>
      
        <option value="after_hours">after_hours</option>
      
      </Field>
  </FormField>



















    <FormField
        label="EstimatedTotal"
    >
        <Field
            type="number"
            name="estimated_total"
            placeholder="EstimatedTotal"
        />
    </FormField>



























    <FormField
        label="FinalTotal"
    >
        <Field
            type="number"
            name="final_total"
            placeholder="FinalTotal"
        />
    </FormField>































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



























  <FormField
      label="ClosedAt"
  >
      <Field
          type="datetime-local"
          name="closed_at"
          placeholder="ClosedAt"
      />
  </FormField>

































  <FormField label='NoContactCoordination' labelFor='requires_no_contact_coordination'>
      <Field
          name='requires_no_contact_coordination'
          id='requires_no_contact_coordination'
          component={SwitchField}
      ></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('/service_requests/service_requests-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Service_requestsNew
