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: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    subdomain: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'active',
    
    
    
    
    
    
    
    tagline: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    primary_color: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    secondary_color: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    logo: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    default_language: 'fr',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    primary_currency: 'USD',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    secondary_currency: 'none',
    
    
    
    
    
    
    
    
    
    
    
    
    
    sso_enabled: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    suspended_on: '',
    
    
    
    
    
    
    
    
    
    
    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="Nom"
  >
      <Field
          name="name"
          placeholder="Nom"
      />
  </FormField>



























  <FormField
      label="Sous-domaine"
  >
      <Field
          name="subdomain"
          placeholder="Sous-domaine"
      />
  </FormField>









































  <FormField label="Statut" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="active">active</option>
      
        <option value="suspended">suspended</option>
      
        <option value="pending_setup">pending_setup</option>
      
      </Field>
  </FormField>













  <FormField
      label="Slogan"
  >
      <Field
          name="tagline"
          placeholder="Slogan"
      />
  </FormField>



























  <FormField
      label="Couleurprimaire"
  >
      <Field
          name="primary_color"
          placeholder="Couleurprimaire"
      />
  </FormField>



























  <FormField
      label="Couleursecondaire"
  >
      <Field
          name="secondary_color"
          placeholder="Couleursecondaire"
      />
  </FormField>

















































  <FormField>
      <Field
          label='Logo'
          color='info'
          icon={mdiUpload}
          path={'tenants/logo'}
          name='logo'
          id='logo'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormImagePicker}
      ></Field>
  </FormField>



















  <FormField label="Languepardefaut" labelFor="default_language">
      <Field name="default_language" id="default_language" component="select">
      
        <option value="fr">fr</option>
      
        <option value="en">en</option>
      
      </Field>
  </FormField>



























  <FormField label="Deviseprincipale" labelFor="primary_currency">
      <Field name="primary_currency" id="primary_currency" component="select">
      
        <option value="USD">USD</option>
      
        <option value="CDF">CDF</option>
      
        <option value="EUR">EUR</option>
      
        <option value="GBP">GBP</option>
      
      </Field>
  </FormField>



























  <FormField label="Devisesecondaire" labelFor="secondary_currency">
      <Field name="secondary_currency" id="secondary_currency" component="select">
      
        <option value="none">none</option>
      
        <option value="USD">USD</option>
      
        <option value="CDF">CDF</option>
      
        <option value="EUR">EUR</option>
      
        <option value="GBP">GBP</option>
      
      </Field>
  </FormField>





























  <FormField label='SSOactive' labelFor='sso_enabled'>
      <Field
          name='sso_enabled'
          id='sso_enabled'
          component={SwitchField}
      ></Field>
  </FormField>





















  <FormField
      label="Datedesuspension"
  >
      <Field
          type="datetime-local"
          name="suspended_on"
          placeholder="Datedesuspension"
      />
  </FormField>

















  <FormField
      label="Politiquederetention"
  >
      <Field
          name="data_retention_policy"
          placeholder="Politiquederetention"
      />
  </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
