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

const initialValues = {
    
    
    
    
    
    
    
    day_start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    day_end_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    season: 'summer',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    weather_state: '',
    
    
    
    
    tourism_index: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    inflation_index: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    
    // get from url params
    const { dateRangeStart, dateRangeEnd } = router.query
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/world_calendar_days/world_calendar_days-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                
                
                dateRangeStart && dateRangeEnd ?
                {
                    ...initialValues,
                    day_start_at: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    day_end_at: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
                } : initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>













  <FormField
      label="DayStartAt"
  >
      <Field
          type="datetime-local"
          name="day_start_at"
          placeholder="DayStartAt"
      />
  </FormField>



























  <FormField
      label="DayEndAt"
  >
      <Field
          type="datetime-local"
          name="day_end_at"
          placeholder="DayEndAt"
      />
  </FormField>































  <FormField label="Season" labelFor="season">
      <Field name="season" id="season" component="select">
      
        <option value="summer">summer</option>
      
        <option value="autumn">autumn</option>
      
        <option value="winter">winter</option>
      
        <option value="spring">spring</option>
      
        <option value="wet">wet</option>
      
        <option value="dry">dry</option>
      
      </Field>
  </FormField>































  <FormField label="WeatherState" labelFor="weather_state">
      <Field name="weather_state" id="weather_state" component={SelectField} options={[]} itemRef={'weather_states'}></Field>
  </FormField>















    <FormField
        label="TourismIndex"
    >
        <Field
            type="number"
            name="tourism_index"
            placeholder="TourismIndex"
        />
    </FormField>



























    <FormField
        label="InflationIndex"
    >
        <Field
            type="number"
            name="inflation_index"
            placeholder="InflationIndex"
        />
    </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('/world_calendar_days/world_calendar_days-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default World_calendar_daysNew
