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

const initialValues = {
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    difficulty: 'beginner',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    topic: 'basics',
    
    
    
    
    
    
    
    
    summary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    content: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    estimated_minutes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    published: false,
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/learning_modules/learning_modules-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="Difficulty" labelFor="difficulty">
      <Field name="difficulty" id="difficulty" component="select">
      
        <option value="beginner">beginner</option>
      
        <option value="intermediate">intermediate</option>
      
        <option value="advanced">advanced</option>
      
      </Field>
  </FormField>



























  <FormField label="Topic" labelFor="topic">
      <Field name="topic" id="topic" component="select">
      
        <option value="basics">basics</option>
      
        <option value="risk_management">risk_management</option>
      
        <option value="technical_analysis">technical_analysis</option>
      
        <option value="fundamentals">fundamentals</option>
      
        <option value="options_awareness">options_awareness</option>
      
        <option value="macro">macro</option>
      
        <option value="portfolio_building">portfolio_building</option>
      
      </Field>
  </FormField>















    <FormField label="Summary" hasTextareaHeight>
        <Field name="summary" as="textarea" placeholder="Summary" />
    </FormField>





























      <FormField label='Content' hasTextareaHeight>
          <Field
              name='content'
              id='content'
              component={RichTextField}
          ></Field>
      </FormField>





























    <FormField
        label="EstimatedMinutes"
    >
        <Field
            type="number"
            name="estimated_minutes"
            placeholder="EstimatedMinutes"
        />
    </FormField>





































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

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

export default Learning_modulesNew
