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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    booking: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    opened_by: '',
    
    
    
    
    reason: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'open',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tutor_evidence: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    learner_evidence: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    resolution: 'none',
    
    
    
    
    
    
    
    
    admin_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    resolved_by: '',
    
    
    
    
    
    
    
    
    
    resolved_at: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























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









  <FormField
      label="Reason"
  >
      <Field
          name="reason"
          placeholder="Reason"
      />
  </FormField>





























    <FormField label="Description" hasTextareaHeight>
        <Field name="description" as="textarea" placeholder="Description" />
    </FormField>







































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="open">open</option>
      
        <option value="under_review">under_review</option>
      
        <option value="resolved">resolved</option>
      
      </Field>
  </FormField>




































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



























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


















  <FormField label="Resolution" labelFor="resolution">
      <Field name="resolution" id="resolution" component="select">
      
        <option value="none">none</option>
      
        <option value="tutor_favor">tutor_favor</option>
      
        <option value="learner_favor">learner_favor</option>
      
        <option value="split">split</option>
      
      </Field>
  </FormField>















    <FormField label="AdminNotes" hasTextareaHeight>
        <Field name="admin_notes" as="textarea" placeholder="AdminNotes" />
    </FormField>











































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



















  <FormField
      label="ResolvedAt"
  >
      <Field
          type="datetime-local"
          name="resolved_at"
          placeholder="ResolvedAt"
      />
  </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('/disputes/disputes-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default DisputesNew
