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

const initialValues = {
    
    
    
    
    
    
    
    
    terms_accepted: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    terms_accepted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    privacy_policy_accepted: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    privacy_policy_accepted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    marketing_emails_opt_in: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    marketing_opt_in_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    consent_source: 'web_guest_checkout',
    
    
    
    
    
    
    
    consent_version: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ip_address: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    user_agent: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    lawful_basis: 'contract',
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/gdpr_consents/gdpr_consents-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='TermsAccepted' labelFor='terms_accepted'>
      <Field
          name='terms_accepted'
          id='terms_accepted'
          component={SwitchField}
      ></Field>
  </FormField>





















  <FormField
      label="TermsAcceptedAt"
  >
      <Field
          type="datetime-local"
          name="terms_accepted_at"
          placeholder="TermsAcceptedAt"
      />
  </FormField>

































  <FormField label='PrivacyPolicyAccepted' labelFor='privacy_policy_accepted'>
      <Field
          name='privacy_policy_accepted'
          id='privacy_policy_accepted'
          component={SwitchField}
      ></Field>
  </FormField>





















  <FormField
      label="PrivacyPolicyAcceptedAt"
  >
      <Field
          type="datetime-local"
          name="privacy_policy_accepted_at"
          placeholder="PrivacyPolicyAcceptedAt"
      />
  </FormField>

































  <FormField label='MarketingEmailsOptIn' labelFor='marketing_emails_opt_in'>
      <Field
          name='marketing_emails_opt_in'
          id='marketing_emails_opt_in'
          component={SwitchField}
      ></Field>
  </FormField>





















  <FormField
      label="MarketingOptInAt"
  >
      <Field
          type="datetime-local"
          name="marketing_opt_in_at"
          placeholder="MarketingOptInAt"
      />
  </FormField>































  <FormField label="ConsentSource" labelFor="consent_source">
      <Field name="consent_source" id="consent_source" component="select">
      
        <option value="web_guest_checkout">web_guest_checkout</option>
      
        <option value="account_settings">account_settings</option>
      
        <option value="admin_recorded">admin_recorded</option>
      
      </Field>
  </FormField>













  <FormField
      label="ConsentVersion"
  >
      <Field
          name="consent_version"
          placeholder="ConsentVersion"
      />
  </FormField>



























  <FormField
      label="IPAddress"
  >
      <Field
          name="ip_address"
          placeholder="IPAddress"
      />
  </FormField>



























  <FormField
      label="UserAgent"
  >
      <Field
          name="user_agent"
          placeholder="UserAgent"
      />
  </FormField>









































  <FormField label="LawfulBasis" labelFor="lawful_basis">
      <Field name="lawful_basis" id="lawful_basis" component="select">
      
        <option value="contract">contract</option>
      
        <option value="consent">consent</option>
      
        <option value="legitimate_interest">legitimate_interest</option>
      
        <option value="legal_obligation">legal_obligation</option>
      
      </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('/gdpr_consents/gdpr_consents-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Gdpr_consentsNew
