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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    environment: 'sandbox',
    
    
    
    
    
    
    
    device_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    branch_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    business_name_on_efris: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tin_on_efris: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    client_id: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    client_secret: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    api_base_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    last_connected_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'active',
    
    
    
    
    
    
    
    
    last_error_message: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/efris_connections/efris_connections-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="Environment" labelFor="environment">
      <Field name="environment" id="environment" component="select">
      
        <option value="sandbox">sandbox</option>
      
        <option value="production">production</option>
      
      </Field>
  </FormField>













  <FormField
      label="DeviceNumber"
  >
      <Field
          name="device_number"
          placeholder="DeviceNumber"
      />
  </FormField>



























  <FormField
      label="BranchCode"
  >
      <Field
          name="branch_code"
          placeholder="BranchCode"
      />
  </FormField>



























  <FormField
      label="BusinessNameonEFRIS"
  >
      <Field
          name="business_name_on_efris"
          placeholder="BusinessNameonEFRIS"
      />
  </FormField>



























  <FormField
      label="TINonEFRIS"
  >
      <Field
          name="tin_on_efris"
          placeholder="TINonEFRIS"
      />
  </FormField>



























  <FormField
      label="ClientID"
  >
      <Field
          name="client_id"
          placeholder="ClientID"
      />
  </FormField>



























  <FormField
      label="ClientSecret"
  >
      <Field
          name="client_secret"
          placeholder="ClientSecret"
      />
  </FormField>



























  <FormField
      label="APIBaseURL"
  >
      <Field
          name="api_base_url"
          placeholder="APIBaseURL"
      />
  </FormField>





































  <FormField
      label="LastConnectedAt"
  >
      <Field
          type="datetime-local"
          name="last_connected_at"
          placeholder="LastConnectedAt"
      />
  </FormField>































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















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

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

export default Efris_connectionsNew
