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

const initialValues = {
    
    
    name_ar: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    slug: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    category: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    color: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    finishes: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    applications: [],
    
    
    
    
    short_description_ar: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description_ar: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    gallery_images: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    technical_sheet_files: [],
    
    
    
    
    
    
    density: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    water_absorption: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    compressive_strength: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    flexural_strength: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    origin_type: 'local',
    
    
    
    
    
    
    
    origin_country: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_featured: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_active: false,
    
    
    
    
    
    
    
    
}


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

    
    

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



























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













































  <FormField label="Category" labelFor="category">
      <Field name="category" id="category" component={SelectField} options={[]} itemRef={'stone_categories'}></Field>
  </FormField>



























  <FormField label="Color" labelFor="color">
      <Field name="color" id="color" component={SelectField} options={[]} itemRef={'stone_colors'}></Field>
  </FormField>





























    <FormField label='Finishes' labelFor='finishes'>
        <Field
            name='finishes'
            id='finishes'
            itemRef={'finishes'}
            options={[]}
            component={SelectFieldMany}>
        </Field>
    </FormField>



























    <FormField label='SuggestedUses' labelFor='applications'>
        <Field
            name='applications'
            id='applications'
            itemRef={'applications'}
            options={[]}
            component={SelectFieldMany}>
        </Field>
    </FormField>









    <FormField label="ShortDescriptionArabic" hasTextareaHeight>
        <Field name="short_description_ar" as="textarea" placeholder="ShortDescriptionArabic" />
    </FormField>





























      <FormField label='DescriptionArabic' hasTextareaHeight>
          <Field
              name='description_ar'
              id='description_ar'
              component={RichTextField}
          ></Field>
      </FormField>













































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




























  <FormField>
      <Field
          label='TechnicalSheetFiles'
          color='info'
          icon={mdiUpload}
          path={'stones/technical_sheet_files'}
          name='technical_sheet_files'
          id='technical_sheet_files'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>










    <FormField
        label="Density"
    >
        <Field
            type="number"
            name="density"
            placeholder="Density"
        />
    </FormField>



























    <FormField
        label="WaterAbsorption"
    >
        <Field
            type="number"
            name="water_absorption"
            placeholder="WaterAbsorption"
        />
    </FormField>



























    <FormField
        label="CompressiveStrength"
    >
        <Field
            type="number"
            name="compressive_strength"
            placeholder="CompressiveStrength"
        />
    </FormField>



























    <FormField
        label="FlexuralStrength"
    >
        <Field
            type="number"
            name="flexural_strength"
            placeholder="FlexuralStrength"
        />
    </FormField>



































  <FormField label="OriginType" labelFor="origin_type">
      <Field name="origin_type" id="origin_type" component="select">
      
        <option value="local">local</option>
      
        <option value="imported">imported</option>
      
        <option value="mixed">mixed</option>
      
      </Field>
  </FormField>













  <FormField
      label="OriginCountry"
  >
      <Field
          name="origin_country"
          placeholder="OriginCountry"
      />
  </FormField>











































  <FormField label='IsFeatured' labelFor='is_featured'>
      <Field
          name='is_featured'
          id='is_featured'
          component={SwitchField}
      ></Field>
  </FormField>



























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

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

export default StonesNew
