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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    insight_type: 'sales_forecast',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    severity: 'info',
    
    
    
    
    
    
    
    insight_title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    insight_summary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    recommendation: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    related_user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    related_product: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    related_warehouse: '',
    
    
    
    
    
    
    
    
    
    generated_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    valid_until: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_acknowledged: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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























  <FormField label="InsightType" labelFor="insight_type">
      <Field name="insight_type" id="insight_type" component="select">
      
        <option value="sales_forecast">sales_forecast</option>
      
        <option value="stock_forecast">stock_forecast</option>
      
        <option value="performance_drop">performance_drop</option>
      
        <option value="top_reseller">top_reseller</option>
      
        <option value="strategy_recommendation">strategy_recommendation</option>
      
        <option value="market_opportunity">market_opportunity</option>
      
      </Field>
  </FormField>



























  <FormField label="Severity" labelFor="severity">
      <Field name="severity" id="severity" component="select">
      
        <option value="info">info</option>
      
        <option value="warning">warning</option>
      
        <option value="critical">critical</option>
      
      </Field>
  </FormField>













  <FormField
      label="InsightTitle"
  >
      <Field
          name="insight_title"
          placeholder="InsightTitle"
      />
  </FormField>





























    <FormField label="InsightSummary" hasTextareaHeight>
        <Field name="insight_summary" as="textarea" placeholder="InsightSummary" />
    </FormField>





























      <FormField label='Recommendation' hasTextareaHeight>
          <Field
              name='recommendation'
              id='recommendation'
              component={RichTextField}
          ></Field>
      </FormField>









































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



























  <FormField label="RelatedProduct" labelFor="related_product">
      <Field name="related_product" id="related_product" component={SelectField} options={[]} itemRef={'products'}></Field>
  </FormField>



























  <FormField label="RelatedWarehouse" labelFor="related_warehouse">
      <Field name="related_warehouse" id="related_warehouse" component={SelectField} options={[]} itemRef={'warehouses'}></Field>
  </FormField>



















  <FormField
      label="GeneratedAt"
  >
      <Field
          type="datetime-local"
          name="generated_at"
          placeholder="GeneratedAt"
      />
  </FormField>



























  <FormField
      label="ValidUntil"
  >
      <Field
          type="datetime-local"
          name="valid_until"
          placeholder="ValidUntil"
      />
  </FormField>

































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

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

export default Ai_insightsNew
