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

const initialValues = {
    
    
    event_ref: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    event_type: 'checkout.session.completed',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    membership: '',
    
    
    
    
    
    
    
    
    
    received_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    processed: false,
    
    
    
    
    
    
    
    
    
    
    processing_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/stripe_events/stripe_events-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="EventRef"
  >
      <Field
          name="event_ref"
          placeholder="EventRef"
      />
  </FormField>









































  <FormField label="EventType" labelFor="event_type">
      <Field name="event_type" id="event_type" component="select">
      
        <option value="checkout.session.completed">checkout.session.completed</option>
      
        <option value="customer.subscription.created">customer.subscription.created</option>
      
        <option value="customer.subscription.updated">customer.subscription.updated</option>
      
        <option value="customer.subscription.deleted">customer.subscription.deleted</option>
      
        <option value="invoice.paid">invoice.paid</option>
      
        <option value="invoice.payment_failed">invoice.payment_failed</option>
      
        <option value="payment_intent.succeeded">payment_intent.succeeded</option>
      
        <option value="payment_intent.payment_failed">payment_intent.payment_failed</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>































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



























  <FormField label="Membership" labelFor="membership">
      <Field name="membership" id="membership" component={SelectField} options={[]} itemRef={'memberships'}></Field>
  </FormField>



















  <FormField
      label="ReceivedAt"
  >
      <Field
          type="datetime-local"
          name="received_at"
          placeholder="ReceivedAt"
      />
  </FormField>

































  <FormField label='Processed' labelFor='processed'>
      <Field
          name='processed'
          id='processed'
          component={SwitchField}
      ></Field>
  </FormField>













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

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

export default Stripe_eventsNew
