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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    app_category: 'productivity',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    runtime: 'wasmedge',
    
    
    
    
    
    
    
    version: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    wasm_artifact_uri: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reliability_score: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    vetting_status: 'pending',
    
    
    
    
    
    
    
    
    
    
    
    
    submitted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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





























    <FormField label="Description" hasTextareaHeight>
        <Field name="description" as="textarea" placeholder="Description" />
    </FormField>







































  <FormField label="AppCategory" labelFor="app_category">
      <Field name="app_category" id="app_category" component="select">
      
        <option value="productivity">productivity</option>
      
        <option value="education">education</option>
      
        <option value="moderation">moderation</option>
      
        <option value="fun">fun</option>
      
        <option value="analytics">analytics</option>
      
        <option value="devtools">devtools</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



























  <FormField label="Runtime" labelFor="runtime">
      <Field name="runtime" id="runtime" component="select">
      
        <option value="wasmedge">wasmedge</option>
      
        <option value="wasmtime">wasmtime</option>
      
      </Field>
  </FormField>













  <FormField
      label="Version"
  >
      <Field
          name="version"
          placeholder="Version"
      />
  </FormField>



























  <FormField
      label="WASMArtifactURI"
  >
      <Field
          name="wasm_artifact_uri"
          placeholder="WASMArtifactURI"
      />
  </FormField>

































    <FormField
        label="ReliabilityScore"
    >
        <Field
            type="number"
            name="reliability_score"
            placeholder="ReliabilityScore"
        />
    </FormField>



































  <FormField label="VettingStatus" labelFor="vetting_status">
      <Field name="vetting_status" id="vetting_status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="approved">approved</option>
      
        <option value="rejected">rejected</option>
      
        <option value="disabled_auto">disabled_auto</option>
      
        <option value="disabled_admin">disabled_admin</option>
      
      </Field>
  </FormField>























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

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

export default Marketplace_appsNew
