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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    system_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    system_type: 'entra_id',
    
    
    
    
    
    
    
    vendor: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    environment: 'production',
    
    
    
    
    
    
    
    owner: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    connection_status: 'connected',
    
    
    
    
    
    
    
    
    
    
    
    
    last_successful_sync_at: '',
    
    
    
    
    
    
    
    
    
    
    
    connection_health_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    source_of_truth_flag: false,
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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









































  <FormField label="SystemType" labelFor="system_type">
      <Field name="system_type" id="system_type" component="select">
      
        <option value="entra_id">entra_id</option>
      
        <option value="microsoft_365_audit">microsoft_365_audit</option>
      
        <option value="okta">okta</option>
      
        <option value="google_workspace">google_workspace</option>
      
        <option value="hris">hris</option>
      
        <option value="ticketing_psa">ticketing_psa</option>
      
        <option value="pam">pam</option>
      
        <option value="endpoint_mdm">endpoint_mdm</option>
      
        <option value="siem">siem</option>
      
        <option value="backup_recovery">backup_recovery</option>
      
        <option value="custom_source">custom_source</option>
      
      </Field>
  </FormField>













  <FormField
      label="Vendor"
  >
      <Field
          name="vendor"
          placeholder="Vendor"
      />
  </FormField>









































  <FormField label="Environment" labelFor="environment">
      <Field name="environment" id="environment" component="select">
      
        <option value="production">production</option>
      
        <option value="staging">staging</option>
      
        <option value="sandbox">sandbox</option>
      
        <option value="unknown">unknown</option>
      
      </Field>
  </FormField>













  <FormField
      label="Owner"
  >
      <Field
          name="owner"
          placeholder="Owner"
      />
  </FormField>









































  <FormField label="ConnectionStatus" labelFor="connection_status">
      <Field name="connection_status" id="connection_status" component="select">
      
        <option value="connected">connected</option>
      
        <option value="degraded">degraded</option>
      
        <option value="disconnected">disconnected</option>
      
        <option value="not_configured">not_configured</option>
      
      </Field>
  </FormField>























  <FormField
      label="LastSuccessfulSyncAt"
  >
      <Field
          type="datetime-local"
          name="last_successful_sync_at"
          placeholder="LastSuccessfulSyncAt"
      />
  </FormField>



















    <FormField label="ConnectionHealthNotes" hasTextareaHeight>
        <Field name="connection_health_notes" as="textarea" placeholder="ConnectionHealthNotes" />
    </FormField>









































  <FormField label='SourceofTruthFlag' labelFor='source_of_truth_flag'>
      <Field
          name='source_of_truth_flag'
          id='source_of_truth_flag'
          component={SwitchField}
      ></Field>
  </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('/connected_systems/connected_systems-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Connected_systemsNew
