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 = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    repair_order: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payment_method: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    payment_type: 'deposit',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'pending',
    
    
    
    
    
    
    
    amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    currency: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reference_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    provider_transaction_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    initiated_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    confirmed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    proof_files: [],
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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="RepairOrder" labelFor="repair_order">
      <Field name="repair_order" id="repair_order" component={SelectField} options={[]} itemRef={'repair_orders'}></Field>
  </FormField>



























  <FormField label="PaymentMethod" labelFor="payment_method">
      <Field name="payment_method" id="payment_method" component={SelectField} options={[]} itemRef={'payment_methods'}></Field>
  </FormField>























  <FormField label="PaymentType" labelFor="payment_type">
      <Field name="payment_type" id="payment_type" component="select">
      
        <option value="deposit">deposit</option>
      
        <option value="full">full</option>
      
        <option value="balance">balance</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="submitted">submitted</option>
      
        <option value="confirmed">confirmed</option>
      
        <option value="failed">failed</option>
      
        <option value="refunded">refunded</option>
      
        <option value="cancelled">cancelled</option>
      
      </Field>
  </FormField>



















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





















  <FormField
      label="Currency"
  >
      <Field
          name="currency"
          placeholder="Currency"
      />
  </FormField>



























  <FormField
      label="ReferenceCode"
  >
      <Field
          name="reference_code"
          placeholder="ReferenceCode"
      />
  </FormField>



























  <FormField
      label="ProviderTransactionCode"
  >
      <Field
          name="provider_transaction_code"
          placeholder="ProviderTransactionCode"
      />
  </FormField>





































  <FormField
      label="InitiatedAt"
  >
      <Field
          type="datetime-local"
          name="initiated_at"
          placeholder="InitiatedAt"
      />
  </FormField>



























  <FormField
      label="ConfirmedAt"
  >
      <Field
          type="datetime-local"
          name="confirmed_at"
          placeholder="ConfirmedAt"
      />
  </FormField>








































  <FormField>
      <Field
          label='ProofFiles'
          color='info'
          icon={mdiUpload}
          path={'payments/proof_files'}
          name='proof_files'
          id='proof_files'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>






    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </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
