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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    meal: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    food: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    recipe: '',
    
    
    
    
    quantity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    quantity_unit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    calories: '',
    
    
    
    
    
    
    
    
    
    
    
    
    protein_g: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    carbs_g: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    fat_g: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="Food" labelFor="food">
      <Field name="food" id="food" component={SelectField} options={[]} itemRef={'foods'}></Field>
  </FormField>



























  <FormField label="Recipe" labelFor="recipe">
      <Field name="recipe" id="recipe" component={SelectField} options={[]} itemRef={'recipes'}></Field>
  </FormField>















    <FormField
        label="Quantity"
    >
        <Field
            type="number"
            name="quantity"
            placeholder="Quantity"
        />
    </FormField>





















  <FormField
      label="QuantityUnit"
  >
      <Field
          name="quantity_unit"
          placeholder="QuantityUnit"
      />
  </FormField>

































    <FormField
        label="Calories"
    >
        <Field
            type="number"
            name="calories"
            placeholder="Calories"
        />
    </FormField>



























    <FormField
        label="Protein(g)"
    >
        <Field
            type="number"
            name="protein_g"
            placeholder="Protein(g)"
        />
    </FormField>



























    <FormField
        label="Carbohydrates(g)"
    >
        <Field
            type="number"
            name="carbs_g"
            placeholder="Carbohydrates(g)"
        />
    </FormField>



























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

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

export default Meal_itemsNew
