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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    workflow: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    evidence_model: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    source_system: '',
    
    
    
    
    artifact_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    artifact_type: 'screenshot',
    
    
    
    
    
    
    
    
    artifact_reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    collected_by_user: '',
    
    
    
    
    
    
    
    
    
    collected_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    event_timestamp: '',
    
    
    
    
    
    
    
    
    
    
    subject_user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approver_user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'pending',
    
    
    
    
    
    
    
    
    validation_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    evidence_strength_score: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    chain_integrity_score: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    retention_expiry: '',
    
    
    
    
    
    
    
    
    
    
    tags: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    uploaded_files: [],
    
    
    
    
    
}


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

    
    

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



























  <FormField label="EvidenceModel" labelFor="evidence_model">
      <Field name="evidence_model" id="evidence_model" component={SelectField} options={[]} itemRef={'evidence_models'}></Field>
  </FormField>



























  <FormField label="SourceSystem" labelFor="source_system">
      <Field name="source_system" id="source_system" component={SelectField} options={[]} itemRef={'connected_systems'}></Field>
  </FormField>









  <FormField
      label="ArtifactName"
  >
      <Field
          name="artifact_name"
          placeholder="ArtifactName"
      />
  </FormField>









































  <FormField label="ArtifactType" labelFor="artifact_type">
      <Field name="artifact_type" id="artifact_type" component="select">
      
        <option value="screenshot">screenshot</option>
      
        <option value="export_csv">export_csv</option>
      
        <option value="export_json">export_json</option>
      
        <option value="audit_log">audit_log</option>
      
        <option value="ticket">ticket</option>
      
        <option value="attestation">attestation</option>
      
        <option value="configuration">configuration</option>
      
        <option value="policy_document">policy_document</option>
      
        <option value="api_snapshot">api_snapshot</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>















    <FormField label="ArtifactReference" hasTextareaHeight>
        <Field name="artifact_reference" as="textarea" placeholder="ArtifactReference" />
    </FormField>











































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



















  <FormField
      label="CollectedAt"
  >
      <Field
          type="datetime-local"
          name="collected_at"
          placeholder="CollectedAt"
      />
  </FormField>



























  <FormField
      label="EventTimestamp"
  >
      <Field
          type="datetime-local"
          name="event_timestamp"
          placeholder="EventTimestamp"
      />
  </FormField>

















  <FormField
      label="SubjectUser"
  >
      <Field
          name="subject_user"
          placeholder="SubjectUser"
      />
  </FormField>













































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























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="collected">collected</option>
      
        <option value="validated">validated</option>
      
        <option value="rejected">rejected</option>
      
        <option value="expired">expired</option>
      
      </Field>
  </FormField>















    <FormField label="ValidationNotes" hasTextareaHeight>
        <Field name="validation_notes" as="textarea" placeholder="ValidationNotes" />
    </FormField>































    <FormField
        label="EvidenceStrengthScore"
    >
        <Field
            type="number"
            name="evidence_strength_score"
            placeholder="EvidenceStrengthScore"
        />
    </FormField>



























    <FormField
        label="ChainIntegrityScore"
    >
        <Field
            type="number"
            name="chain_integrity_score"
            placeholder="ChainIntegrityScore"
        />
    </FormField>































  <FormField
      label="RetentionExpiry"
  >
      <Field
          type="datetime-local"
          name="retention_expiry"
          placeholder="RetentionExpiry"
      />
  </FormField>

















  <FormField
      label="Tags"
  >
      <Field
          name="tags"
          placeholder="Tags"
      />
  </FormField>


















































  <FormField>
      <Field
          label='UploadedFiles'
          color='info'
          icon={mdiUpload}
          path={'artifacts/uploaded_files'}
          name='uploaded_files'
          id='uploaded_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('/artifacts/artifacts-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default ArtifactsNew
