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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    seller_tenant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    harvest: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    species: '',
    
    
    
    
    listing_title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    product_form: 'live',
    
    
    
    
    
    
    
    available_quantity_kg: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    price_per_kg: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    currency: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    available_from: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    expires_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    listing_status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    photos: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    fulfillment_location: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























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



























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









  <FormField
      label="ListingTitle"
  >
      <Field
          name="listing_title"
          placeholder="ListingTitle"
      />
  </FormField>































      <FormField label='Description' hasTextareaHeight>
          <Field
              name='description'
              id='description'
              component={RichTextField}
          ></Field>
      </FormField>





































  <FormField label="ProductForm" labelFor="product_form">
      <Field name="product_form" id="product_form" component="select">
      
        <option value="live">live</option>
      
        <option value="whole">whole</option>
      
        <option value="gutted">gutted</option>
      
        <option value="fillet">fillet</option>
      
        <option value="frozen">frozen</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



















    <FormField
        label="AvailableQuantityKg"
    >
        <Field
            type="number"
            name="available_quantity_kg"
            placeholder="AvailableQuantityKg"
        />
    </FormField>



























    <FormField
        label="PricePerKg"
    >
        <Field
            type="number"
            name="price_per_kg"
            placeholder="PricePerKg"
        />
    </FormField>





















  <FormField
      label="Currency"
  >
      <Field
          name="currency"
          placeholder="Currency"
      />
  </FormField>





































  <FormField
      label="AvailableFrom"
  >
      <Field
          type="datetime-local"
          name="available_from"
          placeholder="AvailableFrom"
      />
  </FormField>



























  <FormField
      label="ExpiresAt"
  >
      <Field
          type="datetime-local"
          name="expires_at"
          placeholder="ExpiresAt"
      />
  </FormField>































  <FormField label="ListingStatus" labelFor="listing_status">
      <Field name="listing_status" id="listing_status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="active">active</option>
      
        <option value="paused">paused</option>
      
        <option value="sold_out">sold_out</option>
      
        <option value="expired">expired</option>
      
        <option value="removed">removed</option>
      
      </Field>
  </FormField>



































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























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

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

export default Marketplace_listingsNew
