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

const initialValues = {
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    age: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    profession: 'shop_owner',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    personality: 'friendly',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    home_location: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    work_location: '',
    
    
    
    
    
    
    bio: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    emotion_state: 'happy',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    portrait_images: [],
    
    
    
    
    
    
    
    
    
    
    
    is_main_character: false,
    
    
    
    
    
    
    
    
}


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

    
    

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



































  <FormField label="Profession" labelFor="profession">
      <Field name="profession" id="profession" component="select">
      
        <option value="shop_owner">shop_owner</option>
      
        <option value="farmer">farmer</option>
      
        <option value="fisher">fisher</option>
      
        <option value="teacher">teacher</option>
      
        <option value="baker">baker</option>
      
        <option value="priest">priest</option>
      
        <option value="student">student</option>
      
        <option value="tourist">tourist</option>
      
        <option value="harbor_worker">harbor_worker</option>
      
        <option value="artisan">artisan</option>
      
        <option value="doctor">doctor</option>
      
        <option value="police">police</option>
      
        <option value="unemployed">unemployed</option>
      
      </Field>
  </FormField>



























  <FormField label="Personality" labelFor="personality">
      <Field name="personality" id="personality" component="select">
      
        <option value="friendly">friendly</option>
      
        <option value="shy">shy</option>
      
        <option value="bold">bold</option>
      
        <option value="serious">serious</option>
      
        <option value="cheerful">cheerful</option>
      
        <option value="grumpy">grumpy</option>
      
        <option value="curious">curious</option>
      
        <option value="romantic">romantic</option>
      
        <option value="ambitious">ambitious</option>
      
        <option value="laid_back">laid_back</option>
      
      </Field>
  </FormField>































  <FormField label="HomeLocation" labelFor="home_location">
      <Field name="home_location" id="home_location" component={SelectField} options={[]} itemRef={'locations'}></Field>
  </FormField>



























  <FormField label="WorkLocation" labelFor="work_location">
      <Field name="work_location" id="work_location" component={SelectField} options={[]} itemRef={'locations'}></Field>
  </FormField>













      <FormField label='Bio' hasTextareaHeight>
          <Field
              name='bio'
              id='bio'
              component={RichTextField}
          ></Field>
      </FormField>





































  <FormField label="EmotionState" labelFor="emotion_state">
      <Field name="emotion_state" id="emotion_state" component="select">
      
        <option value="happy">happy</option>
      
        <option value="neutral">neutral</option>
      
        <option value="sad">sad</option>
      
        <option value="angry">angry</option>
      
        <option value="stressed">stressed</option>
      
        <option value="excited">excited</option>
      
        <option value="tired">tired</option>
      
      </Field>
  </FormField>



































  <FormField>
      <Field
          label='PortraitImages'
          color='info'
          icon={mdiUpload}
          path={'npcs/portrait_images'}
          name='portrait_images'
          id='portrait_images'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormImagePicker}
      ></Field>
  </FormField>





















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

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

export default NpcsNew
