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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    campus: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    capacity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    room_type: 'classroom',
    
    
    
    
    
    
    
    
    
    
    
    
    
    active: false,
    
    
    
    
    
    
    
    
}


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

    
    

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









  <FormField
      label="RoomName"
  >
      <Field
          name="name"
          placeholder="RoomName"
      />
  </FormField>



























  <FormField
      label="RoomCode"
  >
      <Field
          name="code"
          placeholder="RoomCode"
      />
  </FormField>

































    <FormField
        label="Capacity"
    >
        <Field
            type="number"
            name="capacity"
            placeholder="Capacity"
        />
    </FormField>



































  <FormField label="RoomType" labelFor="room_type">
      <Field name="room_type" id="room_type" component="select">
      
        <option value="classroom">classroom</option>
      
        <option value="lab">lab</option>
      
        <option value="gym">gym</option>
      
        <option value="auditorium">auditorium</option>
      
        <option value="library">library</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>





























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

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

export default RoomsNew
