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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    marketplace_app: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    team: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    installation_status: 'installed',
    
    
    
    
    
    
    
    
    
    
    
    
    installed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    disabled_at: '',
    
    
    
    
    
    
    
    
    
    
    
    disable_reason: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    auto_suggest_enabled: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField label="Team" labelFor="team">
      <Field name="team" id="team" component={SelectField} options={[]} itemRef={'teams'}></Field>
  </FormField>























  <FormField label="InstallationStatus" labelFor="installation_status">
      <Field name="installation_status" id="installation_status" component="select">
      
        <option value="installed">installed</option>
      
        <option value="paused">paused</option>
      
        <option value="disabled">disabled</option>
      
        <option value="uninstalled">uninstalled</option>
      
      </Field>
  </FormField>























  <FormField
      label="InstalledAt"
  >
      <Field
          type="datetime-local"
          name="installed_at"
          placeholder="InstalledAt"
      />
  </FormField>



























  <FormField
      label="DisabledAt"
  >
      <Field
          type="datetime-local"
          name="disabled_at"
          placeholder="DisabledAt"
      />
  </FormField>



















    <FormField label="DisableReason" hasTextareaHeight>
        <Field name="disable_reason" as="textarea" placeholder="DisableReason" />
    </FormField>









































  <FormField label='AutoSuggestEnabled' labelFor='auto_suggest_enabled'>
      <Field
          name='auto_suggest_enabled'
          id='auto_suggest_enabled'
          component={SwitchField}
      ></Field>
  </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('/app_installations/app_installations-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default App_installationsNew
