Made begin and end date required (#3283)

This commit is contained in:
Erik Jan de Wit 2022-09-12 15:35:30 +02:00 committed by GitHub
parent 0e1c788f5b
commit 76ce0e5315
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,7 @@ import {
Split,
SplitItem,
TimePicker,
ValidatedOptions,
} from "@patternfly/react-core";
import { HelpItem } from "../../../components/help-enabler/HelpItem";
@ -57,6 +58,7 @@ const DateTime = ({ name }: { name: string }) => {
name={name}
defaultValue=""
control={control}
rules={{ required: true }}
render={({ onChange, value }) => {
const dateTime = value.match(DATE_TIME_FORMAT) || ["", "", "0", "00"];
return (
@ -147,7 +149,7 @@ const FromTo = ({ name, ...rest }: NumberControlProps) => {
export const Time = () => {
const { t } = useTranslation("clients");
const { getValues } = useFormContext();
const { getValues, errors } = useFormContext();
const [repeat, setRepeat] = useState(getValues("month"));
return (
<>
@ -203,6 +205,11 @@ export const Time = () => {
fieldLabelId="clients:startTime"
/>
}
isRequired
helperTextInvalid={t("common:required")}
validated={
errors.notBefore ? ValidatedOptions.error : ValidatedOptions.default
}
>
<DateTime name="notBefore" />
</FormGroup>
@ -215,6 +222,13 @@ export const Time = () => {
fieldLabelId="clients:expireTime"
/>
}
isRequired
helperTextInvalid={t("common:required")}
validated={
errors.notOnOrAfter
? ValidatedOptions.error
: ValidatedOptions.default
}
>
<DateTime name="notOnOrAfter" />
</FormGroup>