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

const initialValues = {
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    slot: 'hair',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    rarity: 'common',
    
    
    
    
    
    
    
    price: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_dyeable: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    preview_images: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    asset_files: [],
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/customization_items/customization_items-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="Slot" labelFor="slot">
      <Field name="slot" id="slot" component="select">
      
        <option value="hair">hair</option>
      
        <option value="eyes">eyes</option>
      
        <option value="skin">skin</option>
      
        <option value="body">body</option>
      
        <option value="top">top</option>
      
        <option value="bottom">bottom</option>
      
        <option value="shoes">shoes</option>
      
        <option value="accessory">accessory</option>
      
        <option value="backpack">backpack</option>
      
      </Field>
  </FormField>



























  <FormField label="Rarity" labelFor="rarity">
      <Field name="rarity" id="rarity" component="select">
      
        <option value="common">common</option>
      
        <option value="uncommon">uncommon</option>
      
        <option value="rare">rare</option>
      
        <option value="epic">epic</option>
      
        <option value="legendary">legendary</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Price"
    >
        <Field
            type="number"
            name="price"
            placeholder="Price"
        />
    </FormField>





































  <FormField label='IsDyeable' labelFor='is_dyeable'>
      <Field
          name='is_dyeable'
          id='is_dyeable'
          component={SwitchField}
      ></Field>
  </FormField>

































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




























  <FormField>
      <Field
          label='AssetFiles'
          color='info'
          icon={mdiUpload}
          path={'customization_items/asset_files'}
          name='asset_files'
          id='asset_files'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></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('/customization_items/customization_items-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Customization_itemsNew
