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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    booking: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tutor: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    learner: '',
    
    
    
    
    rating: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    communication_rating: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    knowledge_rating: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    punctuality_rating: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    value_rating: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    review_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    would_recommend: false,
    
    
    
    
    
    
    
    
    
    
    tutor_response: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tutor_response_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'pending',
    
    
    
    
    
    
    
    
    
    
    
    
    published_at: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























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















    <FormField
        label="OverallRating"
    >
        <Field
            type="number"
            name="rating"
            placeholder="OverallRating"
        />
    </FormField>



























    <FormField
        label="CommunicationRating"
    >
        <Field
            type="number"
            name="communication_rating"
            placeholder="CommunicationRating"
        />
    </FormField>



























    <FormField
        label="KnowledgeRating"
    >
        <Field
            type="number"
            name="knowledge_rating"
            placeholder="KnowledgeRating"
        />
    </FormField>



























    <FormField
        label="PunctualityRating"
    >
        <Field
            type="number"
            name="punctuality_rating"
            placeholder="PunctualityRating"
        />
    </FormField>



























    <FormField
        label="ValueRating"
    >
        <Field
            type="number"
            name="value_rating"
            placeholder="ValueRating"
        />
    </FormField>























    <FormField label="ReviewText" hasTextareaHeight>
        <Field name="review_text" as="textarea" placeholder="ReviewText" />
    </FormField>









































  <FormField label='WouldRecommend' labelFor='would_recommend'>
      <Field
          name='would_recommend'
          id='would_recommend'
          component={SwitchField}
      ></Field>
  </FormField>













    <FormField label="TutorResponse" hasTextareaHeight>
        <Field name="tutor_response" as="textarea" placeholder="TutorResponse" />
    </FormField>



































  <FormField
      label="TutorResponseAt"
  >
      <Field
          type="datetime-local"
          name="tutor_response_at"
          placeholder="TutorResponseAt"
      />
  </FormField>































  <FormField label="ModerationStatus" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="published">published</option>
      
        <option value="removed">removed</option>
      
      </Field>
  </FormField>























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

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

export default ReviewsNew
