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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    campaign: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    signal_type: 'metric_import',
    
    
    
    
    
    
    
    
    
    
    
    
    signal_at: '',
    
    
    
    
    
    
    
    
    
    
    signal_title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    signal_details: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    confidence_score: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    applied_to_brain: false,
    
    
    
    
    
    
    
    
}


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

    
    

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























  <FormField label="SignalType" labelFor="signal_type">
      <Field name="signal_type" id="signal_type" component="select">
      
        <option value="metric_import">metric_import</option>
      
        <option value="ab_result">ab_result</option>
      
        <option value="audience_comment">audience_comment</option>
      
        <option value="competitor_change">competitor_change</option>
      
        <option value="seasonal_pattern">seasonal_pattern</option>
      
        <option value="manual_insight">manual_insight</option>
      
      </Field>
  </FormField>























  <FormField
      label="SignalAt"
  >
      <Field
          type="datetime-local"
          name="signal_at"
          placeholder="SignalAt"
      />
  </FormField>

















  <FormField
      label="SignalTitle"
  >
      <Field
          name="signal_title"
          placeholder="SignalTitle"
      />
  </FormField>































      <FormField label='SignalDetails' hasTextareaHeight>
          <Field
              name='signal_details'
              id='signal_details'
              component={RichTextField}
          ></Field>
      </FormField>





























    <FormField
        label="ConfidenceScore"
    >
        <Field
            type="number"
            name="confidence_score"
            placeholder="ConfidenceScore"
        />
    </FormField>





































  <FormField label='AppliedToBrain' labelFor='applied_to_brain'>
      <Field
          name='applied_to_brain'
          id='applied_to_brain'
          component={SwitchField}
      ></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('/learning_signals/learning_signals-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Learning_signalsNew
