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

const initialValues = {
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    slug: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    phase: 'dev',
    
    
    
    
    
    
    
    logo_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    favicon_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    og_image_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    theme_config_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    custom_css_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    cdn_base_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    entry_page_slug: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_deleted: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    deleted_at_time: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField
      label="Slug"
  >
      <Field
          name="slug"
          placeholder="Slug"
      />
  </FormField>































      <FormField label='Description' hasTextareaHeight>
          <Field
              name='description'
              id='description'
              component={RichTextField}
          ></Field>
      </FormField>





































  <FormField label="Phase" labelFor="phase">
      <Field name="phase" id="phase" component="select">
      
        <option value="dev">dev</option>
      
        <option value="stage">stage</option>
      
        <option value="production">production</option>
      
      </Field>
  </FormField>













  <FormField
      label="LogoURL"
  >
      <Field
          name="logo_url"
          placeholder="LogoURL"
      />
  </FormField>



























  <FormField
      label="FaviconURL"
  >
      <Field
          name="favicon_url"
          placeholder="FaviconURL"
      />
  </FormField>



























  <FormField
      label="OGImageURL"
  >
      <Field
          name="og_image_url"
          placeholder="OGImageURL"
      />
  </FormField>





























    <FormField label="ThemeconfigJSON" hasTextareaHeight>
        <Field name="theme_config_json" as="textarea" placeholder="ThemeconfigJSON" />
    </FormField>



























    <FormField label="CustomCSSJSON" hasTextareaHeight>
        <Field name="custom_css_json" as="textarea" placeholder="CustomCSSJSON" />
    </FormField>

























  <FormField
      label="CDNbaseURL"
  >
      <Field
          name="cdn_base_url"
          placeholder="CDNbaseURL"
      />
  </FormField>



























  <FormField
      label="Entrypageslug"
  >
      <Field
          name="entry_page_slug"
          placeholder="Entrypageslug"
      />
  </FormField>











































  <FormField label='Isdeleted' labelFor='is_deleted'>
      <Field
          name='is_deleted'
          id='is_deleted'
          component={SwitchField}
      ></Field>
  </FormField>





















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

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

export default ProjectsNew
