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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    source_type: 'website',
    
    
    
    
    
    
    
    source_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    source_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    uploaded_files: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    trust_tier: 'gold',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    content_domain: 'ndis',
    
    
    
    
    
    
    
    
    
    
    
    
    last_ingested_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    next_refresh_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    auto_refresh_enabled: false,
    
    
    
    
    
    
    
    
    
    
    refresh_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/knowledge_sources/knowledge_sources-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="SourceType" labelFor="source_type">
      <Field name="source_type" id="source_type" component="select">
      
        <option value="website">website</option>
      
        <option value="document">document</option>
      
        <option value="video">video</option>
      
        <option value="audio">audio</option>
      
        <option value="note">note</option>
      
        <option value="dataset">dataset</option>
      
      </Field>
  </FormField>













  <FormField
      label="SourceName"
  >
      <Field
          name="source_name"
          placeholder="SourceName"
      />
  </FormField>



























  <FormField
      label="SourceURL"
  >
      <Field
          name="source_url"
          placeholder="SourceURL"
      />
  </FormField>


















































  <FormField>
      <Field
          label='UploadedFiles'
          color='info'
          icon={mdiUpload}
          path={'knowledge_sources/uploaded_files'}
          name='uploaded_files'
          id='uploaded_files'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>


















  <FormField label="TrustTier" labelFor="trust_tier">
      <Field name="trust_tier" id="trust_tier" component="select">
      
        <option value="gold">gold</option>
      
        <option value="silver">silver</option>
      
        <option value="bronze">bronze</option>
      
        <option value="blocked">blocked</option>
      
      </Field>
  </FormField>



























  <FormField label="ContentDomain" labelFor="content_domain">
      <Field name="content_domain" id="content_domain" component="select">
      
        <option value="ndis">ndis</option>
      
        <option value="compliance">compliance</option>
      
        <option value="behavioral_science">behavioral_science</option>
      
        <option value="platform_policy">platform_policy</option>
      
        <option value="competitor_research">competitor_research</option>
      
        <option value="brand_assets">brand_assets</option>
      
        <option value="campaign_reports">campaign_reports</option>
      
        <option value="general_marketing">general_marketing</option>
      
      </Field>
  </FormField>























  <FormField
      label="LastIngestedAt"
  >
      <Field
          type="datetime-local"
          name="last_ingested_at"
          placeholder="LastIngestedAt"
      />
  </FormField>



























  <FormField
      label="NextRefreshAt"
  >
      <Field
          type="datetime-local"
          name="next_refresh_at"
          placeholder="NextRefreshAt"
      />
  </FormField>

































  <FormField label='AutoRefreshEnabled' labelFor='auto_refresh_enabled'>
      <Field
          name='auto_refresh_enabled'
          id='auto_refresh_enabled'
          component={SwitchField}
      ></Field>
  </FormField>













    <FormField label="RefreshNotes" hasTextareaHeight>
        <Field name="refresh_notes" as="textarea" placeholder="RefreshNotes" />
    </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_sources/knowledge_sources-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Knowledge_sourcesNew
