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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    store: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    register: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    cashier_employee: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    customer_npc: '',
    
    
    
    
    
    
    
    
    
    sold_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payment_method: 'cash',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'open',
    
    
    
    
    
    
    
    subtotal_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tax_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    total_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="CashierEmployee" labelFor="cashier_employee">
      <Field name="cashier_employee" id="cashier_employee" component={SelectField} options={[]} itemRef={'employees'}></Field>
  </FormField>



























  <FormField label="CustomerNPC" labelFor="customer_npc">
      <Field name="customer_npc" id="customer_npc" component={SelectField} options={[]} itemRef={'npcs'}></Field>
  </FormField>



















  <FormField
      label="SoldAt"
  >
      <Field
          type="datetime-local"
          name="sold_at"
          placeholder="SoldAt"
      />
  </FormField>































  <FormField label="PaymentMethod" labelFor="payment_method">
      <Field name="payment_method" id="payment_method" component="select">
      
        <option value="cash">cash</option>
      
        <option value="pix">pix</option>
      
        <option value="credit_card">credit_card</option>
      
        <option value="debit_card">debit_card</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="open">open</option>
      
        <option value="paid">paid</option>
      
        <option value="voided">voided</option>
      
        <option value="refunded">refunded</option>
      
      </Field>
  </FormField>



















    <FormField
        label="SubtotalAmount"
    >
        <Field
            type="number"
            name="subtotal_amount"
            placeholder="SubtotalAmount"
        />
    </FormField>



























    <FormField
        label="TaxAmount"
    >
        <Field
            type="number"
            name="tax_amount"
            placeholder="TaxAmount"
        />
    </FormField>



























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

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

export default Sales_transactionsNew
