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

const initialValues = {
    
    
    name_ar: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    slug: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    service_type: 'cnc_cutting',
    
    
    
    
    
    
    
    
    summary_ar: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description_ar: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    images: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    brochure_files: [],
    
    
    
    
    
    
    
    
    
    sort_order: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_featured: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_active: false,
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/services/services-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="NameArabic"
  >
      <Field
          name="name_ar"
          placeholder="NameArabic"
      />
  </FormField>



























  <FormField
      label="Slug"
  >
      <Field
          name="slug"
          placeholder="Slug"
      />
  </FormField>









































  <FormField label="ServiceType" labelFor="service_type">
      <Field name="service_type" id="service_type" component="select">
      
        <option value="cnc_cutting">cnc_cutting</option>
      
        <option value="waterjet_cutting">waterjet_cutting</option>
      
        <option value="polishing">polishing</option>
      
        <option value="profiling">profiling</option>
      
        <option value="edge_finishing">edge_finishing</option>
      
        <option value="engraving">engraving</option>
      
        <option value="installation_support">installation_support</option>
      
        <option value="custom_fabrication">custom_fabrication</option>
      
        <option value="consultation">consultation</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>















    <FormField label="SummaryArabic" hasTextareaHeight>
        <Field name="summary_ar" as="textarea" placeholder="SummaryArabic" />
    </FormField>





























      <FormField label='DescriptionArabic' hasTextareaHeight>
          <Field
              name='description_ar'
              id='description_ar'
              component={RichTextField}
          ></Field>
      </FormField>













































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




























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










    <FormField
        label="SortOrder"
    >
        <Field
            type="number"
            name="sort_order"
            placeholder="SortOrder"
        />
    </FormField>





































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



























  <FormField label='IsActive' labelFor='is_active'>
      <Field
          name='is_active'
          id='is_active'
          component={SwitchField}
      ></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('/services/services-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default ServicesNew
