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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    pond: '',
    
    
    
    
    
    
    
    
    
    sampled_at: '',
    
    
    
    
    
    
    
    
    
    
    temperature_c: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ph: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    dissolved_oxygen_mg_l: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    salinity_ppt: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ammonia_mg_l: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    nitrite_mg_l: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    nitrate_mg_l: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    turbidity_ntu: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    recorded_by: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField label="Pond" labelFor="pond">
      <Field name="pond" id="pond" component={SelectField} options={[]} itemRef={'ponds'}></Field>
  </FormField>



















  <FormField
      label="SampledAt"
  >
      <Field
          type="datetime-local"
          name="sampled_at"
          placeholder="SampledAt"
      />
  </FormField>























    <FormField
        label="TemperatureC"
    >
        <Field
            type="number"
            name="temperature_c"
            placeholder="TemperatureC"
        />
    </FormField>



























    <FormField
        label="pH"
    >
        <Field
            type="number"
            name="ph"
            placeholder="pH"
        />
    </FormField>



























    <FormField
        label="DissolvedOxygenMgL"
    >
        <Field
            type="number"
            name="dissolved_oxygen_mg_l"
            placeholder="DissolvedOxygenMgL"
        />
    </FormField>



























    <FormField
        label="SalinityPpt"
    >
        <Field
            type="number"
            name="salinity_ppt"
            placeholder="SalinityPpt"
        />
    </FormField>



























    <FormField
        label="AmmoniaMgL"
    >
        <Field
            type="number"
            name="ammonia_mg_l"
            placeholder="AmmoniaMgL"
        />
    </FormField>



























    <FormField
        label="NitriteMgL"
    >
        <Field
            type="number"
            name="nitrite_mg_l"
            placeholder="NitriteMgL"
        />
    </FormField>



























    <FormField
        label="NitrateMgL"
    >
        <Field
            type="number"
            name="nitrate_mg_l"
            placeholder="NitrateMgL"
        />
    </FormField>



























    <FormField
        label="TurbidityNTU"
    >
        <Field
            type="number"
            name="turbidity_ntu"
            placeholder="TurbidityNTU"
        />
    </FormField>























    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </FormField>











































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

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

export default Water_quality_logsNew
