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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    product: '',
    
    
    
    
    
    
    
    
    
    purchased_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    price_supercharged: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    access_status: 'ACTIVE',
    
    
    
    
    
    
    
    
    
    
    
    
    access_expires_at: '',
    
    
    
    
    
    
    
    
    
    
    
    note: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="Product" labelFor="product">
      <Field name="product" id="product" component={SelectField} options={[]} itemRef={'products'}></Field>
  </FormField>



















  <FormField
      label="PurchasedAt"
  >
      <Field
          type="datetime-local"
          name="purchased_at"
          placeholder="PurchasedAt"
      />
  </FormField>























    <FormField
        label="PriceSupercharged"
    >
        <Field
            type="number"
            name="price_supercharged"
            placeholder="PriceSupercharged"
        />
    </FormField>



































  <FormField label="AccessStatus" labelFor="access_status">
      <Field name="access_status" id="access_status" component="select">
      
        <option value="ACTIVE">ACTIVE</option>
      
        <option value="EXPIRED">EXPIRED</option>
      
        <option value="REVOKED">REVOKED</option>
      
      </Field>
  </FormField>























  <FormField
      label="AccessExpiresAt"
  >
      <Field
          type="datetime-local"
          name="access_expires_at"
          placeholder="AccessExpiresAt"
      />
  </FormField>



















    <FormField label="Note" hasTextareaHeight>
        <Field name="note" as="textarea" placeholder="Note" />
    </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_purchases/product_purchases-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Product_purchasesNew
