143 lines
4.2 KiB
TypeScript
143 lines
4.2 KiB
TypeScript
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/scouting/scoutingSlice';
|
|
import { useAppDispatch } from '../../stores/hooks';
|
|
import { useRouter } from 'next/router';
|
|
import moment from 'moment';
|
|
|
|
const initialValues = {
|
|
team_number: '',
|
|
|
|
coral_l1: '',
|
|
|
|
coral_l2: '',
|
|
|
|
coral_l3: '',
|
|
|
|
coral_l4: '',
|
|
|
|
algae_processor: '',
|
|
|
|
algae_net: '',
|
|
};
|
|
|
|
const ScoutingNew = () => {
|
|
const router = useRouter();
|
|
const dispatch = useAppDispatch();
|
|
|
|
const handleSubmit = async (data) => {
|
|
await dispatch(create(data));
|
|
await router.push('/scouting/scouting-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='Team number'>
|
|
<Field
|
|
type='number'
|
|
name='team_number'
|
|
placeholder='Team number'
|
|
/>
|
|
</FormField>
|
|
|
|
<FormField label='Coral l1'>
|
|
<Field type='number' name='coral_l1' placeholder='Coral l1' />
|
|
</FormField>
|
|
|
|
<FormField label='Coral l2'>
|
|
<Field type='number' name='coral_l2' placeholder='Coral l2' />
|
|
</FormField>
|
|
|
|
<FormField label='Coral l3'>
|
|
<Field type='number' name='coral_l3' placeholder='Coral l3' />
|
|
</FormField>
|
|
|
|
<FormField label='Coral l4'>
|
|
<Field type='number' name='coral_l4' placeholder='Coral l4' />
|
|
</FormField>
|
|
|
|
<FormField label='Algae processor'>
|
|
<Field
|
|
type='number'
|
|
name='algae_processor'
|
|
placeholder='Algae processor'
|
|
/>
|
|
</FormField>
|
|
|
|
<FormField label='Algae net'>
|
|
<Field type='number' name='algae_net' placeholder='Algae net' />
|
|
</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('/scouting/scouting-list')}
|
|
/>
|
|
</BaseButtons>
|
|
</Form>
|
|
</Formik>
|
|
</CardBox>
|
|
</SectionMain>
|
|
</>
|
|
);
|
|
};
|
|
|
|
ScoutingNew.getLayout = function getLayout(page: ReactElement) {
|
|
return (
|
|
<LayoutAuthenticated permission={'CREATE_SCOUTING'}>
|
|
{page}
|
|
</LayoutAuthenticated>
|
|
);
|
|
};
|
|
|
|
export default ScoutingNew;
|