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

const initialValues = {
    
    
    node_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    node_type: 'topic',
    
    
    
    
    
    
    
    
    
    node_description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    importance_score: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    supporting_chunks: [],
    
    
}


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

    
    

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









































  <FormField label="NodeType" labelFor="node_type">
      <Field name="node_type" id="node_type" component="select">
      
        <option value="topic">topic</option>
      
        <option value="framework">framework</option>
      
        <option value="offer">offer</option>
      
        <option value="hook">hook</option>
      
        <option value="audience_segment">audience_segment</option>
      
        <option value="policy">policy</option>
      
        <option value="constraint">constraint</option>
      
        <option value="metric">metric</option>
      
        <option value="competitor">competitor</option>
      
        <option value="custom">custom</option>
      
      </Field>
  </FormField>

















      <FormField label='NodeDescription' hasTextareaHeight>
          <Field
              name='node_description'
              id='node_description'
              component={RichTextField}
          ></Field>
      </FormField>





























    <FormField
        label="ImportanceScore"
    >
        <Field
            type="number"
            name="importance_score"
            placeholder="ImportanceScore"
        />
    </FormField>









































    <FormField label='SupportingChunks' labelFor='supporting_chunks'>
        <Field
            name='supporting_chunks'
            id='supporting_chunks'
            itemRef={'knowledge_chunks'}
            options={[]}
            component={SelectFieldMany}>
        </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('/knowledge_nodes/knowledge_nodes-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Knowledge_nodesNew
