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

const initialValues = {
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    weather_type: 'sunny',
    
    
    
    
    
    
    
    temperature_c: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    wind_speed: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    rain_intensity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    has_thunder: false,
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/weather_states/weather_states-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="Name"
  >
      <Field
          name="name"
          placeholder="Name"
      />
  </FormField>









































  <FormField label="WeatherType" labelFor="weather_type">
      <Field name="weather_type" id="weather_type" component="select">
      
        <option value="sunny">sunny</option>
      
        <option value="rain">rain</option>
      
        <option value="storm">storm</option>
      
        <option value="cloudy">cloudy</option>
      
        <option value="fog">fog</option>
      
        <option value="heat_wave">heat_wave</option>
      
        <option value="wind">wind</option>
      
      </Field>
  </FormField>



















    <FormField
        label="TemperatureC"
    >
        <Field
            type="number"
            name="temperature_c"
            placeholder="TemperatureC"
        />
    </FormField>



























    <FormField
        label="WindSpeed"
    >
        <Field
            type="number"
            name="wind_speed"
            placeholder="WindSpeed"
        />
    </FormField>



























    <FormField
        label="RainIntensity"
    >
        <Field
            type="number"
            name="rain_intensity"
            placeholder="RainIntensity"
        />
    </FormField>





































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

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

export default Weather_statesNew
