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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    property: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    unit_type: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    rate_type: 'nightly',
    
    
    
    
    
    
    
    rate_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    valid_from: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    valid_until: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    minimum_stay_nights: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_active: false,
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="Unittype" labelFor="unit_type">
      <Field name="unit_type" id="unit_type" component={SelectField} options={[]} itemRef={'unit_types'}></Field>
  </FormField>























  <FormField label="Ratetype" labelFor="rate_type">
      <Field name="rate_type" id="rate_type" component="select">
      
        <option value="nightly">nightly</option>
      
        <option value="monthly">monthly</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Rateamount"
    >
        <Field
            type="number"
            name="rate_amount"
            placeholder="Rateamount"
        />
    </FormField>































  <FormField
      label="Validfrom"
  >
      <Field
          type="datetime-local"
          name="valid_from"
          placeholder="Validfrom"
      />
  </FormField>



























  <FormField
      label="Validuntil"
  >
      <Field
          type="datetime-local"
          name="valid_until"
          placeholder="Validuntil"
      />
  </FormField>























    <FormField
        label="Minimumstay(nights)"
    >
        <Field
            type="number"
            name="minimum_stay_nights"
            placeholder="Minimumstay(nights)"
        />
    </FormField>





































  <FormField label='Isactive' labelFor='is_active'>
      <Field
          name='is_active'
          id='is_active'
          component={SwitchField}
      ></Field>
  </FormField>













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

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

export default Negotiated_ratesNew
