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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    invitee_email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    invitee_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    role: 'org_admin',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    invited_by_user: '',
    
    
    
    
    invite_token_hash: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    expires_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'pending',
    
    
    
    
    
    
    
    
    
    
    
    
    accepted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    revoked_at: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/user_invitations/user_invitations-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="InviteeEmail"
  >
      <Field
          name="invitee_email"
          placeholder="InviteeEmail"
      />
  </FormField>



























  <FormField
      label="InviteeName"
  >
      <Field
          name="invitee_name"
          placeholder="InviteeName"
      />
  </FormField>









































  <FormField label="Role" labelFor="role">
      <Field name="role" id="role" component="select">
      
        <option value="org_admin">org_admin</option>
      
        <option value="compliance_manager">compliance_manager</option>
      
        <option value="security_manager">security_manager</option>
      
        <option value="iam_operator">iam_operator</option>
      
        <option value="auditor">auditor</option>
      
        <option value="read_only_client">read_only_client</option>
      
      </Field>
  </FormField>































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









  <FormField
      label="InviteTokenHash"
  >
      <Field
          name="invite_token_hash"
          placeholder="InviteTokenHash"
      />
  </FormField>





































  <FormField
      label="ExpiresAt"
  >
      <Field
          type="datetime-local"
          name="expires_at"
          placeholder="ExpiresAt"
      />
  </FormField>































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="accepted">accepted</option>
      
        <option value="revoked">revoked</option>
      
        <option value="expired">expired</option>
      
      </Field>
  </FormField>























  <FormField
      label="AcceptedAt"
  >
      <Field
          type="datetime-local"
          name="accepted_at"
          placeholder="AcceptedAt"
      />
  </FormField>



























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

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

export default User_invitationsNew
