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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    build_job: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    artifact_type: 'apk',
    
    
    
    
    
    
    
    file_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    file_blob: [],
    
    
    
    
    
    
    download_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    checksum_sha256: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    generated_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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























  <FormField label="ArtifactType" labelFor="artifact_type">
      <Field name="artifact_type" id="artifact_type" component="select">
      
        <option value="apk">apk</option>
      
        <option value="aab">aab</option>
      
        <option value="zip">zip</option>
      
        <option value="log">log</option>
      
        <option value="report">report</option>
      
        <option value="preview_url">preview_url</option>
      
      </Field>
  </FormField>













  <FormField
      label="FileName"
  >
      <Field
          name="file_name"
          placeholder="FileName"
      />
  </FormField>


















































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




  <FormField
      label="DownloadURL"
  >
      <Field
          name="download_url"
          placeholder="DownloadURL"
      />
  </FormField>



























  <FormField
      label="ChecksumSHA256"
  >
      <Field
          name="checksum_sha256"
          placeholder="ChecksumSHA256"
      />
  </FormField>





































  <FormField
      label="GeneratedAt"
  >
      <Field
          type="datetime-local"
          name="generated_at"
          placeholder="GeneratedAt"
      />
  </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('/build_artifacts/build_artifacts-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Build_artifactsNew
