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

const initialValues = {
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    icon_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    author_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    widget_type: 'chat_box',
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_public: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_adult_only: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bundle_files: [],
    
    
    
    
    
    
    
    schema_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField
      label="IconName"
  >
      <Field
          name="icon_name"
          placeholder="IconName"
      />
  </FormField>



























  <FormField
      label="AuthorName"
  >
      <Field
          name="author_name"
          placeholder="AuthorName"
      />
  </FormField>









































  <FormField label="WidgetType" labelFor="widget_type">
      <Field name="widget_type" id="widget_type" component="select">
      
        <option value="chat_box">chat_box</option>
      
        <option value="goal_meter">goal_meter</option>
      
        <option value="sub_bar">sub_bar</option>
      
        <option value="now_playing">now_playing</option>
      
        <option value="poll">poll</option>
      
        <option value="alert_box">alert_box</option>
      
        <option value="custom">custom</option>
      
      </Field>
  </FormField>

















      <FormField label='Description' hasTextareaHeight>
          <Field
              name='description'
              id='description'
              component={RichTextField}
          ></Field>
      </FormField>







































  <FormField label='IsPublic' labelFor='is_public'>
      <Field
          name='is_public'
          id='is_public'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='IsAdultOnly' labelFor='is_adult_only'>
      <Field
          name='is_adult_only'
          id='is_adult_only'
          component={SwitchField}
      ></Field>
  </FormField>


































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






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

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

export default Widget_catalog_itemsNew
