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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    restaurant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    order: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    client_user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    payment_method: 'espece',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'initie',
    
    
    
    
    
    
    
    amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    paid_at: '',
    
    
    
    
    
    
    
    
    
    
    provider_reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    receipt_file: [],
    
    
    
    
    
    
    
    receipt_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    points_earned: '',
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="Commande" labelFor="order">
      <Field name="order" id="order" component={SelectField} options={[]} itemRef={'orders'}></Field>
  </FormField>



























  <FormField label="Client" labelFor="client_user">
      <Field name="client_user" id="client_user" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>























  <FormField label="Modedepaiement" labelFor="payment_method">
      <Field name="payment_method" id="payment_method" component="select">
      
        <option value="espece">espece</option>
      
        <option value="orange_money">orange_money</option>
      
        <option value="mtn_mobile_money">mtn_mobile_money</option>
      
        <option value="moov_money">moov_money</option>
      
        <option value="wave">wave</option>
      
        <option value="visa">visa</option>
      
        <option value="mastercard">mastercard</option>
      
      </Field>
  </FormField>



























  <FormField label="Statutpaiement" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="initie">initie</option>
      
        <option value="reussi">reussi</option>
      
        <option value="echoue">echoue</option>
      
        <option value="rembourse">rembourse</option>
      
      </Field>
  </FormField>



















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































  <FormField
      label="Datedepaiement"
  >
      <Field
          type="datetime-local"
          name="paid_at"
          placeholder="Datedepaiement"
      />
  </FormField>

















  <FormField
      label="Référenceprestataire"
  >
      <Field
          name="provider_reference"
          placeholder="Référenceprestataire"
      />
  </FormField>


















































  <FormField>
      <Field
          label='Reçudepaiement(fichier)'
          color='info'
          icon={mdiUpload}
          path={'payments/receipt_file'}
          name='receipt_file'
          id='receipt_file'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>






    <FormField label="Reçudepaiement(texte)" hasTextareaHeight>
        <Field name="receipt_text" as="textarea" placeholder="Reçudepaiement(texte)" />
    </FormField>































    <FormField
        label="Pointsgagnés"
    >
        <Field
            type="number"
            name="points_earned"
            placeholder="Pointsgagnés"
        />
    </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('/payments/payments-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default PaymentsNew
