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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    recipient_user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    notification_type: 'packet_due',
    
    
    
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    message: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    priority: 'low',
    
    
    
    
    
    
    
    
    
    
    
    
    
    read_flag: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    read_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    target_entity_type: 'proof_packet',
    
    
    
    
    
    
    
    target_entity_key: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    scheduled_for: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

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























  <FormField label="NotificationType" labelFor="notification_type">
      <Field name="notification_type" id="notification_type" component="select">
      
        <option value="packet_due">packet_due</option>
      
        <option value="remediation_overdue">remediation_overdue</option>
      
        <option value="artifact_pending_validation">artifact_pending_validation</option>
      
        <option value="review_deadline">review_deadline</option>
      
        <option value="exception_expiration">exception_expiration</option>
      
        <option value="system_connection_degraded">system_connection_degraded</option>
      
        <option value="packet_ready">packet_ready</option>
      
        <option value="comment_mention">comment_mention</option>
      
      </Field>
  </FormField>













  <FormField
      label="Title"
  >
      <Field
          name="title"
          placeholder="Title"
      />
  </FormField>





























    <FormField label="Message" hasTextareaHeight>
        <Field name="message" as="textarea" placeholder="Message" />
    </FormField>







































  <FormField label="Priority" labelFor="priority">
      <Field name="priority" id="priority" component="select">
      
        <option value="low">low</option>
      
        <option value="normal">normal</option>
      
        <option value="high">high</option>
      
      </Field>
  </FormField>





























  <FormField label='ReadFlag' labelFor='read_flag'>
      <Field
          name='read_flag'
          id='read_flag'
          component={SwitchField}
      ></Field>
  </FormField>





















  <FormField
      label="ReadAt"
  >
      <Field
          type="datetime-local"
          name="read_at"
          placeholder="ReadAt"
      />
  </FormField>































  <FormField label="TargetEntityType" labelFor="target_entity_type">
      <Field name="target_entity_type" id="target_entity_type" component="select">
      
        <option value="proof_packet">proof_packet</option>
      
        <option value="remediation_item">remediation_item</option>
      
        <option value="artifact">artifact</option>
      
        <option value="access_review">access_review</option>
      
        <option value="exception">exception</option>
      
        <option value="connected_system">connected_system</option>
      
        <option value="identity_workflow">identity_workflow</option>
      
      </Field>
  </FormField>













  <FormField
      label="TargetEntityKey"
  >
      <Field
          name="target_entity_key"
          placeholder="TargetEntityKey"
      />
  </FormField>





































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

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

export default NotificationsNew
