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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    document_type: 'invoice_pdf',
    
    
    
    
    
    
    
    file_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    mime_type: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    file_size_bytes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    storage_key: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    uploaded_by: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    booking_request: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reservation: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    service_request: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    invoice: '',
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_private: false,
    
    
    
    
    
    
    
    
}


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

    
    

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























  <FormField label="Documenttype" labelFor="document_type">
      <Field name="document_type" id="document_type" component="select">
      
        <option value="invoice_pdf">invoice_pdf</option>
      
        <option value="guest_id">guest_id</option>
      
        <option value="contract">contract</option>
      
        <option value="approval_attachment">approval_attachment</option>
      
        <option value="arrival_instructions">arrival_instructions</option>
      
        <option value="checklist">checklist</option>
      
        <option value="inspection_report">inspection_report</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>













  <FormField
      label="Filename"
  >
      <Field
          name="file_name"
          placeholder="Filename"
      />
  </FormField>



























  <FormField
      label="MIMEtype"
  >
      <Field
          name="mime_type"
          placeholder="MIMEtype"
      />
  </FormField>

































    <FormField
        label="Filesize(bytes)"
    >
        <Field
            type="number"
            name="file_size_bytes"
            placeholder="Filesize(bytes)"
        />
    </FormField>





















  <FormField
      label="Storagekey"
  >
      <Field
          name="storage_key"
          placeholder="Storagekey"
      />
  </FormField>



























  <FormField
      label="PublicURL"
  >
      <Field
          name="public_url"
          placeholder="PublicURL"
      />
  </FormField>













































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



























  <FormField label="Organization" labelFor="organization">
      <Field name="organization" id="organization" component={SelectField} options={[]} itemRef={'organizations'}></Field>
  </FormField>



























  <FormField label="Bookingrequest" labelFor="booking_request">
      <Field name="booking_request" id="booking_request" component={SelectField} options={[]} itemRef={'booking_requests'}></Field>
  </FormField>



























  <FormField label="Reservation" labelFor="reservation">
      <Field name="reservation" id="reservation" component={SelectField} options={[]} itemRef={'reservations'}></Field>
  </FormField>



























  <FormField label="Servicerequest" labelFor="service_request">
      <Field name="service_request" id="service_request" component={SelectField} options={[]} itemRef={'service_requests'}></Field>
  </FormField>



























  <FormField label="Invoice" labelFor="invoice">
      <Field name="invoice" id="invoice" component={SelectField} options={[]} itemRef={'invoices'}></Field>
  </FormField>











    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </FormField>









































  <FormField label='Isprivate' labelFor='is_private'>
      <Field
          name='is_private'
          id='is_private'
          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('/documents/documents-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default DocumentsNew
