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

const initialValues = {
    
    
    
    
    
    
    
    movement_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    direction: 'in',
    
    
    
    
    
    
    
    amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    method: 'cash',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    source_type: 'payment',
    
    
    
    
    
    
    
    reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payment: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    expense: '',
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    recorded_by_user: '',
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/cash_movements/cash_movements-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="Datemouvement"
  >
      <Field
          type="datetime-local"
          name="movement_at"
          placeholder="Datemouvement"
      />
  </FormField>































  <FormField label="Sens" labelFor="direction">
      <Field name="direction" id="direction" component="select">
      
        <option value="in">in</option>
      
        <option value="out">out</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Montant"
    >
        <Field
            type="number"
            name="amount"
            placeholder="Montant"
        />
    </FormField>



































  <FormField label="Méthode" labelFor="method">
      <Field name="method" id="method" component="select">
      
        <option value="cash">cash</option>
      
        <option value="bank_transfer">bank_transfer</option>
      
        <option value="orange_money">orange_money</option>
      
        <option value="wave">wave</option>
      
        <option value="cheque">cheque</option>
      
        <option value="card">card</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



























  <FormField label="Origine" labelFor="source_type">
      <Field name="source_type" id="source_type" component="select">
      
        <option value="payment">payment</option>
      
        <option value="expense">expense</option>
      
        <option value="adjustment">adjustment</option>
      
        <option value="opening_balance">opening_balance</option>
      
        <option value="transfer">transfer</option>
      
      </Field>
  </FormField>













  <FormField
      label="Référence"
  >
      <Field
          name="reference"
          placeholder="Référence"
      />
  </FormField>













































  <FormField label="Paiementlié" labelFor="payment">
      <Field name="payment" id="payment" component={SelectField} options={[]} itemRef={'payments'}></Field>
  </FormField>



























  <FormField label="Dépenseliée" labelFor="expense">
      <Field name="expense" id="expense" component={SelectField} options={[]} itemRef={'expenses'}></Field>
  </FormField>











    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </FormField>











































  <FormField label="Enregistrépar" labelFor="recorded_by_user">
      <Field name="recorded_by_user" id="recorded_by_user" component={SelectField} options={[]} itemRef={'users'}></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('/cash_movements/cash_movements-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Cash_movementsNew
