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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    payout_reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    recipient_user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    payout_method: 'bank_transfer',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payout_status: 'draft',
    
    
    
    
    
    
    
    gross_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    fee_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    net_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    scheduled_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    processed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    paid_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payout_proof_files: [],
    
    
    
    
    
    
    
    note: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









  <FormField
      label="PayoutReference"
  >
      <Field
          name="payout_reference"
          placeholder="PayoutReference"
      />
  </FormField>













































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























  <FormField label="PayoutMethod" labelFor="payout_method">
      <Field name="payout_method" id="payout_method" component="select">
      
        <option value="bank_transfer">bank_transfer</option>
      
        <option value="ewallet">ewallet</option>
      
        <option value="cash">cash</option>
      
      </Field>
  </FormField>



























  <FormField label="PayoutStatus" labelFor="payout_status">
      <Field name="payout_status" id="payout_status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="scheduled">scheduled</option>
      
        <option value="processing">processing</option>
      
        <option value="paid">paid</option>
      
        <option value="failed">failed</option>
      
        <option value="cancelled">cancelled</option>
      
      </Field>
  </FormField>



















    <FormField
        label="GrossAmount"
    >
        <Field
            type="number"
            name="gross_amount"
            placeholder="GrossAmount"
        />
    </FormField>



























    <FormField
        label="FeeAmount"
    >
        <Field
            type="number"
            name="fee_amount"
            placeholder="FeeAmount"
        />
    </FormField>



























    <FormField
        label="NetAmount"
    >
        <Field
            type="number"
            name="net_amount"
            placeholder="NetAmount"
        />
    </FormField>































  <FormField
      label="ScheduledAt"
  >
      <Field
          type="datetime-local"
          name="scheduled_at"
          placeholder="ScheduledAt"
      />
  </FormField>



























  <FormField
      label="ProcessedAt"
  >
      <Field
          type="datetime-local"
          name="processed_at"
          placeholder="ProcessedAt"
      />
  </FormField>



























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








































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






    <FormField label="Note" hasTextareaHeight>
        <Field name="note" as="textarea" placeholder="Note" />
    </FormField>











































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

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

export default PayoutsNew
