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

const initialValues = {
    
    
    workout_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    workout_type: 'strength_training',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    goal_focus: 'fat_loss',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    difficulty: 'beginner',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    equipment_needed: 'none_bodyweight',
    
    
    
    
    
    
    
    
    
    
    duration_minutes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    estimated_calories: '',
    
    
    
    
    
    
    
    
    
    
    
    
    average_rating: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    cover_image: [],
    
    
    
    
    
    
    warmup_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    cooldown_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    safety_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    video_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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





























    <FormField label="Description" hasTextareaHeight>
        <Field name="description" as="textarea" placeholder="Description" />
    </FormField>







































  <FormField label="WorkoutType" labelFor="workout_type">
      <Field name="workout_type" id="workout_type" component="select">
      
        <option value="strength_training">strength_training</option>
      
        <option value="hiit">hiit</option>
      
        <option value="cardio">cardio</option>
      
        <option value="yoga">yoga</option>
      
        <option value="pilates">pilates</option>
      
        <option value="stretching">stretching</option>
      
        <option value="mobility">mobility</option>
      
        <option value="sport_specific">sport_specific</option>
      
        <option value="circuit">circuit</option>
      
        <option value="crossfit_style">crossfit_style</option>
      
        <option value="martial_arts">martial_arts</option>
      
        <option value="dance">dance</option>
      
        <option value="prenatal">prenatal</option>
      
        <option value="postnatal">postnatal</option>
      
        <option value="senior_friendly">senior_friendly</option>
      
        <option value="recovery">recovery</option>
      
        <option value="rehab">rehab</option>
      
      </Field>
  </FormField>



























  <FormField label="GoalFocus" labelFor="goal_focus">
      <Field name="goal_focus" id="goal_focus" component="select">
      
        <option value="fat_loss">fat_loss</option>
      
        <option value="muscle_gain">muscle_gain</option>
      
        <option value="endurance">endurance</option>
      
        <option value="flexibility">flexibility</option>
      
        <option value="sport_specific">sport_specific</option>
      
        <option value="recovery">recovery</option>
      
        <option value="rehab">rehab</option>
      
      </Field>
  </FormField>



























  <FormField label="Difficulty" labelFor="difficulty">
      <Field name="difficulty" id="difficulty" component="select">
      
        <option value="beginner">beginner</option>
      
        <option value="intermediate">intermediate</option>
      
        <option value="advanced">advanced</option>
      
        <option value="elite">elite</option>
      
      </Field>
  </FormField>



























  <FormField label="EquipmentNeeded" labelFor="equipment_needed">
      <Field name="equipment_needed" id="equipment_needed" component="select">
      
        <option value="none_bodyweight">none_bodyweight</option>
      
        <option value="dumbbells">dumbbells</option>
      
        <option value="barbell">barbell</option>
      
        <option value="resistance_bands">resistance_bands</option>
      
        <option value="gym_machines">gym_machines</option>
      
        <option value="trx">trx</option>
      
        <option value="kettlebells">kettlebells</option>
      
        <option value="swimming_pool">swimming_pool</option>
      
        <option value="bike">bike</option>
      
        <option value="treadmill">treadmill</option>
      
        <option value="rowing_machine">rowing_machine</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Duration(minutes)"
    >
        <Field
            type="number"
            name="duration_minutes"
            placeholder="Duration(minutes)"
        />
    </FormField>



























    <FormField
        label="EstimatedCaloriesBurned"
    >
        <Field
            type="number"
            name="estimated_calories"
            placeholder="EstimatedCaloriesBurned"
        />
    </FormField>



























    <FormField
        label="AverageRating"
    >
        <Field
            type="number"
            name="average_rating"
            placeholder="AverageRating"
        />
    </FormField>











































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







    <FormField label="WarmUpNotes" hasTextareaHeight>
        <Field name="warmup_notes" as="textarea" placeholder="WarmUpNotes" />
    </FormField>



























    <FormField label="CoolDownNotes" hasTextareaHeight>
        <Field name="cooldown_notes" as="textarea" placeholder="CoolDownNotes" />
    </FormField>



























    <FormField label="SafetyNotes" hasTextareaHeight>
        <Field name="safety_notes" as="textarea" placeholder="SafetyNotes" />
    </FormField>

























  <FormField
      label="VideoURL"
  >
      <Field
          name="video_url"
          placeholder="VideoURL"
      />
  </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('/workouts/workouts-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default WorkoutsNew
