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_title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sku: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    barcode: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    price: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    compare_at_price: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    inventory_quantity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    inventory_policy: 'deny',
    
    
    
    
    
    
    
    
    
    
    
    
    
    taxable: false,
    
    
    
    
    
    
    
    
    
    weight: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    weight_unit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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="VariantTitle"
  >
      <Field
          name="variant_title"
          placeholder="VariantTitle"
      />
  </FormField>



























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



























  <FormField
      label="Barcode"
  >
      <Field
          name="barcode"
          placeholder="Barcode"
      />
  </FormField>

































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



























    <FormField
        label="CompareAtPrice"
    >
        <Field
            type="number"
            name="compare_at_price"
            placeholder="CompareAtPrice"
        />
    </FormField>



























    <FormField
        label="InventoryQuantity"
    >
        <Field
            type="number"
            name="inventory_quantity"
            placeholder="InventoryQuantity"
        />
    </FormField>



































  <FormField label="InventoryPolicy" labelFor="inventory_policy">
      <Field name="inventory_policy" id="inventory_policy" component="select">
      
        <option value="deny">deny</option>
      
        <option value="continue">continue</option>
      
      </Field>
  </FormField>





























  <FormField label='Taxable' labelFor='taxable'>
      <Field
          name='taxable'
          id='taxable'
          component={SwitchField}
      ></Field>
  </FormField>

















    <FormField
        label="Weight"
    >
        <Field
            type="number"
            name="weight"
            placeholder="Weight"
        />
    </FormField>





















  <FormField
      label="WeightUnit"
  >
      <Field
          name="weight_unit"
          placeholder="WeightUnit"
      />
  </FormField>













































  <FormField label="organizations" labelFor="organizations">
      <Field name="organizations" id="organizations" component={SelectField} options={[]} itemRef={'organizations'}></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
