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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    sale: '',
    
    
    
    
    refund_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    refund_method: 'cash',
    
    
    
    
    
    
    
    amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'requested',
    
    
    
    
    
    
    
    
    
    
    
    
    requested_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approved_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requested_by: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approved_by: '',
    
    
    
    
    
    reason: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









  <FormField
      label="RefundNumber"
  >
      <Field
          name="refund_number"
          placeholder="RefundNumber"
      />
  </FormField>









































  <FormField label="RefundMethod" labelFor="refund_method">
      <Field name="refund_method" id="refund_method" component="select">
      
        <option value="cash">cash</option>
      
        <option value="card">card</option>
      
        <option value="mobile_money">mobile_money</option>
      
        <option value="store_credit">store_credit</option>
      
      </Field>
  </FormField>



















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



































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="requested">requested</option>
      
        <option value="approved">approved</option>
      
        <option value="paid">paid</option>
      
        <option value="rejected">rejected</option>
      
      </Field>
  </FormField>























  <FormField
      label="RequestedAt"
  >
      <Field
          type="datetime-local"
          name="requested_at"
          placeholder="RequestedAt"
      />
  </FormField>



























  <FormField
      label="ApprovedAt"
  >
      <Field
          type="datetime-local"
          name="approved_at"
          placeholder="ApprovedAt"
      />
  </FormField>



































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



























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











    <FormField label="Reason" hasTextareaHeight>
        <Field name="reason" as="textarea" placeholder="Reason" />
    </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('/refunds/refunds-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default RefundsNew
