2020-09-17 13:51:40 +00:00
|
|
|
import React from "react";
|
2021-02-28 20:02:31 +00:00
|
|
|
import { useFormContext } from "react-hook-form";
|
2020-09-10 18:04:03 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2021-03-09 13:59:41 +00:00
|
|
|
import {
|
|
|
|
FormGroup,
|
|
|
|
TextArea,
|
|
|
|
TextInput,
|
|
|
|
ValidatedOptions,
|
|
|
|
} from "@patternfly/react-core";
|
|
|
|
|
|
|
|
import { HelpItem } from "../components/help-enabler/HelpItem";
|
2020-09-03 19:25:05 +00:00
|
|
|
|
2021-02-28 20:02:31 +00:00
|
|
|
import { FormAccess } from "../components/form-access/FormAccess";
|
|
|
|
import { ClientForm } from "./ClientDetails";
|
2020-09-03 19:25:05 +00:00
|
|
|
|
2021-02-28 20:02:31 +00:00
|
|
|
export const ClientDescription = () => {
|
2020-09-10 18:04:03 +00:00
|
|
|
const { t } = useTranslation("clients");
|
2021-02-28 20:02:31 +00:00
|
|
|
const { register, errors } = useFormContext<ClientForm>();
|
2020-09-03 19:25:05 +00:00
|
|
|
return (
|
2020-10-28 18:17:15 +00:00
|
|
|
<FormAccess role="manage-clients" unWrap>
|
2020-09-23 19:19:02 +00:00
|
|
|
<FormGroup
|
2021-03-09 13:59:41 +00:00
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
2021-04-06 17:39:27 +00:00
|
|
|
helpText="clients-help:clientId"
|
|
|
|
forLabel={t("common:clientId")}
|
2021-03-09 13:59:41 +00:00
|
|
|
forID="kc-client-id"
|
|
|
|
/>
|
|
|
|
}
|
2021-04-06 17:39:27 +00:00
|
|
|
label={t("common:clientId")}
|
2020-09-23 19:19:02 +00:00
|
|
|
fieldId="kc-client-id"
|
|
|
|
helperTextInvalid={t("common:required")}
|
2020-11-09 19:49:32 +00:00
|
|
|
validated={
|
|
|
|
errors.clientId ? ValidatedOptions.error : ValidatedOptions.default
|
|
|
|
}
|
2020-09-23 19:19:02 +00:00
|
|
|
isRequired
|
|
|
|
>
|
2020-09-03 19:25:05 +00:00
|
|
|
<TextInput
|
2020-09-23 19:19:02 +00:00
|
|
|
ref={register({ required: true })}
|
2020-09-03 19:25:05 +00:00
|
|
|
type="text"
|
|
|
|
id="kc-client-id"
|
|
|
|
name="clientId"
|
2020-11-09 19:49:32 +00:00
|
|
|
validated={
|
|
|
|
errors.clientId ? ValidatedOptions.error : ValidatedOptions.default
|
|
|
|
}
|
2020-09-03 19:25:05 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
2021-03-09 13:59:41 +00:00
|
|
|
<FormGroup
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:clientName"
|
|
|
|
forLabel={t("common:name")}
|
|
|
|
forID="kc-name"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
label={t("common:name")}
|
|
|
|
fieldId="kc-name"
|
|
|
|
>
|
2020-09-17 13:51:40 +00:00
|
|
|
<TextInput ref={register()} type="text" id="kc-name" name="name" />
|
2020-09-03 19:25:05 +00:00
|
|
|
</FormGroup>
|
2021-02-16 19:18:09 +00:00
|
|
|
<FormGroup
|
2021-03-09 13:59:41 +00:00
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:description"
|
|
|
|
forLabel={t("common:description")}
|
|
|
|
forID="kc-description"
|
|
|
|
/>
|
|
|
|
}
|
2021-02-16 19:18:09 +00:00
|
|
|
label={t("common:description")}
|
|
|
|
fieldId="kc-description"
|
|
|
|
validated={
|
|
|
|
errors.description ? ValidatedOptions.error : ValidatedOptions.default
|
|
|
|
}
|
|
|
|
helperTextInvalid={errors.description?.message}
|
|
|
|
>
|
2021-03-09 13:59:41 +00:00
|
|
|
<TextArea
|
2021-02-16 19:18:09 +00:00
|
|
|
ref={register({
|
|
|
|
maxLength: {
|
|
|
|
value: 255,
|
|
|
|
message: t("common:maxLength", { length: 255 }),
|
|
|
|
},
|
|
|
|
})}
|
2020-09-03 19:25:05 +00:00
|
|
|
type="text"
|
|
|
|
id="kc-description"
|
|
|
|
name="description"
|
2021-02-16 19:18:09 +00:00
|
|
|
validated={
|
|
|
|
errors.description
|
|
|
|
? ValidatedOptions.error
|
|
|
|
: ValidatedOptions.default
|
|
|
|
}
|
2020-09-03 19:25:05 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
2020-10-28 18:17:15 +00:00
|
|
|
</FormAccess>
|
2020-09-03 19:25:05 +00:00
|
|
|
);
|
|
|
|
};
|