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

const initialValues = {
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    category: 'nutrition_science',
    
    
    
    
    
    
    
    tags_csv: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reading_time_minutes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    difficulty_level: 'beginner',
    
    
    
    
    
    
    
    
    
    
    
    
    published_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    updated_at_custom: '',
    
    
    
    
    
    
    
    
    
    
    
    
    content: '',
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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









































  <FormField label="Category" labelFor="category">
      <Field name="category" id="category" component="select">
      
        <option value="nutrition_science">nutrition_science</option>
      
        <option value="fitness_exercise_science">fitness_exercise_science</option>
      
        <option value="mental_health">mental_health</option>
      
        <option value="sleep_science">sleep_science</option>
      
        <option value="hormones">hormones</option>
      
        <option value="longevity_anti_ageing">longevity_anti_ageing</option>
      
        <option value="specific_conditions">specific_conditions</option>
      
        <option value="medications">medications</option>
      
        <option value="lab_results_explained">lab_results_explained</option>
      
        <option value="supplements">supplements</option>
      
      </Field>
  </FormField>













  <FormField
      label="Tags"
  >
      <Field
          name="tags_csv"
          placeholder="Tags"
      />
  </FormField>

































    <FormField
        label="ReadingTime(minutes)"
    >
        <Field
            type="number"
            name="reading_time_minutes"
            placeholder="ReadingTime(minutes)"
        />
    </FormField>



































  <FormField label="DifficultyLevel" labelFor="difficulty_level">
      <Field name="difficulty_level" id="difficulty_level" component="select">
      
        <option value="beginner">beginner</option>
      
        <option value="intermediate">intermediate</option>
      
        <option value="advanced">advanced</option>
      
      </Field>
  </FormField>























  <FormField
      label="PublishedAt"
  >
      <Field
          type="datetime-local"
          name="published_at"
          placeholder="PublishedAt"
      />
  </FormField>



























  <FormField
      label="UpdatedAt"
  >
      <Field
          type="datetime-local"
          name="updated_at_custom"
          placeholder="UpdatedAt"
      />
  </FormField>





















      <FormField label='Content' hasTextareaHeight>
          <Field
              name='content'
              id='content'
              component={RichTextField}
          ></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('/library_articles/library_articles-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Library_articlesNew
