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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    provider_type: 'oidc',
    
    
    
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    issuer_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    client_id: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sso_metadata_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    jit_provisioning_enabled: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    scim_enabled: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    idp_status: 'active',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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























  <FormField label="ProviderType" labelFor="provider_type">
      <Field name="provider_type" id="provider_type" component="select">
      
        <option value="oidc">oidc</option>
      
        <option value="saml2">saml2</option>
      
        <option value="ldap">ldap</option>
      
      </Field>
  </FormField>













  <FormField
      label="ProviderName"
  >
      <Field
          name="name"
          placeholder="ProviderName"
      />
  </FormField>



























  <FormField
      label="IssuerURL"
  >
      <Field
          name="issuer_url"
          placeholder="IssuerURL"
      />
  </FormField>



























  <FormField
      label="ClientID"
  >
      <Field
          name="client_id"
          placeholder="ClientID"
      />
  </FormField>



























  <FormField
      label="SSOMetadataURL"
  >
      <Field
          name="sso_metadata_url"
          placeholder="SSOMetadataURL"
      />
  </FormField>











































  <FormField label='JITProvisioningEnabled' labelFor='jit_provisioning_enabled'>
      <Field
          name='jit_provisioning_enabled'
          id='jit_provisioning_enabled'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='SCIMEnabled' labelFor='scim_enabled'>
      <Field
          name='scim_enabled'
          id='scim_enabled'
          component={SwitchField}
      ></Field>
  </FormField>

























  <FormField label="IdPStatus" labelFor="idp_status">
      <Field name="idp_status" id="idp_status" component="select">
      
        <option value="active">active</option>
      
        <option value="disabled">disabled</option>
      
      </Field>
  </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('/identity_providers/identity_providers-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Identity_providersNew
