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 = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    contract: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payer: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payee: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    payment_type: 'escrow_deposit',
    
    
    
    
    
    
    
    amount_gross: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    platform_fee_client_rate: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    platform_fee_freelancer_rate: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    platform_fee_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    amount_net: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'pending',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    provider: 'simulated',
    
    
    
    
    
    
    
    provider_reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    initiated_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    paid_at: '',
    
    
    
    
    
    
    
    
    
}


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



























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



























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























  <FormField label="PaymentType" labelFor="payment_type">
      <Field name="payment_type" id="payment_type" component="select">
      
        <option value="escrow_deposit">escrow_deposit</option>
      
        <option value="milestone_release">milestone_release</option>
      
        <option value="refund">refund</option>
      
        <option value="payout">payout</option>
      
      </Field>
  </FormField>



















    <FormField
        label="AmountGross"
    >
        <Field
            type="number"
            name="amount_gross"
            placeholder="AmountGross"
        />
    </FormField>



























    <FormField
        label="PlatformFeeClientRate"
    >
        <Field
            type="number"
            name="platform_fee_client_rate"
            placeholder="PlatformFeeClientRate"
        />
    </FormField>



























    <FormField
        label="PlatformFeeFreelancerRate"
    >
        <Field
            type="number"
            name="platform_fee_freelancer_rate"
            placeholder="PlatformFeeFreelancerRate"
        />
    </FormField>



























    <FormField
        label="PlatformFeeAmount"
    >
        <Field
            type="number"
            name="platform_fee_amount"
            placeholder="PlatformFeeAmount"
        />
    </FormField>



























    <FormField
        label="AmountNet"
    >
        <Field
            type="number"
            name="amount_net"
            placeholder="AmountNet"
        />
    </FormField>



































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



























  <FormField label="Provider" labelFor="provider">
      <Field name="provider" id="provider" component="select">
      
        <option value="simulated">simulated</option>
      
        <option value="stripe">stripe</option>
      
        <option value="paypal">paypal</option>
      
      </Field>
  </FormField>













  <FormField
      label="ProviderReference"
  >
      <Field
          name="provider_reference"
          placeholder="ProviderReference"
      />
  </FormField>





































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



























  <FormField
      label="PaidAt"
  >
      <Field
          type="datetime-local"
          name="paid_at"
          placeholder="PaidAt"
      />
  </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
