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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    trophy: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    award_status: 'pending',
    
    
    
    
    
    
    
    
    award_reason: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    awarded_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_visible_on_profile: false,
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="Trophy" labelFor="trophy">
      <Field name="trophy" id="trophy" component={SelectField} options={[]} itemRef={'trophies'}></Field>
  </FormField>























  <FormField label="AwardStatus" labelFor="award_status">
      <Field name="award_status" id="award_status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="awarded">awarded</option>
      
        <option value="revoked">revoked</option>
      
      </Field>
  </FormField>















    <FormField label="AwardReason" hasTextareaHeight>
        <Field name="award_reason" as="textarea" placeholder="AwardReason" />
    </FormField>



































  <FormField
      label="AwardedAt"
  >
      <Field
          type="datetime-local"
          name="awarded_at"
          placeholder="AwardedAt"
      />
  </FormField>

































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

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

export default User_trophiesNew
