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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    workspace: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    subject: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    topic: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    mode: 'focus',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    session_type: 'pomodoro',
    
    
    
    
    
    
    
    
    
    
    
    
    started_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ended_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    duration_seconds: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    distraction_block_enabled: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    music_mode: 'off',
    
    
    
    
    
    
    
    focus_score: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    
    // get from url params
    const { dateRangeStart, dateRangeEnd } = router.query
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/study_sessions/study_sessions-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                
                
                dateRangeStart && dateRangeEnd ?
                {
                    ...initialValues,
                    started_at: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    ended_at: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
                } : initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>





















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



























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



























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



























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























  <FormField label="Mode" labelFor="mode">
      <Field name="mode" id="mode" component="select">
      
        <option value="focus">focus</option>
      
        <option value="learn">learn</option>
      
        <option value="review">review</option>
      
        <option value="test">test</option>
      
        <option value="challenge">challenge</option>
      
        <option value="tutor">tutor</option>
      
      </Field>
  </FormField>



























  <FormField label="SessionType" labelFor="session_type">
      <Field name="session_type" id="session_type" component="select">
      
        <option value="pomodoro">pomodoro</option>
      
        <option value="deep_work">deep_work</option>
      
        <option value="quick_review">quick_review</option>
      
      </Field>
  </FormField>























  <FormField
      label="StartedAt"
  >
      <Field
          type="datetime-local"
          name="started_at"
          placeholder="StartedAt"
      />
  </FormField>



























  <FormField
      label="EndedAt"
  >
      <Field
          type="datetime-local"
          name="ended_at"
          placeholder="EndedAt"
      />
  </FormField>























    <FormField
        label="DurationSeconds"
    >
        <Field
            type="number"
            name="duration_seconds"
            placeholder="DurationSeconds"
        />
    </FormField>





































  <FormField label='DistractionBlockEnabled' labelFor='distraction_block_enabled'>
      <Field
          name='distraction_block_enabled'
          id='distraction_block_enabled'
          component={SwitchField}
      ></Field>
  </FormField>

























  <FormField label="MusicMode" labelFor="music_mode">
      <Field name="music_mode" id="music_mode" component="select">
      
        <option value="off">off</option>
      
        <option value="lofi">lofi</option>
      
        <option value="ambient">ambient</option>
      
        <option value="white_noise">white_noise</option>
      
      </Field>
  </FormField>



















    <FormField
        label="FocusScore"
    >
        <Field
            type="number"
            name="focus_score"
            placeholder="FocusScore"
        />
    </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('/study_sessions/study_sessions-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Study_sessionsNew
