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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    referrer: '',
    
    
    
    
    referral_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    referred_email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    referred_user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'INVITED',
    
    
    
    
    
    
    
    
    
    
    
    
    invited_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    signed_up_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    rewarded_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    reward_doodlecoins: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    note: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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









  <FormField
      label="ReferralCode"
  >
      <Field
          name="referral_code"
          placeholder="ReferralCode"
      />
  </FormField>



























  <FormField
      label="ReferredEmail"
  >
      <Field
          name="referred_email"
          placeholder="ReferredEmail"
      />
  </FormField>













































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























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="INVITED">INVITED</option>
      
        <option value="SIGNED_UP">SIGNED_UP</option>
      
        <option value="REWARDED">REWARDED</option>
      
        <option value="CANCELLED">CANCELLED</option>
      
      </Field>
  </FormField>























  <FormField
      label="InvitedAt"
  >
      <Field
          type="datetime-local"
          name="invited_at"
          placeholder="InvitedAt"
      />
  </FormField>



























  <FormField
      label="SignedUpAt"
  >
      <Field
          type="datetime-local"
          name="signed_up_at"
          placeholder="SignedUpAt"
      />
  </FormField>



























  <FormField
      label="RewardedAt"
  >
      <Field
          type="datetime-local"
          name="rewarded_at"
          placeholder="RewardedAt"
      />
  </FormField>























    <FormField
        label="RewardDoodlecoins"
    >
        <Field
            type="number"
            name="reward_doodlecoins"
            placeholder="RewardDoodlecoins"
        />
    </FormField>























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

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

export default ReferralsNew
