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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    product: '',
    
    
    
    
    variant_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sku: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    size: '20x30',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    difficulty: 'easy',
    
    
    
    
    
    
    
    price: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    inventory_quantity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_active: false,
    
    
    
    
    
    
    
    
}


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

    
    

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









  <FormField
      label="VariantName"
  >
      <Field
          name="variant_name"
          placeholder="VariantName"
      />
  </FormField>



























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









































  <FormField label="Size" labelFor="size">
      <Field name="size" id="size" component="select">
      
        <option value="20x30">20x30</option>
      
        <option value="30x40">30x40</option>
      
        <option value="40x50">40x50</option>
      
        <option value="50x70">50x70</option>
      
        <option value="60x80">60x80</option>
      
      </Field>
  </FormField>



























  <FormField label="Difficulty" labelFor="difficulty">
      <Field name="difficulty" id="difficulty" component="select">
      
        <option value="easy">easy</option>
      
        <option value="medium">medium</option>
      
        <option value="hard">hard</option>
      
        <option value="expert">expert</option>
      
      </Field>
  </FormField>



















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



























    <FormField
        label="InventoryQuantity"
    >
        <Field
            type="number"
            name="inventory_quantity"
            placeholder="InventoryQuantity"
        />
    </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('/product_variants/product_variants-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Product_variantsNew
