Made begin and end date required (#3283)
This commit is contained in:
parent
0e1c788f5b
commit
76ce0e5315
1 changed files with 15 additions and 1 deletions
|
@ -11,6 +11,7 @@ import {
|
||||||
Split,
|
Split,
|
||||||
SplitItem,
|
SplitItem,
|
||||||
TimePicker,
|
TimePicker,
|
||||||
|
ValidatedOptions,
|
||||||
} from "@patternfly/react-core";
|
} from "@patternfly/react-core";
|
||||||
|
|
||||||
import { HelpItem } from "../../../components/help-enabler/HelpItem";
|
import { HelpItem } from "../../../components/help-enabler/HelpItem";
|
||||||
|
@ -57,6 +58,7 @@ const DateTime = ({ name }: { name: string }) => {
|
||||||
name={name}
|
name={name}
|
||||||
defaultValue=""
|
defaultValue=""
|
||||||
control={control}
|
control={control}
|
||||||
|
rules={{ required: true }}
|
||||||
render={({ onChange, value }) => {
|
render={({ onChange, value }) => {
|
||||||
const dateTime = value.match(DATE_TIME_FORMAT) || ["", "", "0", "00"];
|
const dateTime = value.match(DATE_TIME_FORMAT) || ["", "", "0", "00"];
|
||||||
return (
|
return (
|
||||||
|
@ -147,7 +149,7 @@ const FromTo = ({ name, ...rest }: NumberControlProps) => {
|
||||||
|
|
||||||
export const Time = () => {
|
export const Time = () => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { getValues } = useFormContext();
|
const { getValues, errors } = useFormContext();
|
||||||
const [repeat, setRepeat] = useState(getValues("month"));
|
const [repeat, setRepeat] = useState(getValues("month"));
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -203,6 +205,11 @@ export const Time = () => {
|
||||||
fieldLabelId="clients:startTime"
|
fieldLabelId="clients:startTime"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
isRequired
|
||||||
|
helperTextInvalid={t("common:required")}
|
||||||
|
validated={
|
||||||
|
errors.notBefore ? ValidatedOptions.error : ValidatedOptions.default
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<DateTime name="notBefore" />
|
<DateTime name="notBefore" />
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
@ -215,6 +222,13 @@ export const Time = () => {
|
||||||
fieldLabelId="clients:expireTime"
|
fieldLabelId="clients:expireTime"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
isRequired
|
||||||
|
helperTextInvalid={t("common:required")}
|
||||||
|
validated={
|
||||||
|
errors.notOnOrAfter
|
||||||
|
? ValidatedOptions.error
|
||||||
|
: ValidatedOptions.default
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<DateTime name="notOnOrAfter" />
|
<DateTime name="notOnOrAfter" />
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|
Loading…
Reference in a new issue