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

const initialValues = {
    
    
    exercise_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    exercise_type: 'strength',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    primary_muscle_group: 'full_body',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    equipment: 'none_bodyweight',
    
    
    
    
    
    
    
    
    instructions: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    common_mistakes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    coaching_cues: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    illustrations: [],
    
    
    
    
}


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

    
    

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









































  <FormField label="ExerciseType" labelFor="exercise_type">
      <Field name="exercise_type" id="exercise_type" component="select">
      
        <option value="strength">strength</option>
      
        <option value="cardio">cardio</option>
      
        <option value="mobility">mobility</option>
      
        <option value="stretch">stretch</option>
      
        <option value="skill">skill</option>
      
      </Field>
  </FormField>



























  <FormField label="PrimaryMuscleGroup" labelFor="primary_muscle_group">
      <Field name="primary_muscle_group" id="primary_muscle_group" component="select">
      
        <option value="full_body">full_body</option>
      
        <option value="upper_body">upper_body</option>
      
        <option value="lower_body">lower_body</option>
      
        <option value="core">core</option>
      
        <option value="chest">chest</option>
      
        <option value="back">back</option>
      
        <option value="shoulders">shoulders</option>
      
        <option value="arms">arms</option>
      
        <option value="glutes">glutes</option>
      
        <option value="legs">legs</option>
      
      </Field>
  </FormField>



























  <FormField label="Equipment" labelFor="equipment">
      <Field name="equipment" id="equipment" component="select">
      
        <option value="none_bodyweight">none_bodyweight</option>
      
        <option value="dumbbells">dumbbells</option>
      
        <option value="barbell">barbell</option>
      
        <option value="bands">bands</option>
      
        <option value="machines">machines</option>
      
        <option value="trx">trx</option>
      
        <option value="kettlebell">kettlebell</option>
      
        <option value="cable">cable</option>
      
        <option value="medicine_ball">medicine_ball</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>















    <FormField label="Instructions" hasTextareaHeight>
        <Field name="instructions" as="textarea" placeholder="Instructions" />
    </FormField>



























    <FormField label="CommonMistakes" hasTextareaHeight>
        <Field name="common_mistakes" as="textarea" placeholder="CommonMistakes" />
    </FormField>



























    <FormField label="CoachingCues" hasTextareaHeight>
        <Field name="coaching_cues" as="textarea" placeholder="CoachingCues" />
    </FormField>















































  <FormField>
      <Field
          label='Illustrations'
          color='info'
          icon={mdiUpload}
          path={'exercises/illustrations'}
          name='illustrations'
          id='illustrations'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormImagePicker}
      ></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('/exercises/exercises-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default ExercisesNew
