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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    asset_type: 'host',
    
    
    
    
    
    
    
    environment: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ip_address: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    hostname: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    os: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    cloud_provider: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    criticality: 'low',
    
    
    
    
    
    
    
    
    
    
    
    
    
    internet_exposed: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sensor: '',
    
    
    
}


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

    
    

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









































  <FormField label="AssetType" labelFor="asset_type">
      <Field name="asset_type" id="asset_type" component="select">
      
        <option value="host">host</option>
      
        <option value="server">server</option>
      
        <option value="workstation">workstation</option>
      
        <option value="container">container</option>
      
        <option value="kubernetes_cluster">kubernetes_cluster</option>
      
        <option value="database">database</option>
      
        <option value="application">application</option>
      
        <option value="api">api</option>
      
        <option value="network_device">network_device</option>
      
        <option value="iot">iot</option>
      
        <option value="edge_sensor">edge_sensor</option>
      
      </Field>
  </FormField>













  <FormField
      label="Environment"
  >
      <Field
          name="environment"
          placeholder="Environment"
      />
  </FormField>



























  <FormField
      label="IPAddress"
  >
      <Field
          name="ip_address"
          placeholder="IPAddress"
      />
  </FormField>



























  <FormField
      label="Hostname"
  >
      <Field
          name="hostname"
          placeholder="Hostname"
      />
  </FormField>



























  <FormField
      label="OperatingSystem"
  >
      <Field
          name="os"
          placeholder="OperatingSystem"
      />
  </FormField>



























  <FormField
      label="CloudProvider"
  >
      <Field
          name="cloud_provider"
          placeholder="CloudProvider"
      />
  </FormField>









































  <FormField label="Criticality" labelFor="criticality">
      <Field name="criticality" id="criticality" component="select">
      
        <option value="low">low</option>
      
        <option value="medium">medium</option>
      
        <option value="high">high</option>
      
        <option value="critical">critical</option>
      
      </Field>
  </FormField>





























  <FormField label='InternetExposed' labelFor='internet_exposed'>
      <Field
          name='internet_exposed'
          id='internet_exposed'
          component={SwitchField}
      ></Field>
  </FormField>





























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

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

export default AssetsNew
