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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    workspace: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    author: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    message: '',
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    language: 'javascript',
    
    
    
    
    
    
    
    
    code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    entry_point: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_runnable: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























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



























  <FormField label="Message" labelFor="message">
      <Field name="message" id="message" component={SelectField} options={[]} itemRef={'messages'}></Field>
  </FormField>









  <FormField
      label="Title"
  >
      <Field
          name="title"
          placeholder="Title"
      />
  </FormField>









































  <FormField label="Language" labelFor="language">
      <Field name="language" id="language" component="select">
      
        <option value="javascript">javascript</option>
      
        <option value="typescript">typescript</option>
      
        <option value="python">python</option>
      
        <option value="java">java</option>
      
        <option value="csharp">csharp</option>
      
        <option value="cpp">cpp</option>
      
        <option value="go">go</option>
      
        <option value="rust">rust</option>
      
        <option value="php">php</option>
      
        <option value="ruby">ruby</option>
      
        <option value="swift">swift</option>
      
        <option value="kotlin">kotlin</option>
      
        <option value="html">html</option>
      
        <option value="css">css</option>
      
        <option value="sql">sql</option>
      
        <option value="bash">bash</option>
      
        <option value="yaml">yaml</option>
      
        <option value="json">json</option>
      
        <option value="markdown">markdown</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>















    <FormField label="Code" hasTextareaHeight>
        <Field name="code" as="textarea" placeholder="Code" />
    </FormField>

























  <FormField
      label="EntryPoint"
  >
      <Field
          name="entry_point"
          placeholder="EntryPoint"
      />
  </FormField>











































  <FormField label='IsRunnable' labelFor='is_runnable'>
      <Field
          name='is_runnable'
          id='is_runnable'
          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('/code_snippets/code_snippets-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Code_snippetsNew
