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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    owner: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    content_type: 'post',
    
    
    
    
    
    
    
    content_ref: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    window_start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    window_end_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    impressions: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reach: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    profile_visits: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    likes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    comments: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    saves: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    shares: '',
    
    
    
    
    
    
    
    
    
    
    
}


const Insight_snapshotsNew = () => {
  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('/insight_snapshots/insight_snapshots-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                
                
                dateRangeStart && dateRangeEnd ?
                {
                    ...initialValues,
                    window_start_at: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    window_end_at: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
                } : initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>





















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























  <FormField label="ContentType" labelFor="content_type">
      <Field name="content_type" id="content_type" component="select">
      
        <option value="post">post</option>
      
        <option value="story">story</option>
      
        <option value="reel">reel</option>
      
        <option value="profile">profile</option>
      
      </Field>
  </FormField>













  <FormField
      label="ContentReference"
  >
      <Field
          name="content_ref"
          placeholder="ContentReference"
      />
  </FormField>





































  <FormField
      label="WindowStart"
  >
      <Field
          type="datetime-local"
          name="window_start_at"
          placeholder="WindowStart"
      />
  </FormField>



























  <FormField
      label="WindowEnd"
  >
      <Field
          type="datetime-local"
          name="window_end_at"
          placeholder="WindowEnd"
      />
  </FormField>























    <FormField
        label="Impressions"
    >
        <Field
            type="number"
            name="impressions"
            placeholder="Impressions"
        />
    </FormField>



























    <FormField
        label="Reach"
    >
        <Field
            type="number"
            name="reach"
            placeholder="Reach"
        />
    </FormField>



























    <FormField
        label="ProfileVisits"
    >
        <Field
            type="number"
            name="profile_visits"
            placeholder="ProfileVisits"
        />
    </FormField>



























    <FormField
        label="Likes"
    >
        <Field
            type="number"
            name="likes"
            placeholder="Likes"
        />
    </FormField>



























    <FormField
        label="Comments"
    >
        <Field
            type="number"
            name="comments"
            placeholder="Comments"
        />
    </FormField>



























    <FormField
        label="Saves"
    >
        <Field
            type="number"
            name="saves"
            placeholder="Saves"
        />
    </FormField>



























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

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

export default Insight_snapshotsNew
