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

const initialValues = {
    
    
    policy_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    scope: 'free_user',
    
    
    
    
    
    
    
    
    
    
    daily_request_limit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    monthly_request_limit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    daily_cost_limit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    monthly_cost_limit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    hard_block_on_limit: false,
    
    
    
    
    
    
    
    
}


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

    
    

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









































  <FormField label="Scope" labelFor="scope">
      <Field name="scope" id="scope" component="select">
      
        <option value="free_user">free_user</option>
      
        <option value="member">member</option>
      
        <option value="admin">admin</option>
      
        <option value="custom">custom</option>
      
      </Field>
  </FormField>



















    <FormField
        label="DailyRequestLimit"
    >
        <Field
            type="number"
            name="daily_request_limit"
            placeholder="DailyRequestLimit"
        />
    </FormField>



























    <FormField
        label="MonthlyRequestLimit"
    >
        <Field
            type="number"
            name="monthly_request_limit"
            placeholder="MonthlyRequestLimit"
        />
    </FormField>



























    <FormField
        label="DailyCostLimit"
    >
        <Field
            type="number"
            name="daily_cost_limit"
            placeholder="DailyCostLimit"
        />
    </FormField>



























    <FormField
        label="MonthlyCostLimit"
    >
        <Field
            type="number"
            name="monthly_cost_limit"
            placeholder="MonthlyCostLimit"
        />
    </FormField>





































  <FormField label='HardBlockOnLimit' labelFor='hard_block_on_limit'>
      <Field
          name='hard_block_on_limit'
          id='hard_block_on_limit'
          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('/usage_limit_policies/usage_limit_policies-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Usage_limit_policiesNew
