Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 8x 8x | import { Button, Form } from "react-bootstrap";
import { useForm } from "react-hook-form";
function RequestTypeForm({
initialContents = {},
submitAction,
buttonLabel = "Create",
}) {
const {
register,
formState: { errors },
handleSubmit,
} = useForm({ defaultValues: initialContents });
return (
<Form onSubmit={handleSubmit(submitAction)}>
<Form.Group className="mb-3">
<Form.Label htmlFor="requestType">Request Type</Form.Label>
<Form.Control
data-testid="RequestTypeForm-requestType"
id="requestType"
type="text"
isInvalid={Boolean(errors.requestType)}
{...register("requestType", { required: "Request type is required" })}
/>
<Form.Control.Feedback type="invalid">
{errors.requestType?.message}
</Form.Control.Feedback>
</Form.Group>
<Button type="submit" data-testid="RequestTypeForm-submit">
{buttonLabel}
</Button>
</Form>
);
}
export default RequestTypeForm;
|