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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    freelancer: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    category: '',
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    pricing_model: 'fixed',
    
    
    
    
    
    
    
    starting_price: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    delivery_days: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    gallery_images: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sample_files: [],
    
    
    
    
    
    
    
    
    
    
    
    
    is_featured: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tags: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    included_skills: [],
    
    
}


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

    
    

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



























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









  <FormField
      label="Title"
  >
      <Field
          name="title"
          placeholder="Title"
      />
  </FormField>































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





































  <FormField label="PricingModel" labelFor="pricing_model">
      <Field name="pricing_model" id="pricing_model" component="select">
      
        <option value="fixed">fixed</option>
      
        <option value="hourly">hourly</option>
      
      </Field>
  </FormField>



















    <FormField
        label="StartingPrice"
    >
        <Field
            type="number"
            name="starting_price"
            placeholder="StartingPrice"
        />
    </FormField>



























    <FormField
        label="DeliveryDays"
    >
        <Field
            type="number"
            name="delivery_days"
            placeholder="DeliveryDays"
        />
    </FormField>



































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="published">published</option>
      
        <option value="paused">paused</option>
      
      </Field>
  </FormField>



































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




























  <FormField>
      <Field
          label='SampleFiles'
          color='info'
          icon={mdiUpload}
          path={'service_listings/sample_files'}
          name='sample_files'
          id='sample_files'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>




















  <FormField label='IsFeatured' labelFor='is_featured'>
      <Field
          name='is_featured'
          id='is_featured'
          component={SwitchField}
      ></Field>
  </FormField>































    <FormField label='Tags' labelFor='tags'>
        <Field
            name='tags'
            id='tags'
            itemRef={'tags'}
            options={[]}
            component={SelectFieldMany}>
        </Field>
    </FormField>



























    <FormField label='IncludedSkills' labelFor='included_skills'>
        <Field
            name='included_skills'
            id='included_skills'
            itemRef={'skills'}
            options={[]}
            component={SelectFieldMany}>
        </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('/service_listings/service_listings-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Service_listingsNew
