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

const initialValues = {
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    slug: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    plan_tier: 'free',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant_status: 'active',
    
    
    
    
    
    
    
    
    
    
    
    
    activated_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    suspended_at: '',
    
    
    
    
    
    
    
    
    
    
    default_region: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    e2ee_default_enabled: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    education_module_enabled: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    marketplace_enabled: false,
    
    
    
    
    
    
    
    
    
    
    data_retention_policy: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField
      label="Slug"
  >
      <Field
          name="slug"
          placeholder="Slug"
      />
  </FormField>









































  <FormField label="PlanTier" labelFor="plan_tier">
      <Field name="plan_tier" id="plan_tier" component="select">
      
        <option value="free">free</option>
      
        <option value="pro">pro</option>
      
        <option value="business">business</option>
      
        <option value="enterprise">enterprise</option>
      
      </Field>
  </FormField>



























  <FormField label="TenantStatus" labelFor="tenant_status">
      <Field name="tenant_status" id="tenant_status" component="select">
      
        <option value="active">active</option>
      
        <option value="trial">trial</option>
      
        <option value="past_due">past_due</option>
      
        <option value="suspended">suspended</option>
      
        <option value="closed">closed</option>
      
      </Field>
  </FormField>























  <FormField
      label="ActivatedAt"
  >
      <Field
          type="datetime-local"
          name="activated_at"
          placeholder="ActivatedAt"
      />
  </FormField>



























  <FormField
      label="SuspendedAt"
  >
      <Field
          type="datetime-local"
          name="suspended_at"
          placeholder="SuspendedAt"
      />
  </FormField>

















  <FormField
      label="DefaultRegion"
  >
      <Field
          name="default_region"
          placeholder="DefaultRegion"
      />
  </FormField>











































  <FormField label='E2EEDefaultEnabled' labelFor='e2ee_default_enabled'>
      <Field
          name='e2ee_default_enabled'
          id='e2ee_default_enabled'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='EducationModuleEnabled' labelFor='education_module_enabled'>
      <Field
          name='education_module_enabled'
          id='education_module_enabled'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='MarketplaceEnabled' labelFor='marketplace_enabled'>
      <Field
          name='marketplace_enabled'
          id='marketplace_enabled'
          component={SwitchField}
      ></Field>
  </FormField>













    <FormField label="DataRetentionPolicy" hasTextareaHeight>
        <Field name="data_retention_policy" as="textarea" placeholder="DataRetentionPolicy" />
    </FormField>











































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

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

export default TenantsNew
