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: 'like',
    
    
    
    
    
    
    
    title_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    body_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    priority: 'low',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    post: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    comment: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    group: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    conversation: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    event: '',
    
    
    
    
    
    
    
    
    
    
    is_read: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sent_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    read_at: '',
    
    
    
    
    
    
    
    
    
}


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="like">like</option>
      
        <option value="comment">comment</option>
      
        <option value="follow">follow</option>
      
        <option value="mention">mention</option>
      
        <option value="share">share</option>
      
        <option value="message">message</option>
      
        <option value="group_invite">group_invite</option>
      
        <option value="group_request">group_request</option>
      
        <option value="event_invite">event_invite</option>
      
        <option value="live_started">live_started</option>
      
        <option value="system">system</option>
      
      </Field>
  </FormField>













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





























    <FormField label="Body" hasTextareaHeight>
        <Field name="body_text" as="textarea" placeholder="Body" />
    </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="Post" labelFor="post">
      <Field name="post" id="post" component={SelectField} options={[]} itemRef={'posts'}></Field>
  </FormField>



























  <FormField label="Comment" labelFor="comment">
      <Field name="comment" id="comment" component={SelectField} options={[]} itemRef={'comments'}></Field>
  </FormField>



























  <FormField label="Group" labelFor="group">
      <Field name="group" id="group" component={SelectField} options={[]} itemRef={'groups'}></Field>
  </FormField>



























  <FormField label="Conversation" labelFor="conversation">
      <Field name="conversation" id="conversation" component={SelectField} options={[]} itemRef={'conversations'}></Field>
  </FormField>



























  <FormField label="Event" labelFor="event">
      <Field name="event" id="event" component={SelectField} options={[]} itemRef={'events'}></Field>
  </FormField>

























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





















  <FormField
      label="SentAt"
  >
      <Field
          type="datetime-local"
          name="sent_at"
          placeholder="SentAt"
      />
  </FormField>



























  <FormField
      label="ReadAt"
  >
      <Field
          type="datetime-local"
          name="read_at"
          placeholder="ReadAt"
      />
  </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
