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

const initialValues = {
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    pipeline_type: 'log_collector',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'healthy',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    data_sources: [],
    
    
    
    kafka_topic: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    data_lake_path: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    throughput_eps: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    error_rate_percent: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    last_health_check_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









































  <FormField label="PipelineType" labelFor="pipeline_type">
      <Field name="pipeline_type" id="pipeline_type" component="select">
      
        <option value="log_collector">log_collector</option>
      
        <option value="kafka_stream">kafka_stream</option>
      
        <option value="batch_etl">batch_etl</option>
      
        <option value="webhook">webhook</option>
      
        <option value="file_drop">file_drop</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="healthy">healthy</option>
      
        <option value="degraded">degraded</option>
      
        <option value="down">down</option>
      
        <option value="maintenance">maintenance</option>
      
      </Field>
  </FormField>

































    <FormField label='DataSources' labelFor='data_sources'>
        <Field
            name='data_sources'
            id='data_sources'
            itemRef={'data_sources'}
            options={[]}
            component={SelectFieldMany}>
        </Field>
    </FormField>







  <FormField
      label="KafkaTopic"
  >
      <Field
          name="kafka_topic"
          placeholder="KafkaTopic"
      />
  </FormField>



























  <FormField
      label="DataLakePath"
  >
      <Field
          name="data_lake_path"
          placeholder="DataLakePath"
      />
  </FormField>

































    <FormField
        label="ThroughputEPS"
    >
        <Field
            type="number"
            name="throughput_eps"
            placeholder="ThroughputEPS"
        />
    </FormField>



























    <FormField
        label="ErrorRatePercent"
    >
        <Field
            type="number"
            name="error_rate_percent"
            placeholder="ErrorRatePercent"
        />
    </FormField>































  <FormField
      label="LastHealthCheckAt"
  >
      <Field
          type="datetime-local"
          name="last_health_check_at"
          placeholder="LastHealthCheckAt"
      />
  </FormField>



































  <FormField label="organizations" labelFor="organizations">
      <Field name="organizations" id="organizations" component={SelectField} options={[]} itemRef={'organizations'}></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('/ingestion_pipelines/ingestion_pipelines-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Ingestion_pipelinesNew
