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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    event_name: 'login',
    
    
    
    
    
    
    
    
    metadata_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    occurred_at: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























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























  <FormField label="EventName" labelFor="event_name">
      <Field name="event_name" id="event_name" component="select">
      
        <option value="login">login</option>
      
        <option value="request_created">request_created</option>
      
        <option value="request_status_changed">request_status_changed</option>
      
        <option value="message_sent">message_sent</option>
      
        <option value="document_uploaded">document_uploaded</option>
      
        <option value="payment_succeeded">payment_succeeded</option>
      
        <option value="invoice_paid">invoice_paid</option>
      
        <option value="webhook_delivered">webhook_delivered</option>
      
        <option value="csv_import_completed">csv_import_completed</option>
      
        <option value="csv_export_completed">csv_export_completed</option>
      
      </Field>
  </FormField>















    <FormField label="MetadataJSON" hasTextareaHeight>
        <Field name="metadata_json" as="textarea" placeholder="MetadataJSON" />
    </FormField>



































  <FormField
      label="OccurredAt"
  >
      <Field
          type="datetime-local"
          name="occurred_at"
          placeholder="OccurredAt"
      />
  </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('/usage_events/usage_events-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Usage_eventsNew
