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

const initialValues = {
    
    
    submission_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    jurisdiction: 'eu_mdr',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    submission_type: 'technical_documentation',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    product: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    owner: '',
    
    
    
    
    
    
    
    
    
    planned_submission_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    submitted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    decision_at: '',
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    submission_files: [],
    
    
    
    
    
}


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

    
    

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









































  <FormField label="Jurisdiction" labelFor="jurisdiction">
      <Field name="jurisdiction" id="jurisdiction" component="select">
      
        <option value="eu_mdr">eu_mdr</option>
      
        <option value="us_fda">us_fda</option>
      
        <option value="uk_mhra">uk_mhra</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



























  <FormField label="SubmissionType" labelFor="submission_type">
      <Field name="submission_type" id="submission_type" component="select">
      
        <option value="technical_documentation">technical_documentation</option>
      
        <option value="cer">cer</option>
      
        <option value="pms_report">pms_report</option>
      
        <option value="psur">psur</option>
      
        <option value="vigilance">vigilance</option>
      
        <option value="510k">510k</option>
      
        <option value="pma">pma</option>
      
        <option value="de_novo">de_novo</option>
      
        <option value="registration_listing">registration_listing</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="in_review">in_review</option>
      
        <option value="submitted">submitted</option>
      
        <option value="questions_received">questions_received</option>
      
        <option value="accepted">accepted</option>
      
        <option value="rejected">rejected</option>
      
        <option value="closed">closed</option>
      
      </Field>
  </FormField>































  <FormField label="Product" labelFor="product">
      <Field name="product" id="product" component={SelectField} options={[]} itemRef={'products'}></Field>
  </FormField>



























  <FormField label="Owner" labelFor="owner">
      <Field name="owner" id="owner" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>



















  <FormField
      label="PlannedSubmissionAt"
  >
      <Field
          type="datetime-local"
          name="planned_submission_at"
          placeholder="PlannedSubmissionAt"
      />
  </FormField>



























  <FormField
      label="SubmittedAt"
  >
      <Field
          type="datetime-local"
          name="submitted_at"
          placeholder="SubmittedAt"
      />
  </FormField>



























  <FormField
      label="DecisionAt"
  >
      <Field
          type="datetime-local"
          name="decision_at"
          placeholder="DecisionAt"
      />
  </FormField>



















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
















































  <FormField>
      <Field
          label='SubmissionFiles'
          color='info'
          icon={mdiUpload}
          path={'regulatory_submissions/submission_files'}
          name='submission_files'
          id='submission_files'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></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('/regulatory_submissions/regulatory_submissions-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Regulatory_submissionsNew
