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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requested_by: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    data_entity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    file_upload: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    started_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    finished_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    total_rows: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    valid_rows: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    invalid_rows: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    warning_rows: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    error_report_file: [],
    
    
    
    
    
    
    job_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField label="DataEntity" labelFor="data_entity">
      <Field name="data_entity" id="data_entity" component={SelectField} options={[]} itemRef={'data_entities'}></Field>
  </FormField>



























  <FormField label="FileUpload" labelFor="file_upload">
      <Field name="file_upload" id="file_upload" component={SelectField} options={[]} itemRef={'file_uploads'}></Field>
  </FormField>























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="mapping">mapping</option>
      
        <option value="validating">validating</option>
      
        <option value="validation_failed">validation_failed</option>
      
        <option value="ready_to_import">ready_to_import</option>
      
        <option value="importing">importing</option>
      
        <option value="import_failed">import_failed</option>
      
        <option value="completed">completed</option>
      
        <option value="cancelled">cancelled</option>
      
      </Field>
  </FormField>























  <FormField
      label="StartedAt"
  >
      <Field
          type="datetime-local"
          name="started_at"
          placeholder="StartedAt"
      />
  </FormField>



























  <FormField
      label="FinishedAt"
  >
      <Field
          type="datetime-local"
          name="finished_at"
          placeholder="FinishedAt"
      />
  </FormField>























    <FormField
        label="TotalRows"
    >
        <Field
            type="number"
            name="total_rows"
            placeholder="TotalRows"
        />
    </FormField>



























    <FormField
        label="ValidRows"
    >
        <Field
            type="number"
            name="valid_rows"
            placeholder="ValidRows"
        />
    </FormField>



























    <FormField
        label="InvalidRows"
    >
        <Field
            type="number"
            name="invalid_rows"
            placeholder="InvalidRows"
        />
    </FormField>



























    <FormField
        label="WarningRows"
    >
        <Field
            type="number"
            name="warning_rows"
            placeholder="WarningRows"
        />
    </FormField>












































  <FormField>
      <Field
          label='ErrorReportFile'
          color='info'
          icon={mdiUpload}
          path={'import_jobs/error_report_file'}
          name='error_report_file'
          id='error_report_file'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>




  <FormField
      label="JobName"
  >
      <Field
          name="job_name"
          placeholder="JobName"
      />
  </FormField>





























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

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

export default Import_jobsNew
