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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    store: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    item: '',
    
    
    
    
    current_price: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    pricing_mode: 'fixed',
    
    
    
    
    
    
    
    
    
    
    reorder_point: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    target_stock: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_listed: false,
    
    
    
    
    
    
    
    
    
    tax_rate: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="Item" labelFor="item">
      <Field name="item" id="item" component={SelectField} options={[]} itemRef={'items'}></Field>
  </FormField>















    <FormField
        label="CurrentPrice"
    >
        <Field
            type="number"
            name="current_price"
            placeholder="CurrentPrice"
        />
    </FormField>



































  <FormField label="PricingMode" labelFor="pricing_mode">
      <Field name="pricing_mode" id="pricing_mode" component="select">
      
        <option value="fixed">fixed</option>
      
        <option value="dynamic">dynamic</option>
      
        <option value="promotion">promotion</option>
      
      </Field>
  </FormField>



















    <FormField
        label="ReorderPoint"
    >
        <Field
            type="number"
            name="reorder_point"
            placeholder="ReorderPoint"
        />
    </FormField>



























    <FormField
        label="TargetStock"
    >
        <Field
            type="number"
            name="target_stock"
            placeholder="TargetStock"
        />
    </FormField>





































  <FormField label='IsListed' labelFor='is_listed'>
      <Field
          name='is_listed'
          id='is_listed'
          component={SwitchField}
      ></Field>
  </FormField>

















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

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

export default Store_productsNew
