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 = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    recipient: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    notification_type: 'announcement',
    
    
    
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    message: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    announcement: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    homework: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    submission: '',
    
    
    
    
    
    
    
    
    
    
    is_read: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    read_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sent_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    priority: 'low',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sent_by: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    schools: '',
    
    
    
}


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="Recipient" labelFor="recipient">
      <Field name="recipient" id="recipient" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>























  <FormField label="NotificationType" labelFor="notification_type">
      <Field name="notification_type" id="notification_type" component="select">
      
        <option value="announcement">announcement</option>
      
        <option value="homework_assigned">homework_assigned</option>
      
        <option value="homework_due">homework_due</option>
      
        <option value="submission_received">submission_received</option>
      
        <option value="grade_posted">grade_posted</option>
      
        <option value="account_approval">account_approval</option>
      
        <option value="system">system</option>
      
        <option value="security">security</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="Announcement" labelFor="announcement">
      <Field name="announcement" id="announcement" component={SelectField} options={[]} itemRef={'announcements'}></Field>
  </FormField>



























  <FormField label="Homework" labelFor="homework">
      <Field name="homework" id="homework" component={SelectField} options={[]} itemRef={'homeworks'}></Field>
  </FormField>



























  <FormField label="Submission" labelFor="submission">
      <Field name="submission" id="submission" component={SelectField} options={[]} itemRef={'homework_submissions'}></Field>
  </FormField>

























  <FormField label='IsRead' labelFor='is_read'>
      <Field
          name='is_read'
          id='is_read'
          component={SwitchField}
      ></Field>
  </FormField>





















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



























  <FormField
      label="SentAt"
  >
      <Field
          type="datetime-local"
          name="sent_at"
          placeholder="SentAt"
      />
  </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>
      
        <option value="urgent">urgent</option>
      
      </Field>
  </FormField>































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



























  <FormField label="schools" labelFor="schools">
      <Field name="schools" id="schools" component={SelectField} options={[]} itemRef={'schools'}></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('/notifications/notifications-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default NotificationsNew
