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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    learner: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tutor: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    gig: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    gig_level: '',
    
    
    
    
    
    
    
    level_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    level_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    price: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    platform_fee: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tutor_payout: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'pending_acceptance',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    escrow_status: 'held',
    
    
    
    
    
    
    
    
    
    
    
    
    scheduled_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    accepted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    milestone_submitted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    auto_release_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    completed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    deliverable_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    deliverable_files: [],
    
    
    
    
    
    
    
    
    
    revision_count: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    revision_reason: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    jitsi_meet_meeting_id: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    jitsi_meet_password: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    admin_note: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























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



























  <FormField label="Gig" labelFor="gig">
      <Field name="gig" id="gig" component={SelectField} options={[]} itemRef={'gigs'}></Field>
  </FormField>



























  <FormField label="GigLevel" labelFor="gig_level">
      <Field name="gig_level" id="gig_level" component={SelectField} options={[]} itemRef={'gig_levels'}></Field>
  </FormField>















    <FormField
        label="LevelNumberSnapshot"
    >
        <Field
            type="number"
            name="level_number"
            placeholder="LevelNumberSnapshot"
        />
    </FormField>





















  <FormField
      label="LevelNameSnapshot"
  >
      <Field
          name="level_name"
          placeholder="LevelNameSnapshot"
      />
  </FormField>

































    <FormField
        label="Price"
    >
        <Field
            type="number"
            name="price"
            placeholder="Price"
        />
    </FormField>



























    <FormField
        label="PlatformFee"
    >
        <Field
            type="number"
            name="platform_fee"
            placeholder="PlatformFee"
        />
    </FormField>



























    <FormField
        label="TutorPayout"
    >
        <Field
            type="number"
            name="tutor_payout"
            placeholder="TutorPayout"
        />
    </FormField>



































  <FormField label="BookingStatus" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="pending_acceptance">pending_acceptance</option>
      
        <option value="active">active</option>
      
        <option value="milestone_submitted">milestone_submitted</option>
      
        <option value="revision_requested">revision_requested</option>
      
        <option value="completed">completed</option>
      
        <option value="disputed">disputed</option>
      
        <option value="cancelled">cancelled</option>
      
        <option value="refunded">refunded</option>
      
      </Field>
  </FormField>



























  <FormField label="EscrowStatus" labelFor="escrow_status">
      <Field name="escrow_status" id="escrow_status" component="select">
      
        <option value="held">held</option>
      
        <option value="released">released</option>
      
        <option value="refunded">refunded</option>
      
      </Field>
  </FormField>























  <FormField
      label="ScheduledAt"
  >
      <Field
          type="datetime-local"
          name="scheduled_at"
          placeholder="ScheduledAt"
      />
  </FormField>



























  <FormField
      label="AcceptedAt"
  >
      <Field
          type="datetime-local"
          name="accepted_at"
          placeholder="AcceptedAt"
      />
  </FormField>



























  <FormField
      label="MilestoneSubmittedAt"
  >
      <Field
          type="datetime-local"
          name="milestone_submitted_at"
          placeholder="MilestoneSubmittedAt"
      />
  </FormField>



























  <FormField
      label="AutoReleaseAt"
  >
      <Field
          type="datetime-local"
          name="auto_release_at"
          placeholder="AutoReleaseAt"
      />
  </FormField>



























  <FormField
      label="CompletedAt"
  >
      <Field
          type="datetime-local"
          name="completed_at"
          placeholder="CompletedAt"
      />
  </FormField>



















    <FormField label="DeliverableNotes" hasTextareaHeight>
        <Field name="deliverable_notes" as="textarea" placeholder="DeliverableNotes" />
    </FormField>
















































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










    <FormField
        label="RevisionCount"
    >
        <Field
            type="number"
            name="revision_count"
            placeholder="RevisionCount"
        />
    </FormField>























    <FormField label="RevisionReason" hasTextareaHeight>
        <Field name="revision_reason" as="textarea" placeholder="RevisionReason" />
    </FormField>

























  <FormField
      label="JitsiMeetingID"
  >
      <Field
          name="jitsi_meet_meeting_id"
          placeholder="JitsiMeetingID"
      />
  </FormField>



























  <FormField
      label="JitsiMeetingPassword"
  >
      <Field
          name="jitsi_meet_password"
          placeholder="JitsiMeetingPassword"
      />
  </FormField>





























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

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

export default BookingsNew
