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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    source_type: 'siem',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'active',
    
    
    
    
    
    
    
    connector_type: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    endpoint_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    auth_method: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    poll_interval_seconds: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    last_ingested_at: '',
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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









  <FormField
      label="DataSourceName"
  >
      <Field
          name="name"
          placeholder="DataSourceName"
      />
  </FormField>









































  <FormField label="SourceType" labelFor="source_type">
      <Field name="source_type" id="source_type" component="select">
      
        <option value="siem">siem</option>
      
        <option value="edr">edr</option>
      
        <option value="ids_ips">ids_ips</option>
      
        <option value="firewall">firewall</option>
      
        <option value="proxy">proxy</option>
      
        <option value="dns">dns</option>
      
        <option value="cloud_logs">cloud_logs</option>
      
        <option value="kubernetes_audit">kubernetes_audit</option>
      
        <option value="endpoint">endpoint</option>
      
        <option value="threat_feed">threat_feed</option>
      
        <option value="dark_web">dark_web</option>
      
        <option value="vulnerability_scanner">vulnerability_scanner</option>
      
        <option value="email_gateway">email_gateway</option>
      
        <option value="web_gateway">web_gateway</option>
      
        <option value="custom_api">custom_api</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="active">active</option>
      
        <option value="paused">paused</option>
      
        <option value="error">error</option>
      
        <option value="onboarding">onboarding</option>
      
      </Field>
  </FormField>













  <FormField
      label="ConnectorType"
  >
      <Field
          name="connector_type"
          placeholder="ConnectorType"
      />
  </FormField>



























  <FormField
      label="EndpointURL"
  >
      <Field
          name="endpoint_url"
          placeholder="EndpointURL"
      />
  </FormField>



























  <FormField
      label="AuthMethod"
  >
      <Field
          name="auth_method"
          placeholder="AuthMethod"
      />
  </FormField>

































    <FormField
        label="PollIntervalSeconds"
    >
        <Field
            type="number"
            name="poll_interval_seconds"
            placeholder="PollIntervalSeconds"
        />
    </FormField>































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



















    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </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('/data_sources/data_sources-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Data_sourcesNew
