mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 06:29:07 +00:00
form bugfixes
- validation message - cancel
This commit is contained in:
@@ -10,13 +10,8 @@ export default function ChakraInput(props) {
|
|||||||
<Field name={name}>
|
<Field name={name}>
|
||||||
{({ field, form }) => {
|
{({ field, form }) => {
|
||||||
return (
|
return (
|
||||||
<FormControl>
|
<FormControl isInvalid={form.errors[name] && form.touched[name]}>
|
||||||
<FormLabel
|
<FormLabel htmlFor={name}>{label}</FormLabel>
|
||||||
htmlFor={name}
|
|
||||||
isInvalid={form.errors[name] && form.touched[name]}
|
|
||||||
>
|
|
||||||
{label}
|
|
||||||
</FormLabel>
|
|
||||||
<Input id={name} {...rest} {...field} />
|
<Input id={name} {...rest} {...field} />
|
||||||
<FormErrorMessage>{form.errors[name]}</FormErrorMessage>
|
<FormErrorMessage>{form.errors[name]}</FormErrorMessage>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
@@ -15,13 +15,8 @@ export default function ChakraNumberInput(props) {
|
|||||||
<Field name={name}>
|
<Field name={name}>
|
||||||
{({ field, form }) => {
|
{({ field, form }) => {
|
||||||
return (
|
return (
|
||||||
<FormControl>
|
<FormControl isInvalid={form.errors[name] && form.touched[name]}>
|
||||||
<FormLabel
|
<FormLabel htmlFor={name}>{label}</FormLabel>
|
||||||
htmlFor={name}
|
|
||||||
isInvalid={form.errors[name] && form.touched[name]}
|
|
||||||
>
|
|
||||||
{label}
|
|
||||||
</FormLabel>
|
|
||||||
<NumberInput
|
<NumberInput
|
||||||
defaultValue={field.value}
|
defaultValue={field.value}
|
||||||
{...rest}
|
{...rest}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Button } from '@chakra-ui/button';
|
import { Button } from '@chakra-ui/button';
|
||||||
import { Formik } from 'formik';
|
import { Form, Formik } from 'formik';
|
||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import ChakraInput from '../../common/input/ChakraInput';
|
import ChakraInput from '../../common/input/ChakraInput';
|
||||||
import ChakraNumberInput from '../../common/input/ChakraNumberInput';
|
import ChakraNumberInput from '../../common/input/ChakraNumberInput';
|
||||||
@@ -23,10 +23,13 @@ export default function EventForm(props) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const validationSchema = Yup.object({
|
const validationSchema = Yup.object({
|
||||||
title: Yup.string().required(),
|
title: Yup.string().required('An event requires a title'),
|
||||||
subtitle: Yup.string(),
|
subtitle: Yup.string(),
|
||||||
presenter: Yup.string(),
|
presenter: Yup.string(),
|
||||||
timerDuration: Yup.number().required().min(1).max(60),
|
timerDuration: Yup.number()
|
||||||
|
.min(1)
|
||||||
|
.max(60)
|
||||||
|
.required('An event requires a duration'),
|
||||||
});
|
});
|
||||||
|
|
||||||
const submitForm = (values) => {
|
const submitForm = (values) => {
|
||||||
@@ -50,7 +53,7 @@ export default function EventForm(props) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{(props) => (
|
{(props) => (
|
||||||
<form onSubmit={props.handleSubmit}>
|
<Form onSubmit={props.handleSubmit}>
|
||||||
<ChakraInput name='title' label='Event Title' />
|
<ChakraInput name='title' label='Event Title' />
|
||||||
<ChakraInput name='subtitle' label='Event Subtitle' />
|
<ChakraInput name='subtitle' label='Event Subtitle' />
|
||||||
<ChakraInput name='presenter' label='Presenter Name' />
|
<ChakraInput name='presenter' label='Presenter Name' />
|
||||||
@@ -67,7 +70,7 @@ export default function EventForm(props) {
|
|||||||
<Button
|
<Button
|
||||||
variant='outline'
|
variant='outline'
|
||||||
disabled={props.isSubmitting}
|
disabled={props.isSubmitting}
|
||||||
onClick={() => console.log('ccancel form?')}
|
type='reset'
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
@@ -80,7 +83,7 @@ export default function EventForm(props) {
|
|||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</Form>
|
||||||
)}
|
)}
|
||||||
</Formik>
|
</Formik>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user