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

const initialValues = {
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    address: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    manager: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'active',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/warehouses/warehouses-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('Yeni Kayıt')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Yeni Kayıt" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>



  <FormField
      label="Depo Adı"
  >
      <Field
          name="name"
          placeholder="Depo Adı"
      />
  </FormField>



























  <FormField
      label="Kod"
  >
      <Field
          name="code"
          placeholder="Kod"
      />
  </FormField>





























    <FormField label="Adres" hasTextareaHeight>
        <Field name="address" as="textarea" placeholder="Adres" />
    </FormField>











































  <FormField label="Yönetici" labelFor="manager">
      <Field name="manager" id="manager" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>























  <FormField label="Durum" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="active">active</option>
      
        <option value="inactive">inactive</option>
      
      </Field>
  </FormField>































  <FormField label="Organizasyon" labelFor="Organizasyon">
      <Field name="Organizasyon" id="Organizasyon" component={SelectField} options={[]} itemRef={'Organizasyon'}></Field>
  </FormField>







              <BaseDivider />
              <BaseButtons>
                <BaseButton type="submit" color="info" label="Kaydet" />
                <BaseButton type="reset" color="info" outline label="Sıfırla" />
                <BaseButton type='reset' color='danger' outline label='İptal' onClick={() => router.push('/warehouses/warehouses-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default WarehousesNew
