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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    stone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    variant_type: 'slab',
    
    
    
    
    
    
    
    sku: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    length_mm: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    width_mm: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    thickness_mm: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    weight_kg: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    availability_status: 'in_stock',
    
    
    
    
    
    
    
    base_price: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    price_note_ar: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    images: [],
    
    
    
    
    
    
    
    
    
    
    
    is_active: false,
    
    
    
    
    
    
    
    
}


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

    
    

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























  <FormField label="VariantType" labelFor="variant_type">
      <Field name="variant_type" id="variant_type" component="select">
      
        <option value="slab">slab</option>
      
        <option value="tile">tile</option>
      
        <option value="stair">stair</option>
      
        <option value="countertop">countertop</option>
      
        <option value="custom">custom</option>
      
      </Field>
  </FormField>













  <FormField
      label="SKU"
  >
      <Field
          name="sku"
          placeholder="SKU"
      />
  </FormField>

































    <FormField
        label="Lengthmm"
    >
        <Field
            type="number"
            name="length_mm"
            placeholder="Lengthmm"
        />
    </FormField>



























    <FormField
        label="Widthmm"
    >
        <Field
            type="number"
            name="width_mm"
            placeholder="Widthmm"
        />
    </FormField>



























    <FormField
        label="Thicknessmm"
    >
        <Field
            type="number"
            name="thickness_mm"
            placeholder="Thicknessmm"
        />
    </FormField>



























    <FormField
        label="Weightkg"
    >
        <Field
            type="number"
            name="weight_kg"
            placeholder="Weightkg"
        />
    </FormField>



































  <FormField label="AvailabilityStatus" labelFor="availability_status">
      <Field name="availability_status" id="availability_status" component="select">
      
        <option value="in_stock">in_stock</option>
      
        <option value="made_to_order">made_to_order</option>
      
        <option value="out_of_stock">out_of_stock</option>
      
        <option value="discontinued">discontinued</option>
      
      </Field>
  </FormField>



















    <FormField
        label="BasePrice"
    >
        <Field
            type="number"
            name="base_price"
            placeholder="BasePrice"
        />
    </FormField>























    <FormField label="PriceNoteArabic" hasTextareaHeight>
        <Field name="price_note_ar" as="textarea" placeholder="PriceNoteArabic" />
    </FormField>















































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

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

export default Stone_variantsNew
